Class ArrayAccessNode
- java.lang.Object
-
- org.checkerframework.dataflow.cfg.node.Node
-
- org.checkerframework.dataflow.cfg.node.ArrayAccessNode
-
- All Implemented Interfaces:
org.plumelib.util.UniqueId
public class ArrayAccessNode extends Node
A node for an array access:arrayref [ index ]
We allow array accesses without corresponding ASTTree
s.
-
-
Field Summary
Fields Modifier and Type Field Description protected Node
array
The array expression being accessed.protected @Nullable com.sun.source.tree.ExpressionTree
arrayExpression
If this ArrayAccessNode is a node for an array desugared from an enhanced for loop, then thearrayExpression
field is the expression in the for loop, e.g.,arr
infor(Object o: arr
.protected Node
index
The index expresssion used to access the array.protected com.sun.source.tree.ArrayAccessTree
tree
The corresponding ArrayAccessTree.
-
Constructor Summary
Constructors Constructor Description ArrayAccessNode(com.sun.source.tree.ArrayAccessTree t, Node array, Node index)
Create an ArrayAccessNode.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <R,P>
Raccept(NodeVisitor<R,P> visitor, P p)
Accept method of the visitor pattern.boolean
equals(@Nullable java.lang.Object obj)
Node
getArray()
Get the node that represents the array expression being accessed.@Nullable com.sun.source.tree.ExpressionTree
getArrayExpression()
If this ArrayAccessNode is a node for an array desugared from an enhanced for loop, then return the expression in the for loop, e.g.,arr
infor(Object o: arr
.Node
getIndex()
java.util.Collection<Node>
getOperands()
com.sun.source.tree.ArrayAccessTree
getTree()
Returns theTree
in the abstract syntax tree, ornull
if no corresponding tree exists.int
hashCode()
void
setArrayExpression(@Nullable com.sun.source.tree.ExpressionTree arrayExpression)
Set the array expression from a for loop.java.lang.String
toString()
-
Methods inherited from class org.checkerframework.dataflow.cfg.node.Node
getBlock, getInSource, getTransitiveOperands, getType, getUid, isLValue, nodeCollectionToString, setBlock, setInSource, setLValue, toStringDebug
-
-
-
-
Field Detail
-
tree
protected final com.sun.source.tree.ArrayAccessTree tree
The corresponding ArrayAccessTree.
-
array
protected final Node array
The array expression being accessed.
-
index
protected final Node index
The index expresssion used to access the array.
-
arrayExpression
protected @Nullable com.sun.source.tree.ExpressionTree arrayExpression
If this ArrayAccessNode is a node for an array desugared from an enhanced for loop, then thearrayExpression
field is the expression in the for loop, e.g.,arr
infor(Object o: arr
.Is set by
setArrayExpression(com.sun.source.tree.ExpressionTree)
.
-
-
Method Detail
-
getArrayExpression
public @Nullable com.sun.source.tree.ExpressionTree getArrayExpression()
If this ArrayAccessNode is a node for an array desugared from an enhanced for loop, then return the expression in the for loop, e.g.,arr
infor(Object o: arr
. Otherwise, return null.- Returns:
- the array expression, or null if this is not an array desugared from an enhanced for loop
-
setArrayExpression
public void setArrayExpression(@Nullable com.sun.source.tree.ExpressionTree arrayExpression)
Set the array expression from a for loop.- Parameters:
arrayExpression
- array expression- See Also:
getArrayExpression()
-
getArray
public Node getArray()
Get the node that represents the array expression being accessed.- Returns:
- the array expression node
-
getIndex
public Node getIndex()
-
getTree
public com.sun.source.tree.ArrayAccessTree getTree()
Description copied from class:Node
Returns theTree
in the abstract syntax tree, ornull
if no corresponding tree exists. For instance, this is the case for anImplicitThisNode
.
-
accept
public <R,P> R accept(NodeVisitor<R,P> visitor, P p)
Description copied from class:Node
Accept method of the visitor pattern.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
equals
public boolean equals(@Nullable java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
getOperands
@SideEffectFree public java.util.Collection<Node> getOperands()
Description copied from class:Node
- Specified by:
getOperands
in classNode
- Returns:
- a collection containing all of the operand
Node
s of thisNode
-
-