public boolean visit(Node child) { if (child != null && child.getParent() == null) { newChild.adoptUnadoptedHelper(child); } return true; } });
public boolean visit(Node child) { if (child != null && child.getParent() == null) { newChild.adoptUnadoptedHelper(child); } return true; } });
static int calculateNodeDepth(Node node) { int depth = 0; Node traverseNode = node; while (traverseNode != null) { depth++; traverseNode = traverseNode.getParent(); } return depth; }
final ProbeNode findProbe() { Node parent = this; while (parent != null && !(parent instanceof ProbeNode)) { parent = parent.getParent(); } return (ProbeNode) parent; }
final ProbeNode findProbe() { Node parent = this; while (parent != null && !(parent instanceof ProbeNode)) { parent = parent.getParent(); } return (ProbeNode) parent; }
public static List<Node> collectNodes(Node parent, Node child) { List<Node> nodes = new ArrayList<>(); Node current = child; while (current != null) { nodes.add(current); if (current == parent) { return nodes; } current = current.getParent(); } throw new IllegalArgumentException("Node " + parent + " is not a parent of " + child + "."); }
public static <T> T findParent(Node start, Class<T> clazz) { Node parent = start.getParent(); if (parent == null) { return null; } else if (clazz.isInstance(parent)) { return clazz.cast(parent); } else { return findParent(parent, clazz); } }
/** * Checks if this node can be replaced by another node: tree structure & type. * * @since 0.8 or earlier */ public final boolean isSafelyReplaceableBy(Node newNode) { return NodeUtil.isReplacementSafe(getParent(), this, newNode); }
/** @since 0.8 or earlier */ public static <T> T findParent(Node start, Class<T> clazz) { Node parent = start.getParent(); if (parent == null) { return null; } else if (clazz.isInstance(parent)) { return clazz.cast(parent); } else { return findParent(parent, clazz); } }
@SuppressWarnings("deprecation") private static void invalidateWrapper(Node node) { Node parent = node.getParent(); if (!(parent instanceof com.oracle.truffle.api.instrumentation.InstrumentableFactory.WrapperNode)) { // not yet wrapped return; } invalidateWrapperImpl((com.oracle.truffle.api.instrumentation.InstrumentableFactory.WrapperNode) parent, node); }
/** @since 0.8 or earlier */ public static <T> T findParent(Node start, Class<T> clazz) { Node parent = start.getParent(); if (parent == null) { return null; } else if (clazz.isInstance(parent)) { return clazz.cast(parent); } else { return findParent(parent, clazz); } }
@SuppressWarnings("deprecation") private static void invalidateWrapper(Node node) { Node parent = node.getParent(); if (!(parent instanceof com.oracle.truffle.api.instrumentation.InstrumentableFactory.WrapperNode)) { // not yet wrapped return; } invalidateWrapperImpl((com.oracle.truffle.api.instrumentation.InstrumentableFactory.WrapperNode) parent, node); }
/** * Checks if this node can be replaced by another node: tree structure & type. * * @since 0.8 or earlier */ public final boolean isSafelyReplaceableBy(Node newNode) { return NodeUtil.isReplacementSafe(getParent(), this, newNode); }
private static Node findParentTaggedNode(Node node, Set<Class<? extends Tag>> tags) { if (isTaggedWith(node, tags)) { return node; } Node parent = node.getParent(); if (parent == null) { return null; } return findParentTaggedNode(parent, tags); }
private void adoptUnadoptedHelper() { Iterable<Node> children = this.getChildren(); for (Node child : children) { if (child != null && child.getParent() == null) { this.adoptUnadoptedHelper(child); } } }
private static Node findParentTaggedNode(Node node, Set<Class<? extends Tag>> tags) { if (isTaggedWith(node, tags)) { return node; } Node parent = node.getParent(); if (parent == null) { return null; } return findParentTaggedNode(parent, tags); }
public static boolean verify(Node root) { Iterable<Node> children = root.getChildren(); for (Node child : children) { if (child != null) { if (child.getParent() != root) { throw new AssertionError(toStringWithClass(child) + ": actual parent=" + toStringWithClass(child.getParent()) + " expected parent=" + toStringWithClass(root)); } verify(child); } } return true; }
private static String extractSourceSection(OptimizedDirectCallNode node) { Node cnode = node; while (cnode.getSourceSection() == null && !(cnode instanceof RootNode)) { cnode = cnode.getParent(); if (cnode == null) { return ""; } } return getShortDescription(cnode.getSourceSection()); }