public abstract class Node extends Object implements org.plumelib.util.UniqueId
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 two
Node
s can be .equals
but represent different CFG nodes. Take care
to use reference equality, maps that handle identity IdentityHashMap
, and sets like
IdentityMostlySingleton
.IdentityMostlySingleton
Modifier and Type | Field and Description |
---|---|
protected @Nullable Block |
block
The basic block this node belongs to.
|
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).
|
protected boolean |
lvalue
Is this node an l-value?
|
protected TypeMirror |
type
The type of this node.
|
Modifier | Constructor and Description |
---|---|
protected |
Node(TypeMirror type)
Creates a new Node.
|
Modifier and Type | Method and Description |
---|---|
abstract <R,P> R |
accept(NodeVisitor<R,P> visitor,
P p)
Accept method of the visitor pattern.
|
@Nullable Block |
getBlock()
Returns the basic block this node belongs to (or
null if it represents the parameter of
a method). |
boolean |
getInSource() |
abstract Collection<Node> |
getOperands()
|
Collection<Node> |
getTransitiveOperands()
|
abstract @Nullable Tree |
getTree()
Returns the
Tree in the abstract syntax tree, or null if no corresponding tree
exists. |
TypeMirror |
getType()
Returns a
TypeMirror representing the type of a Node . |
long |
getUid()
Returns the unique ID of this object.
|
boolean |
isLValue()
Is the node an lvalue or not?
|
static String |
nodeCollectionToString(Collection<? extends Node> nodes)
Returns a verbose string representation of a collection of nodes, useful for debugging..
|
void |
setBlock(Block b)
Set the basic block this node belongs to.
|
void |
setInSource(boolean inSrc) |
void |
setLValue()
Make this node an l-value.
|
String |
toStringDebug()
Returns a verbose string representation of this, useful for debugging.
|
protected @Nullable Block block
protected boolean lvalue
protected boolean inSource
protected final TypeMirror type
Node
s with Tree
s, this type is the type of the
Tree
. Otherwise, it is the type is set by the CFGBuilder
.protected Node(TypeMirror type)
type
- the type of the nodepublic long getUid(@UnknownInitialization Node this)
getUid
in interface org.plumelib.util.UniqueId
public @Nullable Block getBlock()
null
if it represents the parameter of
a method).null
if it represents the parameter of
a method)public void setBlock(Block b)
@Pure public abstract @Nullable Tree getTree()
Tree
in the abstract syntax tree, or null
if no corresponding tree
exists. For instance, this is the case for an ImplicitThisNode
.Tree
or null
public TypeMirror getType()
TypeMirror
representing the type of a Node
. A Node
will
always have a type even when it has no Tree
.TypeMirror
representing the type of this Node
public abstract <R,P> R accept(NodeVisitor<R,P> visitor, P p)
R
- result type of the operationP
- parameter typevisitor
- the visitor to be applied to this nodep
- the parameter for this operation@Pure public boolean isLValue()
public void setLValue()
public boolean getInSource()
public void setInSource(boolean inSrc)
public abstract Collection<Node> getOperands()
public Collection<Node> getTransitiveOperands()
public String toStringDebug()
public static String nodeCollectionToString(Collection<? extends Node> nodes)
nodes
- a collection of nodes to format