public class IfStm extends Compound
This AST element represents the if-statement.
An if-statement consists of one or more branches (if, else-if) followed by an optional default branch (else) block.
Example:
if(p) b else if(p1) b1 else b2
SwitchStm
Modifier and Type | Method and Description |
---|---|
static IfStm |
build(Predicate p,
Block b)
Create a new single-branch if-statement:
if(p) b |
Block |
getBranchBody(int index)
Get a branch (if, else-if) body.
|
Predicate |
getBranchPredicate(int index)
Get a branch (if, else-if) predicate.
|
Block |
getDefaultBlock()
Get the default branch (else) body, if any.
|
void |
insertBranch(int index,
Predicate p,
Block b)
Insert a branch.
|
void |
removeBranch(int index)
Remove a branch.
|
void |
setBranchBody(int index,
Block b)
Set a branch (if, else-if) body.
|
void |
setBranchPredicate(int index,
Predicate p)
Set a branch (if, else-if) predicate.
|
int |
size()
Get the number of branches, including the default (else) branch, if any.
|
attachTag, getSubElements, isCompound, replaceSubElement, retrieveTag
public static IfStm build(Predicate p, Block b)
Create a new single-branch if-statement: if(p) b
p
- mandatory predicateb
- mandatory bodypublic int size()
Get the number of branches, including the default (else) branch, if any.
public Predicate getBranchPredicate(int index)
Get a branch (if, else-if) predicate.
index
- 0-based branch indexpublic Block getBranchBody(int index)
Get a branch (if, else-if) body.
index
- 0-based branch indexpublic Block getDefaultBlock()
Get the default branch (else) body, if any.
public void setBranchPredicate(int index, Predicate p)
Set a branch (if, else-if) predicate.
index
- 0-based branch indexp
- mandatory predicatepublic void setBranchBody(int index, Block b)
Set a branch (if, else-if) body.
index
- 0-based branch indexb
- mandatory bodypublic void insertBranch(int index, Predicate p, Block b)
Insert a branch.
index
- 0-based branch indexp
- mandatory predicateb
- mandatory bodypublic void removeBranch(int index)
Remove a branch.
index
- 0-based branch index