Mercurial > hg > graal-jvmci-8
comparison graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/Node.java @ 19975:cd59085cf0d8
Truffle: remove Node#onAdopt() hook
author | Andreas Woess <andreas.woess@oracle.com> |
---|---|
date | Fri, 20 Mar 2015 17:08:43 +0100 |
parents | 1d6a7ea5de59 |
children | f792b4270cb1 |
comparison
equal
deleted
inserted
replaced
19974:a0971187a38a | 19975:cd59085cf0d8 |
---|---|
174 private void adoptHelper(final Node newChild) { | 174 private void adoptHelper(final Node newChild) { |
175 assert newChild != null; | 175 assert newChild != null; |
176 if (newChild == this) { | 176 if (newChild == this) { |
177 throw new IllegalStateException("The parent of a node can never be the node itself."); | 177 throw new IllegalStateException("The parent of a node can never be the node itself."); |
178 } | 178 } |
179 boolean isInserted = newChild.parent == null; | |
180 newChild.parent = this; | 179 newChild.parent = this; |
181 if (TruffleOptions.TraceASTJSON) { | 180 if (TruffleOptions.TraceASTJSON) { |
182 JSONHelper.dumpNewChild(this, newChild); | 181 JSONHelper.dumpNewChild(this, newChild); |
183 } | 182 } |
184 newChild.adoptHelper(); | 183 newChild.adoptHelper(); |
185 if (isInserted) { | |
186 newChild.onAdopt(); | |
187 } | |
188 } | 184 } |
189 | 185 |
190 private void adoptHelper() { | 186 private void adoptHelper() { |
191 Iterable<Node> children = this.getChildren(); | 187 Iterable<Node> children = this.getChildren(); |
192 for (Node child : children) { | 188 for (Node child : children) { |
199 private void adoptUnadoptedHelper(final Node newChild) { | 195 private void adoptUnadoptedHelper(final Node newChild) { |
200 assert newChild != null; | 196 assert newChild != null; |
201 if (newChild == this) { | 197 if (newChild == this) { |
202 throw new IllegalStateException("The parent of a node can never be the node itself."); | 198 throw new IllegalStateException("The parent of a node can never be the node itself."); |
203 } | 199 } |
204 boolean isInserted = newChild.parent == null; | |
205 newChild.parent = this; | 200 newChild.parent = this; |
206 newChild.adoptUnadoptedHelper(); | 201 newChild.adoptUnadoptedHelper(); |
207 if (isInserted) { | |
208 newChild.onAdopt(); | |
209 } | |
210 } | 202 } |
211 | 203 |
212 private void adoptUnadoptedHelper() { | 204 private void adoptUnadoptedHelper() { |
213 Iterable<Node> children = this.getChildren(); | 205 Iterable<Node> children = this.getChildren(); |
214 for (Node child : children) { | 206 for (Node child : children) { |
327 protected void onReplace(Node newNode, CharSequence reason) { | 319 protected void onReplace(Node newNode, CharSequence reason) { |
328 // empty default | 320 // empty default |
329 } | 321 } |
330 | 322 |
331 /** | 323 /** |
332 * Subclasses of {@link Node} can implement this method to execute extra functionality when a | |
333 * node is effectively inserted into the AST. The {@code onAdopt} callback is called after the | |
334 * node has been effectively inserted, and it is guaranteed to be called only once for any given | |
335 * node. | |
336 */ | |
337 protected void onAdopt() { | |
338 // empty default | |
339 } | |
340 | |
341 /** | |
342 * Invokes the {@link NodeVisitor#visit(Node)} method for this node and recursively also for all | 324 * Invokes the {@link NodeVisitor#visit(Node)} method for this node and recursively also for all |
343 * child nodes. | 325 * child nodes. |
344 * | 326 * |
345 * @param nodeVisitor the visitor | 327 * @param nodeVisitor the visitor |
346 */ | 328 */ |