Mercurial > hg > graal-jvmci-8
comparison graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/nodes/serial/TestNodes.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 | 96c1d057a5ed |
children |
comparison
equal
deleted
inserted
replaced
14627:46c020971d9c | 14628:a08b8694f556 |
---|---|
82 static class NodeWithOneChild extends EmptyNode { | 82 static class NodeWithOneChild extends EmptyNode { |
83 | 83 |
84 @Child Node child; | 84 @Child Node child; |
85 | 85 |
86 public NodeWithOneChild(Node child) { | 86 public NodeWithOneChild(Node child) { |
87 this.child = adoptChild(child); | 87 this.child = child; |
88 } | 88 } |
89 | 89 |
90 } | 90 } |
91 | 91 |
92 static class NodeWithTwoChilds extends EmptyNode { | 92 static class NodeWithTwoChilds extends EmptyNode { |
93 | 93 |
94 @Child Node child1; | 94 @Child Node child1; |
95 @Child Node child2; | 95 @Child Node child2; |
96 | 96 |
97 public NodeWithTwoChilds(Node child1, Node child2) { | 97 public NodeWithTwoChilds(Node child1, Node child2) { |
98 this.child1 = adoptChild(child1); | 98 this.child1 = child1; |
99 this.child2 = adoptChild(child2); | 99 this.child2 = child2; |
100 } | 100 } |
101 | 101 |
102 } | 102 } |
103 | 103 |
104 static class NodeWithThreeChilds extends EmptyNode { | 104 static class NodeWithThreeChilds extends EmptyNode { |
106 @Child Node child1; | 106 @Child Node child1; |
107 @Child Node child2; | 107 @Child Node child2; |
108 @Child Node child3; | 108 @Child Node child3; |
109 | 109 |
110 public NodeWithThreeChilds(Node child1, Node child2, Node child3) { | 110 public NodeWithThreeChilds(Node child1, Node child2, Node child3) { |
111 this.child1 = adoptChild(child1); | 111 this.child1 = child1; |
112 this.child2 = adoptChild(child2); | 112 this.child2 = child2; |
113 this.child3 = adoptChild(child3); | 113 this.child3 = child3; |
114 } | 114 } |
115 | 115 |
116 } | 116 } |
117 | 117 |
118 static class NodeWithArray extends EmptyNode { | 118 static class NodeWithArray extends EmptyNode { |
119 | 119 |
120 @Children private final Node[] childNodes; | 120 @Children private final Node[] childNodes; |
121 | 121 |
122 NodeWithArray(Node[] children) { | 122 NodeWithArray(Node[] children) { |
123 this.childNodes = adoptChildren(children); | 123 this.childNodes = children; |
124 } | 124 } |
125 | 125 |
126 Node[] getChildNodes() { | 126 Node[] getChildNodes() { |
127 return childNodes; | 127 return childNodes; |
128 } | 128 } |
132 | 132 |
133 @Children private final Node[] childNodes1; | 133 @Children private final Node[] childNodes1; |
134 @Children private final Node[] childNodes2; | 134 @Children private final Node[] childNodes2; |
135 | 135 |
136 NodeWithTwoArray(Node[] childs1, Node[] childs2) { | 136 NodeWithTwoArray(Node[] childs1, Node[] childs2) { |
137 this.childNodes1 = adoptChildren(childs1); | 137 this.childNodes1 = childs1; |
138 this.childNodes2 = adoptChildren(childs2); | 138 this.childNodes2 = childs2; |
139 } | 139 } |
140 | 140 |
141 Node[] getChildNodes1() { | 141 Node[] getChildNodes1() { |
142 return childNodes1; | 142 return childNodes1; |
143 } | 143 } |