public class ForStm extends Compound
This AST element represents a for loop statement.
A for loop is a kind of pre-tested loop, that consists of an initializer statement, a test predicate, a post-iteration statement, and a body.
for(initializer; predicate; poststm) body
WhileStm
,
DoWhileStm
Modifier and Type | Method and Description |
---|---|
static ForStm |
build(Statement initializer,
Predicate p,
Statement poststm,
Block b)
Create a for loop.
|
Block |
getBody()
Get the loop body.
|
Statement |
getInitializer()
Get the initializer statement.
|
Statement |
getPostStatement()
Get the post-iteration statement.
|
Predicate |
getPredicate()
Get the loop predicate.
|
void |
setBody(Block b)
Set the loop post-iteration statement.
|
void |
setInitializer(Statement initializer)
Set the loop initializer statement.
|
void |
setPostStatement(Statement poststm)
Set the loop post-iteration statement.
|
void |
setPredicate(Predicate p)
Set the loop predicate.
|
attachTag, getSubElements, isCompound, replaceSubElement, retrieveTag
public static ForStm build(Statement initializer, Predicate p, Statement poststm, Block b)
Create a for loop.
initializer
- optional initializer statementp
- optional predicatepoststm
- optional post-iteration statementb
- mandatory loop bodypublic Statement getInitializer()
Get the initializer statement.
public Predicate getPredicate()
Get the loop predicate.
public Statement getPostStatement()
Get the post-iteration statement.
public Block getBody()
Get the loop body.
public void setInitializer(Statement initializer)
Set the loop initializer statement.
initializer
- optional initializerpublic void setPredicate(Predicate p)
Set the loop predicate.
p
- optional loop predicatepublic void setPostStatement(Statement poststm)
Set the loop post-iteration statement.
poststm
- optional post-iteration statementpublic void setBody(Block b)
Set the loop post-iteration statement.
b
- mandatory loop body