Class CaseNode
- java.lang.Object
-
- org.checkerframework.dataflow.cfg.node.Node
-
- org.checkerframework.dataflow.cfg.node.CaseNode
-
- All Implemented Interfaces:
org.plumelib.util.UniqueId
public class CaseNode extends Node
A node for a case in a switch statement. Although a case has no abstract value, it can imply facts about the abstract values of its operands.case constant:
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List<Node>
caseExprs
The case expressions to match the switch expression against: the operands of (possibly multiple) case labels.protected @Nullable Node
guard
The guard (the expression in thewhen
clause) for this case.protected AssignmentNode
selectorExprAssignment
The Node for the assignment of the switch selector expression to a synthetic local variable.protected com.sun.source.tree.CaseTree
tree
The tree for this node.
-
Constructor Summary
Constructors Constructor Description CaseNode(com.sun.source.tree.CaseTree tree, AssignmentNode selectorExprAssignment, java.util.List<Node> caseExprs, @Nullable Node guard, javax.lang.model.util.Types types)
Create a new CaseNode.
-
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)
java.util.List<Node>
getCaseOperands()
Gets the nodes corresponding to the case expressions.@Nullable Node
getGuard()
Gets the node for the guard (the expression in thewhen
clause).java.util.Collection<Node>
getOperands()
AssignmentNode
getSwitchOperand()
The Node for the assignment of the switch selector expression to a synthetic local variable.com.sun.source.tree.CaseTree
getTree()
Returns theTree
in the abstract syntax tree, ornull
if no corresponding tree exists.int
hashCode()
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.CaseTree tree
The tree for this node.
-
selectorExprAssignment
protected final AssignmentNode selectorExprAssignment
The Node for the assignment of the switch selector expression to a synthetic local variable.
-
caseExprs
protected final java.util.List<Node> caseExprs
The case expressions to match the switch expression against: the operands of (possibly multiple) case labels.
-
-
Constructor Detail
-
CaseNode
public CaseNode(com.sun.source.tree.CaseTree tree, AssignmentNode selectorExprAssignment, java.util.List<Node> caseExprs, @Nullable Node guard, javax.lang.model.util.Types types)
Create a new CaseNode.- Parameters:
tree
- the tree for this nodeselectorExprAssignment
- the Node for the assignment of the switch selector expression to a synthetic local variablecaseExprs
- the case expression(s) to match the switch expression againstguard
- the guard expression or nulltypes
- a factory of utility methods for operating on types
-
-
Method Detail
-
getSwitchOperand
public AssignmentNode getSwitchOperand()
The Node for the assignment of the switch selector expression to a synthetic local variable. This is used to refine the type of the switch selector expression in a case block.- Returns:
- the assignment of the switch selector expression to a synthetic local variable
-
getCaseOperands
public java.util.List<Node> getCaseOperands()
Gets the nodes corresponding to the case expressions. There can be multiple expressions since Java 12.- Returns:
- the nodes corresponding to the (potentially multiple) case expressions
-
getGuard
public @Nullable Node getGuard()
Gets the node for the guard (the expression in thewhen
clause).- Returns:
- the node for the guard
-
getTree
public com.sun.source.tree.CaseTree 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
-
-