Package com.oracle.truffle.api.nodes
Class NodeUtil
- java.lang.Object
-
- com.oracle.truffle.api.nodes.NodeUtil
-
public final class NodeUtil extends java.lang.ObjectUtility class that manages the special access methods for node instances.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceNodeUtil.FieldOffsetProviderInterface that allows the customization of field offsets used forUnsafefield accesses.static classNodeUtil.NodeClassInformation about aNodeclass.static interfaceNodeUtil.NodeCountFilterstatic classNodeUtil.NodeFieldInformation about a field in aNodeclass.static classNodeUtil.NodeFieldKind
-
Constructor Summary
Constructors Constructor Description NodeUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T extends Node>
TcloneNode(T orig)static java.util.List<Node>collectNodes(Node parent, Node child)static <T> T[]concat(T[] first, T[] second)static intcountNodes(Node root)static intcountNodes(Node root, NodeUtil.NodeCountFilter filter)static <T> java.util.List<T>findAllNodeInstances(Node root, java.lang.Class<T> clazz)static <T> java.util.List<T>findAllParents(Node start, java.lang.Class<T> clazz)static <T extends java.lang.annotation.Annotation>
TfindAnnotation(java.lang.Class<?> clazz, java.lang.Class<T> annotationClass)find annotation in class/interface hierarchy.static <T> TfindFirstNodeInstance(Node root, java.lang.Class<T> clazz)static java.util.List<Node>findNodeChildren(Node node)static <T> java.util.List<T>findNodeInstancesShallow(Node root, java.lang.Class<T> clazz)LikefindAllNodeInstances(Node, Class)but do not visit children of found nodes.static <T> TfindParent(Node start, java.lang.Class<T> clazz)static NodegetNthParent(Node node, int n)Get the nth parent of a node, where the 0th parent is the node itself.static java.util.Iterator<Node>makeRecursiveIterator(Node node)static voidprintCompactTree(java.io.OutputStream out, Node node)static java.lang.StringprintCompactTreeToString(Node node)static java.lang.StringprintSourceAttributionTree(Node node)static voidprintSourceAttributionTree(java.io.OutputStream out, Node node)static java.lang.StringprintSyntaxTags(java.lang.Object node)Returns a string listing the syntax tags, if any, associated with a node: "[STATEMENT, ASSIGNMENT]" if tags have been applied; "[]" if the node supports tags, but none are present; and "" if the node does not support tags.static voidprintTree(java.io.OutputStream out, Node node)Prints a human readable form of aNodeAST to the givenPrintStream.static voidprintTree(java.io.PrintWriter p, Node node)static java.lang.StringprintTreeToString(Node node)static booleanreplaceChild(Node parent, Node oldChild, Node newChild)static booleanverify(Node root)
-
-
-
Method Detail
-
cloneNode
public static <T extends Node> T cloneNode(T orig)
-
concat
public static <T> T[] concat(T[] first, T[] second)
-
getNthParent
public static Node getNthParent(Node node, int n)
Get the nth parent of a node, where the 0th parent is the node itself. Returns null if there are less than n ancestors.
-
findAnnotation
public static <T extends java.lang.annotation.Annotation> T findAnnotation(java.lang.Class<?> clazz, java.lang.Class<T> annotationClass)find annotation in class/interface hierarchy.
-
findParent
public static <T> T findParent(Node start, java.lang.Class<T> clazz)
-
findAllParents
public static <T> java.util.List<T> findAllParents(Node start, java.lang.Class<T> clazz)
-
findFirstNodeInstance
public static <T> T findFirstNodeInstance(Node root, java.lang.Class<T> clazz)
-
findAllNodeInstances
public static <T> java.util.List<T> findAllNodeInstances(Node root, java.lang.Class<T> clazz)
-
findNodeInstancesShallow
public static <T> java.util.List<T> findNodeInstancesShallow(Node root, java.lang.Class<T> clazz)
LikefindAllNodeInstances(Node, Class)but do not visit children of found nodes.
-
countNodes
public static int countNodes(Node root)
-
countNodes
public static int countNodes(Node root, NodeUtil.NodeCountFilter filter)
-
printCompactTreeToString
public static java.lang.String printCompactTreeToString(Node node)
-
printCompactTree
public static void printCompactTree(java.io.OutputStream out, Node node)
-
printSourceAttributionTree
public static java.lang.String printSourceAttributionTree(Node node)
-
printSourceAttributionTree
public static void printSourceAttributionTree(java.io.OutputStream out, Node node)
-
printSyntaxTags
public static java.lang.String printSyntaxTags(java.lang.Object node)
Returns a string listing the syntax tags, if any, associated with a node:- "[STATEMENT, ASSIGNMENT]" if tags have been applied;
- "[]" if the node supports tags, but none are present; and
- "" if the node does not support tags.
-
printTree
public static void printTree(java.io.OutputStream out, Node node)Prints a human readable form of aNodeAST to the givenPrintStream. This print method does not check for cycles in the node structure.- Parameters:
out- the stream to print to.node- the root node to write
-
printTreeToString
public static java.lang.String printTreeToString(Node node)
-
printTree
public static void printTree(java.io.PrintWriter p, Node node)
-
verify
public static boolean verify(Node root)
-
-