|
||||||||||
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.ChooseStatement
public class ChooseStatement
The choose statement AST.
Field Summary | |
---|---|
protected Statement |
elseStmt
Holds the optional else's statement. |
protected ArrayList<Exp> |
exps
Holds the choose conditions. |
protected ArrayList<Statement> |
stmts
Holds the choose statements. |
Fields inherited from class edu.ksu.cis.projects.bogor.ast.Node |
---|
ILLEGAL_LOCAL_ID_CHAR |
Constructor Summary | |
---|---|
ChooseStatement(List<? extends Exp> exps,
List<? extends Statement> stmts,
Statement elseStmt)
Default constructor. |
Method Summary | |
---|---|
ChooseStatement |
clone()
Clones this object (deep clone); including location info. |
void |
dispose()
Disposes exp and stmt. |
Exp |
getChooseGuard(int index)
Gets a choose guard at a specified index. |
Statement |
getChooseStatement(int index)
Gets an elseif statement at a specified index. |
Statement |
getElse()
Gets the else statement. |
int |
getWhenCount()
Gets the number of whens. |
void |
setElse(Statement stmt)
Sets the else statement. |
void |
setWhens(List<? extends Exp> exps,
List<? extends Statement> stmts)
Sets the choose guards and statements. |
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 ArrayList<Exp> exps
protected ArrayList<Statement> stmts
protected Statement elseStmt
Constructor Detail |
---|
public ChooseStatement(List<? extends Exp> exps, List<? extends Statement> stmts, Statement elseStmt)
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 ChooseStatement clone()
clone
in class Statement
public void dispose()
dispose
in interface Disposable
dispose
in class Statement
public void setWhens(List<? extends Exp> exps, List<? extends Statement> stmts)
exps
- The guards of the choose. Must be non-null. Each element must
be non-null. There must be at least one element.stmts
- The statements of the choose. Must be non-null. Each element
must be non-null. Should be the same size as exps.public Exp getChooseGuard(int index)
index
- The index of the the choose's guard. Must be between 0 and
getWhenCount() - 1, inclusive.
public Statement getChooseStatement(int index)
index
- The index of the the elseif's statement. Must be between 0 and
getWhenCount() - 1, inclusive.
public int getWhenCount()
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.
"choose\n" + " when exp1 do\n" + " stmt1\n" + " when exp2 do\n" + " stmt2\n" + " ..." + " when 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 |