|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object edu.ksu.cis.projects.bogor.ast.Node edu.ksu.cis.projects.bogor.ast.Statement edu.ksu.cis.projects.bogor.ast.IfStatement
public class IfStatement
The if statement AST.
Field Summary | |
---|---|
protected Statement |
elseStmt
Holds the optional else's statement. |
protected Exp |
exp
Holds the condition. |
protected ArrayList<Exp> |
exps
Holds the optional elseif's conditions. |
protected Statement |
stmt
Holds the statement. |
protected ArrayList<Statement> |
stmts
Holds the optional elseif's statements. |
Fields inherited from class edu.ksu.cis.projects.bogor.ast.Node |
---|
ILLEGAL_LOCAL_ID_CHAR |
Constructor Summary | |
---|---|
IfStatement(Exp exp,
Statement stmt,
List<? extends Exp> exps,
List<? extends Statement> stmts,
Statement elseStmt)
Default constructor. |
Method Summary | |
---|---|
IfStatement |
clone()
Clones this object (deep clone); including location info. |
void |
dispose()
Disposes exp and stmt. |
Statement |
getElse()
Gets the else statement. |
Exp |
getElseIfCondition(int index)
Gets an elseif condition at a specified index. |
int |
getElseIfCount()
Gets the number of elseifs. |
Statement |
getElseIfStatement(int index)
Gets an elseif statement at a specified index. |
Exp |
getExp()
Gets the condition. |
Statement |
getStatement()
Gets the statement. |
void |
setElse(Statement stmt)
Sets the else statement. |
void |
setElseIfs(List<? extends Exp> exps,
List<? extends Statement> stmts)
Sets the elseifs. |
void |
setExp(Exp exp)
Sets the condition. |
void |
setStatement(Statement stmt)
Sets the statement. |
protected String |
toString(String indent)
Returns the string representation of this object. |
void |
visit(ASTVisitor visitor)
|
Methods inherited from class edu.ksu.cis.projects.bogor.ast.Statement |
---|
getParent, setParent, toString |
Methods inherited from class edu.ksu.cis.projects.bogor.ast.Node |
---|
getLocationInfo, getProperty, putProperty, setLocationInfo |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected Exp exp
protected Statement stmt
protected ArrayList<Exp> exps
protected ArrayList<Statement> stmts
protected Statement elseStmt
Constructor Detail |
---|
public IfStatement(Exp exp, Statement stmt, List<? extends Exp> exps, List<? extends Statement> stmts, Statement elseStmt)
exp
- The condition. Must be non-null.stmt
- The statement. Must be non-null.exps
- The elseif conditions. Must be either null or at least one
element.stmts
- The elseif statements. Must agree with exps.elseStmt
- The else statement.Method Detail |
---|
public IfStatement clone()
clone
in class Statement
public void dispose()
dispose
in interface Disposable
dispose
in class Statement
public Exp getExp()
public void setExp(Exp exp)
exp
- The condition. Must be non-null.public Statement getStatement()
public void setStatement(Statement stmt)
stmt
- The statement. Must be non-null.public void setElseIfs(List<? extends Exp> exps, List<? extends Statement> stmts)
exps
- The conditions of the elseifs. Must be non-null. Each element
must be non-null. There must be at least one element.stmts
- The statements of the elseifs. Must be non-null. Each element
must be non-null. Should be the same size as exps.public Exp getElseIfCondition(int index)
index
- The index of the the elseif's condition. Must be between 0 and
getElseIfCount() - 1, inclusive.
public Statement getElseIfStatement(int index)
index
- The index of the the elseif's statement. Must be between 0 and
getElseIfCount() - 1, inclusive.
public int getElseIfCount()
public void setElse(Statement stmt)
stmt
- The else statement. Must be non-null.public Statement getElse()
public void visit(ASTVisitor visitor)
visit
in class Node
protected String toString(String indent)
toString
in class Statement
indent
- The indentation for this statement.
"if exp1 do\n" + " stmt1\n" + "elseif exp2 do\n" + " stmt2\n" + "..." + "elseif expN do\n" + " stmtN\n" + "[else do\n" + " stmt\n]" + "end\n".
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |