Mercurial > hg > truffle
annotate truffle/com.oracle.truffle.tools.test/src/com/oracle/truffle/tools/test/TestNodes.java @ 22157:dc83cc1f94f2
Using fully qualified imports
author | Jaroslav Tulach <jaroslav.tulach@oracle.com> |
---|---|
date | Wed, 16 Sep 2015 11:33:22 +0200 |
parents | 5bc7f7b867ab |
children | 1c0f490984d5 |
rev | line source |
---|---|
18988
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
1 /* |
21568
3b8bbf51d320
Truffle/Debugging: add the Truffle DebugEngine and supporting code, as well as add a crude command-line debugging tool used mainly to test the DebugEngine. Migrate the small tols out of project com.oracle.truffle.api into the new project com.oracle.truffle.tools.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
20106
diff
changeset
|
2 * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. |
18988
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
4 * |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
21568
3b8bbf51d320
Truffle/Debugging: add the Truffle DebugEngine and supporting code, as well as add a crude command-line debugging tool used mainly to test the DebugEngine. Migrate the small tols out of project com.oracle.truffle.api into the new project com.oracle.truffle.tools.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
20106
diff
changeset
|
7 * published by the Free Software Foundation. Oracle designates this |
3b8bbf51d320
Truffle/Debugging: add the Truffle DebugEngine and supporting code, as well as add a crude command-line debugging tool used mainly to test the DebugEngine. Migrate the small tols out of project com.oracle.truffle.api into the new project com.oracle.truffle.tools.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
20106
diff
changeset
|
8 * particular file as subject to the "Classpath" exception as provided |
3b8bbf51d320
Truffle/Debugging: add the Truffle DebugEngine and supporting code, as well as add a crude command-line debugging tool used mainly to test the DebugEngine. Migrate the small tols out of project com.oracle.truffle.api into the new project com.oracle.truffle.tools.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
20106
diff
changeset
|
9 * by Oracle in the LICENSE file that accompanied this code. |
18988
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
10 * |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
11 * This code is distributed in the hope that it will be useful, but WITHOUT |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
14 * version 2 for more details (a copy is included in the LICENSE file that |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
15 * accompanied this code). |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
16 * |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
17 * You should have received a copy of the GNU General Public License version |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
18 * 2 along with this work; if not, write to the Free Software Foundation, |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
20 * |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
22 * or visit www.oracle.com if you need additional information or have any |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
23 * questions. |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
24 */ |
21568
3b8bbf51d320
Truffle/Debugging: add the Truffle DebugEngine and supporting code, as well as add a crude command-line debugging tool used mainly to test the DebugEngine. Migrate the small tols out of project com.oracle.truffle.api into the new project com.oracle.truffle.tools.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
20106
diff
changeset
|
25 package com.oracle.truffle.tools.test; |
18988
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
26 |
22157
dc83cc1f94f2
Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22003
diff
changeset
|
27 import com.oracle.truffle.api.CallTarget; |
dc83cc1f94f2
Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22003
diff
changeset
|
28 import com.oracle.truffle.api.Truffle; |
dc83cc1f94f2
Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22003
diff
changeset
|
29 import com.oracle.truffle.api.TruffleLanguage; |
dc83cc1f94f2
Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22003
diff
changeset
|
30 import com.oracle.truffle.api.frame.VirtualFrame; |
dc83cc1f94f2
Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22003
diff
changeset
|
31 import com.oracle.truffle.api.instrument.KillException; |
dc83cc1f94f2
Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22003
diff
changeset
|
32 import com.oracle.truffle.api.instrument.Probe; |
dc83cc1f94f2
Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22003
diff
changeset
|
33 import com.oracle.truffle.api.instrument.ProbeNode; |
18988
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
34 import com.oracle.truffle.api.instrument.ProbeNode.WrapperNode; |
22157
dc83cc1f94f2
Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22003
diff
changeset
|
35 import com.oracle.truffle.api.nodes.Node; |
dc83cc1f94f2
Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22003
diff
changeset
|
36 import com.oracle.truffle.api.nodes.NodeCost; |
dc83cc1f94f2
Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22003
diff
changeset
|
37 import com.oracle.truffle.api.nodes.NodeInfo; |
dc83cc1f94f2
Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22003
diff
changeset
|
38 import com.oracle.truffle.api.nodes.RootNode; |
dc83cc1f94f2
Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22003
diff
changeset
|
39 import com.oracle.truffle.api.source.LineLocation; |
dc83cc1f94f2
Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22003
diff
changeset
|
40 import com.oracle.truffle.api.source.Source; |
dc83cc1f94f2
Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22003
diff
changeset
|
41 import com.oracle.truffle.api.source.SourceSection; |
18988
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
42 |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
43 /** |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
44 * Nodes and an {@linkplain CallTarget executable ASTs} for testing. |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
45 */ |
20106
2e3cc2a27711
Truffle/Instrumentation: a new flavor of Instrument that lazily provides an AST fragment to be attached/adopted directly into a running AST, and to which execution event notifications will be routed. Important use cases so far include conditional breakpoints (with optimizeable conditions) and Ruby set_trace_func.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19869
diff
changeset
|
46 class TestNodes { |
18988
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
47 |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
48 /** |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
49 * A fake source used for testing: empty line 1, expression on line 2. |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
50 */ |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
51 public static final Source expr13Source = Source.fromText("\n6+7\n", "Test Source: expression on line 2 that evaluates to 13"); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
52 public static final LineLocation expr13Line1 = expr13Source.createLineLocation(1); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
53 public static final LineLocation expr13Line2 = expr13Source.createLineLocation(2); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
54 |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
55 /** |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
56 * An executable addition expression that evaluates to 13. |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
57 */ |
20106
2e3cc2a27711
Truffle/Instrumentation: a new flavor of Instrument that lazily provides an AST fragment to be attached/adopted directly into a running AST, and to which execution event notifications will be routed. Important use cases so far include conditional breakpoints (with optimizeable conditions) and Ruby set_trace_func.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19869
diff
changeset
|
58 static CallTarget createExpr13TestCallTarget() { |
18988
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
59 final RootNode rootNode = createExpr13TestRootNode(); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
60 return Truffle.getRuntime().createCallTarget(rootNode); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
61 } |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
62 |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
63 /** |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
64 * Root holding an addition expression that evaluates to 13. |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
65 */ |
20106
2e3cc2a27711
Truffle/Instrumentation: a new flavor of Instrument that lazily provides an AST fragment to be attached/adopted directly into a running AST, and to which execution event notifications will be routed. Important use cases so far include conditional breakpoints (with optimizeable conditions) and Ruby set_trace_func.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19869
diff
changeset
|
66 static RootNode createExpr13TestRootNode() { |
18988
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
67 final TestLanguageNode ast = createExpr13AST(); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
68 final TestRootNode rootNode = new TestRootNode(ast); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
69 rootNode.adoptChildren(); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
70 return rootNode; |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
71 } |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
72 |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
73 /** |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
74 * Addition expression that evaluates to 13, with faked source attribution. |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
75 */ |
20106
2e3cc2a27711
Truffle/Instrumentation: a new flavor of Instrument that lazily provides an AST fragment to be attached/adopted directly into a running AST, and to which execution event notifications will be routed. Important use cases so far include conditional breakpoints (with optimizeable conditions) and Ruby set_trace_func.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19869
diff
changeset
|
76 static TestLanguageNode createExpr13AST() { |
18988
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
77 final SourceSection leftSourceSection = expr13Source.createSection("left", 1, 1); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
78 final TestValueNode leftValueNode = new TestValueNode(6, leftSourceSection); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
79 final SourceSection rightSourceSection = expr13Source.createSection("right", 3, 1); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
80 final TestValueNode rightValueNode = new TestValueNode(7, rightSourceSection); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
81 final SourceSection exprSourceSection = expr13Source.createSection("expr", 1, 3); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
82 return new TestAddNode(leftValueNode, rightValueNode, exprSourceSection); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
83 } |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
84 |
20106
2e3cc2a27711
Truffle/Instrumentation: a new flavor of Instrument that lazily provides an AST fragment to be attached/adopted directly into a running AST, and to which execution event notifications will be routed. Important use cases so far include conditional breakpoints (with optimizeable conditions) and Ruby set_trace_func.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19869
diff
changeset
|
85 abstract static class TestLanguageNode extends Node { |
18988
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
86 public abstract Object execute(VirtualFrame frame); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
87 |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
88 public TestLanguageNode() { |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
89 } |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
90 |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
91 public TestLanguageNode(SourceSection srcSection) { |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
92 super(srcSection); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
93 } |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
94 |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
95 @Override |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
96 public boolean isInstrumentable() { |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
97 return true; |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
98 } |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
99 |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
100 @Override |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
101 public WrapperNode createWrapperNode() { |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
102 return new TestWrapperNode(this); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
103 } |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
104 } |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
105 |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
106 @NodeInfo(cost = NodeCost.NONE) |
20106
2e3cc2a27711
Truffle/Instrumentation: a new flavor of Instrument that lazily provides an AST fragment to be attached/adopted directly into a running AST, and to which execution event notifications will be routed. Important use cases so far include conditional breakpoints (with optimizeable conditions) and Ruby set_trace_func.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19869
diff
changeset
|
107 static class TestWrapperNode extends TestLanguageNode implements WrapperNode { |
18988
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
108 @Child private TestLanguageNode child; |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
109 @Child private ProbeNode probeNode; |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
110 |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
111 public TestWrapperNode(TestLanguageNode child) { |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
112 assert !(child instanceof TestWrapperNode); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
113 this.child = child; |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
114 } |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
115 |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
116 @Override |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
117 public String instrumentationInfo() { |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
118 return "Wrapper node for testing"; |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
119 } |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
120 |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
121 @Override |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
122 public boolean isInstrumentable() { |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
123 return false; |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
124 } |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
125 |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
126 @Override |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
127 public void insertProbe(ProbeNode newProbeNode) { |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
128 this.probeNode = newProbeNode; |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
129 } |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
130 |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
131 @Override |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
132 public Probe getProbe() { |
19869
1d6a7ea5de59
Truffle/Instrumentation: remove support for "probe-lite", an optimization for a particular use case that no longer seems worth the complexity.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
18988
diff
changeset
|
133 return probeNode.getProbe(); |
18988
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
134 } |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
135 |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
136 @Override |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
137 public Node getChild() { |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
138 return child; |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
139 } |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
140 |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
141 @Override |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
142 public Object execute(VirtualFrame frame) { |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
143 probeNode.enter(child, frame); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
144 Object result; |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
145 |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
146 try { |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
147 result = child.execute(frame); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
148 probeNode.returnValue(child, frame, result); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
149 } catch (KillException e) { |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
150 throw (e); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
151 } catch (Exception e) { |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
152 probeNode.returnExceptional(child, frame, e); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
153 throw (e); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
154 } |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
155 |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
156 return result; |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
157 } |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
158 } |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
159 |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
160 /** |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
161 * Truffle requires that all guest languages to have a {@link RootNode} which sits atop any AST |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
162 * of the guest language. This is necessary since creating a {@link CallTarget} is how Truffle |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
163 * completes an AST. The root nodes serves as our entry point into a program. |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
164 */ |
20106
2e3cc2a27711
Truffle/Instrumentation: a new flavor of Instrument that lazily provides an AST fragment to be attached/adopted directly into a running AST, and to which execution event notifications will be routed. Important use cases so far include conditional breakpoints (with optimizeable conditions) and Ruby set_trace_func.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19869
diff
changeset
|
165 static class TestRootNode extends RootNode { |
18988
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
166 @Child private TestLanguageNode body; |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
167 |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
168 /** |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
169 * This constructor emulates the global machinery that applies registered probers to every |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
170 * newly created AST. Global registry is not used, since that would interfere with other |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
171 * tests run in the same environment. |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
172 */ |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
173 public TestRootNode(TestLanguageNode body) { |
22003
5bc7f7b867ab
Making debugger always on for each TruffleVM execution. Introducing EventConsumer to process such debugger events. Requesting each RootNode to be associated with a TruffleLanguage, so debugger can find out proper context for each Node where executions gets suspended.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
174 super(TruffleLanguage.class, null, null); |
18988
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
175 this.body = body; |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
176 } |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
177 |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
178 @Override |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
179 public Object execute(VirtualFrame frame) { |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
180 return body.execute(frame); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
181 } |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
182 |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
183 @Override |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
184 public boolean isCloningAllowed() { |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
185 return true; |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
186 } |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
187 |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
188 @Override |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
189 public void applyInstrumentation() { |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
190 Probe.applyASTProbers(body); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
191 } |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
192 } |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
193 |
20106
2e3cc2a27711
Truffle/Instrumentation: a new flavor of Instrument that lazily provides an AST fragment to be attached/adopted directly into a running AST, and to which execution event notifications will be routed. Important use cases so far include conditional breakpoints (with optimizeable conditions) and Ruby set_trace_func.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19869
diff
changeset
|
194 static class TestValueNode extends TestLanguageNode { |
18988
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
195 private final int value; |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
196 |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
197 public TestValueNode(int value) { |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
198 this.value = value; |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
199 } |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
200 |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
201 public TestValueNode(int value, SourceSection srcSection) { |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
202 super(srcSection); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
203 this.value = value; |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
204 } |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
205 |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
206 @Override |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
207 public Object execute(VirtualFrame frame) { |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
208 return new Integer(this.value); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
209 } |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
210 } |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
211 |
20106
2e3cc2a27711
Truffle/Instrumentation: a new flavor of Instrument that lazily provides an AST fragment to be attached/adopted directly into a running AST, and to which execution event notifications will be routed. Important use cases so far include conditional breakpoints (with optimizeable conditions) and Ruby set_trace_func.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
19869
diff
changeset
|
212 static class TestAddNode extends TestLanguageNode { |
18988
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
213 @Child private TestLanguageNode leftChild; |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
214 @Child private TestLanguageNode rightChild; |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
215 |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
216 public TestAddNode(TestValueNode leftChild, TestValueNode rightChild, SourceSection sourceSection) { |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
217 super(sourceSection); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
218 this.leftChild = insert(leftChild); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
219 this.rightChild = insert(rightChild); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
220 } |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
221 |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
222 @Override |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
223 public Object execute(VirtualFrame frame) { |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
224 return new Integer(((Integer) leftChild.execute(frame)).intValue() + ((Integer) rightChild.execute(frame)).intValue()); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
225 } |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
226 } |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
227 |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
228 } |