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>caseExprsThe case expressions to match the switch expression against: the operands of (possibly multiple) case labels.protected @Nullable NodeguardThe guard (the expression in thewhenclause) for this case.protected AssignmentNodeselectorExprAssignmentThe Node for the assignment of the switch selector expression to a synthetic local variable.protected com.sun.source.tree.CaseTreetreeThe 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.booleanequals(@Nullable java.lang.Object obj)java.util.List<Node>getCaseOperands()Gets the nodes corresponding to the case expressions.@Nullable NodegetGuard()Gets the node for the guard (the expression in thewhenclause).java.util.Collection<Node>getOperands()AssignmentNodegetSwitchOperand()The Node for the assignment of the switch selector expression to a synthetic local variable.com.sun.source.tree.CaseTreegetTree()Returns theTreein the abstract syntax tree, ornullif no corresponding tree exists.inthashCode()java.lang.StringtoString()-
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 thewhenclause).- Returns:
- the node for the guard
-
getTree
public com.sun.source.tree.CaseTree getTree()
Description copied from class:NodeReturns theTreein the abstract syntax tree, ornullif 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:NodeAccept method of the visitor pattern.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
equals
public boolean equals(@Nullable java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
getOperands
@SideEffectFree public java.util.Collection<Node> getOperands()
Description copied from class:Node- Specified by:
getOperandsin classNode- Returns:
- a collection containing all of the operand
Nodes of thisNode
-
-