public class SwitchStm extends Compound
This AST element represents the switch-statement.
A switch-statement consists of an expression, zero or more cases and an optional default case.
Example:
switch(e) case c0: b0 case c1: b1 default: b2
IfStm
Modifier and Type | Method and Description |
---|---|
void |
addCase(java.util.List<java.lang.Integer> keys,
Block b)
Add a case to the switch
|
static SwitchStm |
build(IExpression value)
Create a new switch statement.
|
java.util.List<Block> |
getCaseBodies()
Get the case bodies.
|
Block |
getCaseBody(int key)
Get a case body by key.
|
java.util.HashSet<java.lang.Integer> |
getCaseKeys()
Get the list of case keys.
|
Block |
getDefaultBody()
Get the default case block.
|
IExpression |
getSwitchedExpression()
Get the expression being switched on.
|
boolean |
hasDefaultBody()
Determine if the switch block has a default case.
|
void |
setDefaultBody(Block b)
Set the default case body for the switch.
|
void |
setSwitchedExpression(IExpression e)
Set the switch expression.
|
attachTag, getSubElements, isCompound, replaceSubElement, retrieveTag
public static SwitchStm build(IExpression value)
Create a new switch statement.
value
- mandatory valuepublic IExpression getSwitchedExpression()
Get the expression being switched on.
public void setSwitchedExpression(IExpression e)
Set the switch expression.
e
- mandatory expressionpublic java.util.HashSet<java.lang.Integer> getCaseKeys()
Get the list of case keys.
public java.util.List<Block> getCaseBodies()
Get the case bodies.
public Block getCaseBody(int key)
Get a case body by key.
key
- case keypublic boolean hasDefaultBody()
Determine if the switch block has a default case.
public Block getDefaultBody()
Get the default case block.
public void addCase(java.util.List<java.lang.Integer> keys, Block b)
Add a case to the switch
keys
- mandatory list of keys, this list must contain at least one elementb
- the case bodypublic void setDefaultBody(Block b)
Set the default case body for the switch.
b
- optional default case body, null to remove the default case