Mercurial > hg > truffle
annotate truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/examples/Interop.java @ 22241:14e6dfb1ef05
Truffle/Testing: massive rework of tests to accommodate recent instrumentation change with respect to "applyInstrumentation"
- Caused by lack of a "vm" known to the Accessor during most testing, making the Instrumenter unavailable, which is now required to create a CallTarget
- Modified the Instrumenter/Accessor with a static field that can be reflectively "poked" with a vm value for testing
- Create a pair of methods to globally enable/disable testing mode to modify that static field and restore it when tests complete.
author | Michael Van De Vanter <michael.van.de.vanter@oracle.com> |
---|---|
date | Tue, 22 Sep 2015 20:31:19 -0700 |
parents | dc83cc1f94f2 |
children | 0d36601f233e |
rev | line source |
---|---|
19301
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
1 /* |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
2 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
4 * |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
8 * |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
13 * accompanied this code). |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
14 * |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
18 * |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
21 * questions. |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
22 */ |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
23 package com.oracle.truffle.api.dsl.test.examples; |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
24 |
22241
14e6dfb1ef05
Truffle/Testing: massive rework of tests to accommodate recent instrumentation change with respect to "applyInstrumentation"
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22157
diff
changeset
|
25 import static com.oracle.truffle.api.dsl.test.examples.ExampleNode.createArguments; |
14e6dfb1ef05
Truffle/Testing: massive rework of tests to accommodate recent instrumentation change with respect to "applyInstrumentation"
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22157
diff
changeset
|
26 import static com.oracle.truffle.api.dsl.test.examples.ExampleNode.createTarget; |
14e6dfb1ef05
Truffle/Testing: massive rework of tests to accommodate recent instrumentation change with respect to "applyInstrumentation"
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22157
diff
changeset
|
27 import static org.junit.Assert.assertEquals; |
14e6dfb1ef05
Truffle/Testing: massive rework of tests to accommodate recent instrumentation change with respect to "applyInstrumentation"
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22157
diff
changeset
|
28 |
14e6dfb1ef05
Truffle/Testing: massive rework of tests to accommodate recent instrumentation change with respect to "applyInstrumentation"
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22157
diff
changeset
|
29 import org.junit.After; |
14e6dfb1ef05
Truffle/Testing: massive rework of tests to accommodate recent instrumentation change with respect to "applyInstrumentation"
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22157
diff
changeset
|
30 import org.junit.Before; |
14e6dfb1ef05
Truffle/Testing: massive rework of tests to accommodate recent instrumentation change with respect to "applyInstrumentation"
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22157
diff
changeset
|
31 import org.junit.Test; |
14e6dfb1ef05
Truffle/Testing: massive rework of tests to accommodate recent instrumentation change with respect to "applyInstrumentation"
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22157
diff
changeset
|
32 |
22157
dc83cc1f94f2
Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
33 import com.oracle.truffle.api.CallTarget; |
19301
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
34 import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; |
22157
dc83cc1f94f2
Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
35 import com.oracle.truffle.api.dsl.Cached; |
dc83cc1f94f2
Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
36 import com.oracle.truffle.api.dsl.Specialization; |
19301
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
37 import com.oracle.truffle.api.dsl.test.examples.InteropFactory.UseInteropNodeGen; |
22241
14e6dfb1ef05
Truffle/Testing: massive rework of tests to accommodate recent instrumentation change with respect to "applyInstrumentation"
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22157
diff
changeset
|
38 import com.oracle.truffle.api.dsl.test.utilities.InstrumentationTestMode; |
22157
dc83cc1f94f2
Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
39 import com.oracle.truffle.api.frame.VirtualFrame; |
dc83cc1f94f2
Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
40 import com.oracle.truffle.api.nodes.Node; |
19301
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
41 |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
42 /** |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
43 * This example aims to illustrate how the {@link Cached} annotation can be used to implement a |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
44 * cache for a simplified language interoperability pattern. |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
45 */ |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
46 public class Interop { |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
47 |
22241
14e6dfb1ef05
Truffle/Testing: massive rework of tests to accommodate recent instrumentation change with respect to "applyInstrumentation"
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22157
diff
changeset
|
48 @Before |
14e6dfb1ef05
Truffle/Testing: massive rework of tests to accommodate recent instrumentation change with respect to "applyInstrumentation"
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22157
diff
changeset
|
49 public void before() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { |
14e6dfb1ef05
Truffle/Testing: massive rework of tests to accommodate recent instrumentation change with respect to "applyInstrumentation"
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22157
diff
changeset
|
50 InstrumentationTestMode.set(true); |
14e6dfb1ef05
Truffle/Testing: massive rework of tests to accommodate recent instrumentation change with respect to "applyInstrumentation"
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22157
diff
changeset
|
51 } |
14e6dfb1ef05
Truffle/Testing: massive rework of tests to accommodate recent instrumentation change with respect to "applyInstrumentation"
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22157
diff
changeset
|
52 |
14e6dfb1ef05
Truffle/Testing: massive rework of tests to accommodate recent instrumentation change with respect to "applyInstrumentation"
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22157
diff
changeset
|
53 @After |
14e6dfb1ef05
Truffle/Testing: massive rework of tests to accommodate recent instrumentation change with respect to "applyInstrumentation"
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22157
diff
changeset
|
54 public void after() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { |
14e6dfb1ef05
Truffle/Testing: massive rework of tests to accommodate recent instrumentation change with respect to "applyInstrumentation"
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22157
diff
changeset
|
55 InstrumentationTestMode.set(false); |
14e6dfb1ef05
Truffle/Testing: massive rework of tests to accommodate recent instrumentation change with respect to "applyInstrumentation"
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22157
diff
changeset
|
56 } |
14e6dfb1ef05
Truffle/Testing: massive rework of tests to accommodate recent instrumentation change with respect to "applyInstrumentation"
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22157
diff
changeset
|
57 |
19301
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
58 @Test |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
59 public void testInterop() { |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
60 UseInterop node = UseInteropNodeGen.create(createArguments(2)); |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
61 CallTarget target = createTarget(node); |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
62 TruffleObject o1 = new TruffleObject(); |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
63 TruffleObject o2 = new TruffleObject(); |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
64 TruffleObject o3 = new TruffleObject(); |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
65 TruffleObject o4 = new TruffleObject(); |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
66 assertEquals(42, target.call(o1, 42)); |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
67 assertEquals(43, target.call(o2, 43)); |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
68 assertEquals(44, target.call(o3, 44)); |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
69 assertEquals(3, node.cached); |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
70 assertEquals(0, node.generic); |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
71 assertEquals(45, target.call(o4, 45)); // operation gets generic |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
72 assertEquals(42, target.call(o1, 42)); |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
73 assertEquals(43, target.call(o2, 43)); |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
74 assertEquals(44, target.call(o3, 44)); |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
75 assertEquals(3, node.cached); |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
76 assertEquals(4, node.generic); |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
77 } |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
78 |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
79 public static class UseInterop extends ExampleNode { |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
80 |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
81 int cached = 0; |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
82 int generic = 0; |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
83 |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
84 @Specialization(guards = "operation.accept(target)") |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
85 protected Object interopCached(VirtualFrame frame, TruffleObject target, Object value, // |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
86 @Cached("target.createOperation()") TruffleObjectOperation operation) { |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
87 cached++; |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
88 return operation.execute(frame, target, value); |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
89 } |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
90 |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
91 @Specialization(contains = "interopCached") |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
92 protected Object interopGeneric(VirtualFrame frame, TruffleObject target, Object value) { |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
93 generic++; |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
94 return target.createOperation().execute(frame, target, value); |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
95 } |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
96 } |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
97 |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
98 public abstract static class TruffleObjectOperation extends Node { |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
99 |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
100 public abstract boolean accept(TruffleObject object); |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
101 |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
102 public abstract Object execute(VirtualFrame frame, Object target, Object value); |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
103 |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
104 } |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
105 |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
106 public static class TruffleObject { |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
107 |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
108 @TruffleBoundary |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
109 public TruffleObjectOperation createOperation() { |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
110 return new TruffleObjectOperation() { |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
111 @Override |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
112 public Object execute(VirtualFrame frame, Object target, Object value) { |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
113 return value; |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
114 } |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
115 |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
116 @Override |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
117 public boolean accept(TruffleObject object) { |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
118 return TruffleObject.this == object; |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
119 } |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
120 }; |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
121 } |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
122 } |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
123 |
a79a3e467245
Truffle-DSL: move examples package into test package for the project canonicalizer.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
124 } |