Class Node
- java.lang.Object
-
- org.checkerframework.dataflow.cfg.node.Node
-
- All Implemented Interfaces:
org.plumelib.util.UniqueId
- Direct Known Subclasses:
ArrayAccessNode,ArrayCreationNode,ArrayTypeNode,AssertionErrorNode,AssignmentNode,BinaryOperationNode,CaseNode,ClassDeclarationNode,ClassNameNode,DeconstructorPatternNode,ExpressionStatementNode,FieldAccessNode,FunctionalInterfaceNode,InstanceOfNode,LambdaResultExpressionNode,LocalVariableNode,MarkerNode,MethodAccessNode,MethodInvocationNode,NarrowingConversionNode,NullChkNode,ObjectCreationNode,PackageNameNode,ParameterizedTypeNode,PrimitiveTypeNode,ReturnNode,StringConversionNode,SuperNode,SwitchExpressionNode,SynchronizedNode,TernaryExpressionNode,ThisNode,ThrowNode,TypeCastNode,UnaryOperationNode,ValueLiteralNode,VariableDeclarationNode,WideningConversionNode
public abstract class Node extends java.lang.Object implements org.plumelib.util.UniqueIdA node in the abstract representation used for Java code inside a basic block.The following invariants hold:
block == null || block instanceof RegularBlock || block instanceof ExceptionBlock block != null ⇔ block.getNodes().contains(this)
type != null tree != null ⇒ node.getType() == InternalUtils.typeOf(node.getTree())
Note that twoNodes can be.equalsbut represent different CFG nodes. Take care to use reference equality, maps that handle identityIdentityHashMap, and sets likeIdentityArraySet.
-
-
Field Summary
Fields Modifier and Type Field Description protected @Nullable BlockblockThe basic block this node belongs to.protected booleaninSourceDoes this node represent a tree that appears in the source code (true) or one that the CFG builder added while desugaring (false).protected booleanlvalueIs this node an l-value?protected javax.lang.model.type.TypeMirrortypeThe type of this node.
-
Constructor Summary
Constructors Modifier Constructor Description protectedNode(javax.lang.model.type.TypeMirror type)Creates a new Node.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract <R,P>
Raccept(NodeVisitor<R,P> visitor, P p)Accept method of the visitor pattern.@Nullable BlockgetBlock()Returns the basic block this node belongs to (ornullif it represents the parameter of a method).booleangetInSource()Return whether this node represents a tree that appears in the source code (true) or one that the CFG or builder added while desugaring (false).abstract java.util.Collection<Node>getOperands()java.util.Collection<Node>getTransitiveOperands()abstract @Nullable com.sun.source.tree.TreegetTree()Returns theTreein the abstract syntax tree, ornullif no corresponding tree exists.javax.lang.model.type.TypeMirrorgetType()Returns aTypeMirrorrepresenting the type of aNode.longgetUid()booleanisLValue()Is the node an lvalue or not?static java.lang.StringnodeCollectionToString(java.util.Collection<? extends Node> nodes)Returns a verbose string representation of a collection of nodes, useful for debugging..voidsetBlock(Block b)Set the basic block this node belongs to.voidsetInSource(boolean inSrc)voidsetLValue()Make this node an l-value.java.lang.StringtoStringDebug()Returns a verbose string representation of this, useful for debugging.
-
-
-
Field Detail
-
block
protected @Nullable Block block
The basic block this node belongs to. If null, this object represents a method formal parameter.Is set by
setBlock(org.checkerframework.dataflow.cfg.block.Block).
-
lvalue
protected boolean lvalue
Is this node an l-value?Is set by
setLValue().
-
inSource
protected boolean inSource
Does this node represent a tree that appears in the source code (true) or one that the CFG builder added while desugaring (false).Is set by
setInSource(boolean).
-
type
protected final javax.lang.model.type.TypeMirror type
The type of this node. ForNodes withTrees, this type is the type of theTree. Otherwise, it is the type is set by theCFGBuilder.
-
-
Method Detail
-
getUid
@Pure public long getUid(@UnknownInitialization Node this)
- Specified by:
getUidin interfaceorg.plumelib.util.UniqueId
-
getBlock
@Pure public @Nullable Block getBlock()
Returns the basic block this node belongs to (ornullif it represents the parameter of a method).- Returns:
- the basic block this node belongs to (or
nullif it represents the parameter of a method)
-
setBlock
public void setBlock(Block b)
Set the basic block this node belongs to.
-
getTree
@Pure public abstract @Nullable com.sun.source.tree.Tree getTree()
Returns theTreein the abstract syntax tree, ornullif no corresponding tree exists. For instance, this is the case for anImplicitThisNode.- Returns:
- the corresponding
Treeornull
-
getType
@Pure public javax.lang.model.type.TypeMirror getType()
Returns aTypeMirrorrepresenting the type of aNode. ANodewill always have a type even when it has noTree.- Returns:
- a
TypeMirrorrepresenting the type of thisNode
-
accept
public abstract <R,P> R accept(NodeVisitor<R,P> visitor, P p)
Accept method of the visitor pattern.- Type Parameters:
R- result type of the operationP- parameter type- Parameters:
visitor- the visitor to be applied to this nodep- the parameter for this operation
-
isLValue
@Pure public boolean isLValue()
Is the node an lvalue or not?
-
setLValue
public void setLValue()
Make this node an l-value.
-
getInSource
@Pure public boolean getInSource()
Return whether this node represents a tree that appears in the source code (true) or one that the CFG or builder added while desugaring (false).- Returns:
- whether this node represents a tree that appears in the source code
-
setInSource
public void setInSource(boolean inSrc)
-
getOperands
@SideEffectFree public abstract java.util.Collection<Node> getOperands()
-
toStringDebug
@Pure public java.lang.String toStringDebug()
Returns a verbose string representation of this, useful for debugging.- Returns:
- a printed representation of this
-
nodeCollectionToString
@Pure public static java.lang.String nodeCollectionToString(java.util.Collection<? extends Node> nodes)
Returns a verbose string representation of a collection of nodes, useful for debugging..- Parameters:
nodes- a collection of nodes to format- Returns:
- a printed representation of the given collection
-
-