/** * Method that updates the link to the parent in the specified new child node to this node. * * @param newChild the new child whose parent should be updated * @return the new child */ protected final <T extends Node> T insert(final T newChild) { CompilerDirectives.transferToInterpreterAndInvalidate(); assert newChild != null; adoptHelper(newChild); return newChild; }
private void adoptHelper(final Node newChild) { assert newChild != null; if (newChild == this) { throw new IllegalStateException("The parent of a node can never be the node itself."); } newChild.parent = this; if (TruffleOptions.TraceASTJSON) { JSONHelper.dumpNewChild(this, newChild); } newChild.adoptHelper(); }
public final void adoptChildren() { CompilerDirectives.transferToInterpreterAndInvalidate(); adoptHelper(); }
/** * Method that updates the link to the parent in the array of specified new child nodes to this * node. * * @param newChildren the array of new children whose parent should be updated * @return the array of new children */ protected final <T extends Node> T[] insert(final T[] newChildren) { CompilerDirectives.transferToInterpreterAndInvalidate(); assert newChildren != null; for (Node newChild : newChildren) { adoptHelper(newChild); } return newChildren; }
/** * Inserts an new node into an AST that was already {@link #adoptChildren() adopted} by a * {@link #getParent() parent}. The new child needs to be assigned to its {@link Child child} * field after insert was called. * * @param newChild the new child whose parent should be updated * @return the new child * @since 0.8 or earlier */ protected final <T extends Node> T insert(final T newChild) { CompilerDirectives.transferToInterpreterAndInvalidate(); if (newChild != null) { adoptHelper(newChild); } return newChild; }
/** * Inserts an new node into an AST that was already {@link #adoptChildren() adopted} by a * {@link #getParent() parent}. The new child needs to be assigned to its {@link Child child} * field after insert was called. * * @param newChild the new child whose parent should be updated * @return the new child * @since 0.8 or earlier */ protected final <T extends Node> T insert(final T newChild) { CompilerDirectives.transferToInterpreterAndInvalidate(); if (newChild != null) { adoptHelper(newChild); } return newChild; }
/** * Inserts new node children into an AST that was already {@link #adoptChildren() adopted} by a * {@link #getParent() parent}. The new children need to be assigned to its {@link Children * children} field after insert was called. * * @param newChildren the array of new children whose parent should be updated * @return the array of new children * @since 0.8 or earlier */ protected final <T extends Node> T[] insert(final T[] newChildren) { CompilerDirectives.transferToInterpreterAndInvalidate(); if (newChildren != null) { for (Node newChild : newChildren) { adoptHelper(newChild); } } return newChildren; }
/** * Inserts new node children into an AST that was already {@link #adoptChildren() adopted} by a * {@link #getParent() parent}. The new children need to be assigned to its {@link Children * children} field after insert was called. * * @param newChildren the array of new children whose parent should be updated * @return the array of new children * @since 0.8 or earlier */ protected final <T extends Node> T[] insert(final T[] newChildren) { CompilerDirectives.transferToInterpreterAndInvalidate(); if (newChildren != null) { for (Node newChild : newChildren) { adoptHelper(newChild); } } return newChildren; }
private void adoptHelper() { Iterable<Node> children = this.getChildren(); for (Node child : children) { if (child != null && child.getParent() != this) { this.adoptHelper(child); } } }
Node node = (Node) child; if (node.getParent() != currentNode) { currentNode.adoptHelper(node); Node node = (Node) child; if (node.getParent() != currentNode) { currentNode.adoptHelper(node);
if (nodeClass.getFieldObject(nodeField, parent) == oldChild) { if (adopt) { parent.adoptHelper(newChild); if (array[i] == oldChild) { if (adopt) { parent.adoptHelper(newChild);
if (nodeClass.getFieldObject(nodeField, parent) == oldChild) { if (adopt) { parent.adoptHelper(newChild); if (array[i] == oldChild) { if (adopt) { parent.adoptHelper(newChild);
Node node = (Node) child; if (node.getParent() != currentNode) { currentNode.adoptHelper(node); Node node = (Node) child; if (node.getParent() != currentNode) { currentNode.adoptHelper(node);
final void replaceHelper(Node newNode, CharSequence reason) { CompilerAsserts.neverPartOfCompilation(); assert inAtomicBlock(); if (this.getParent() == null) { throw new IllegalStateException("This node cannot be replaced, because it does not yet have a parent."); } if (sourceSection != null && newNode.getSourceSection() == null) { // Pass on the source section to the new node. newNode.assignSourceSection(sourceSection); } // (aw) need to set parent *before* replace, so that (unsynchronized) getRootNode() // will always find the root node newNode.parent = this.parent; if (NodeUtil.replaceChild(this.parent, this, newNode)) { this.parent.adoptHelper(newNode); } else { this.parent.adoptUnadoptedHelper(newNode); } reportReplace(this, newNode, reason); onReplace(newNode, reason); }