Package pascal.taie.ir.stmt
Class SwitchStmt
java.lang.Object
pascal.taie.ir.stmt.JumpStmt
pascal.taie.ir.stmt.SwitchStmt
- All Implemented Interfaces:
Serializable
,Stmt
,Indexable
- Direct Known Subclasses:
LookupSwitch
,TableSwitch
Representation of switch statement, e.g.,
switch (v) {
case 1: ...
case 2: ...
default: ...
}
- See Also:
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
getDef()
int
getIndex()
abstract String
int
getTarget
(int i) getUses()
getVar()
void
setDefaultTarget
(Stmt defaultTarget) void
setIndex
(int index) void
setLineNumber
(int lineNumber) void
setTargets
(List<Stmt> targets) toString()
-
Field Details
-
var
The variable holding the condition value of the switch-statement. -
targets
List of jump targets of the switch-statement, one target for each case. -
defaultTarget
The jump target for default case. -
index
protected int index -
lineNumber
protected int lineNumber
-
-
Constructor Details
-
SwitchStmt
-
-
Method Details
-
getVar
- Returns:
- the variable holding the condition value of the switch-statement.
-
getTarget
- Returns:
- the i-th jump target (for i-th case) of the switch-statement. The indexes start from 0. Target for default case is excluded.
-
setTargets
-
getCaseValues
- Returns:
- all case values of the switch statement. For example,
for switch statement
switch (x) { case 1: a = 1; break; case 3: a = 3; break; default: a = 0; break; }
This API would return [1, 3].
-
getCaseTargets
- Returns:
- pairs of case value and the corresponding jump target.
Default case is excluded. For example, for switch statement
switch (x) { case 1: a = 1; break; case 3: a = 3; break; default: a = 0; break; }
This API would return [(1, a = 1;), (3, a = 3;)].
-
getDefaultTarget
- Returns:
- the jump target for default case.
-
setDefaultTarget
-
getUses
-
canFallThrough
public boolean canFallThrough()- Specified by:
canFallThrough
in interfaceStmt
- Returns:
- true if execution after this statement could continue at the following statement, otherwise false.
-
getTargets
- Specified by:
getTargets
in classJumpStmt
- Returns:
- possible jump targets of this statement.
-
toString
-
getInsnString
-
getIndex
public int getIndex() -
setIndex
public void setIndex(int index) -
getLineNumber
public int getLineNumber()- Specified by:
getLineNumber
in interfaceStmt
- Returns:
- the line number of this Stmt in the original source file. If the line number is unavailable, return -1.
-
setLineNumber
public void setLineNumber(int lineNumber) - Specified by:
setLineNumber
in interfaceStmt
-
getDef
-