Package com.oracle.truffle.api.nodes
Class NodeUtil
- java.lang.Object
-
- com.oracle.truffle.api.nodes.NodeUtil
-
public final class NodeUtil extends java.lang.Object
Utility class that manages the special access methods for node instances.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
NodeUtil.FieldOffsetProvider
Interface that allows the customization of field offsets used forUnsafe
field accesses.static class
NodeUtil.NodeClass
Information about aNode
class.static interface
NodeUtil.NodeCountFilter
static class
NodeUtil.NodeField
Information about a field in aNode
class.static class
NodeUtil.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 int
countNodes(Node root)
static int
countNodes(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> T
findFirstNodeInstance(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> T
findParent(Node start, java.lang.Class<T> clazz)
static Node
getNthParent(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 void
printCompactTree(java.io.OutputStream out, Node node)
static java.lang.String
printCompactTreeToString(Node node)
static java.lang.String
printSourceAttributionTree(Node node)
static void
printSourceAttributionTree(java.io.OutputStream out, Node node)
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.static void
printTree(java.io.OutputStream out, Node node)
Prints a human readable form of aNode
AST to the givenPrintStream
.static void
printTree(java.io.PrintWriter p, Node node)
static java.lang.String
printTreeToString(Node node)
static boolean
replaceChild(Node parent, Node oldChild, Node newChild)
static boolean
verify(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 aNode
AST 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)
-
-