Mercurial > hg > graal-compiler
comparison graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/ArgumentsTest.java @ 14628:a08b8694f556
Truffle: Node API changes
deprecate adoptChild, no longer needed in constructor
add Node#insert for inserting new nodes into the tree (previously adoptChild)
add Node#adoptChildren() helper method that adopts all (direct and indirect) children of a node, automatically called in TruffleRuntime#createCallTarget
author | Andreas Woess <andreas.woess@jku.at> |
---|---|
date | Wed, 19 Mar 2014 23:11:46 +0100 |
parents | df1d665ca846 |
children | 64dcb92ee75a |
comparison
equal
deleted
inserted
replaced
14627:46c020971d9c | 14628:a08b8694f556 |
---|---|
59 CallTarget target = runtime.createCallTarget(rootNode); | 59 CallTarget target = runtime.createCallTarget(rootNode); |
60 Object result = target.call(new TestArguments(20, 22)); | 60 Object result = target.call(new TestArguments(20, 22)); |
61 Assert.assertEquals(42, result); | 61 Assert.assertEquals(42, result); |
62 } | 62 } |
63 | 63 |
64 class TestArguments extends Arguments { | 64 private static class TestArguments extends Arguments { |
65 | 65 |
66 final int[] values; | 66 final int[] values; |
67 | 67 |
68 TestArguments(int... values) { | 68 TestArguments(int... values) { |
69 this.values = values; | 69 this.values = values; |
70 } | 70 } |
71 } | 71 } |
72 | 72 |
73 class TestRootNode extends RootNode { | 73 private static class TestRootNode extends RootNode { |
74 | 74 |
75 @Children private TestArgumentNode[] children; | 75 @Children private final TestArgumentNode[] children; |
76 | 76 |
77 TestRootNode(TestArgumentNode[] children) { | 77 TestRootNode(TestArgumentNode[] children) { |
78 super(null); | 78 super(null); |
79 this.children = adoptChildren(children); | 79 this.children = children; |
80 } | 80 } |
81 | 81 |
82 @Override | 82 @Override |
83 public Object execute(VirtualFrame frame) { | 83 public Object execute(VirtualFrame frame) { |
84 int sum = 0; | 84 int sum = 0; |
87 } | 87 } |
88 return sum; | 88 return sum; |
89 } | 89 } |
90 } | 90 } |
91 | 91 |
92 class TestArgumentNode extends Node { | 92 private static class TestArgumentNode extends Node { |
93 | 93 |
94 private final int index; | 94 private final int index; |
95 | 95 |
96 TestArgumentNode(int index) { | 96 TestArgumentNode(int index) { |
97 super(null); | 97 super(null); |