public class WhileLoop extends Statement implements Loop, SymbolTable
| Constructor and Description |
|---|
WhileLoop(Expression condition,
Statement body)
Constructs a new while loop with the given condition expression
condition and the loop body body.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addDeclaration(Declaration decl)
Add a declaration to the end of the set of declarations
and place the declared symbols in the symbol table.
|
void |
addDeclarationAfter(Declaration ref,
Declaration decl)
Add a declaration after the reference declaration.
|
void |
addDeclarationBefore(Declaration ref,
Declaration decl)
Add a declaration before the reference declaration.
|
WhileLoop |
clone()
Returns a clone of this while loop.
|
boolean |
containsDeclaration(Declaration decl)
Checks if the symbol table contains the specified declaration.
|
boolean |
containsSymbol(Symbol symbol)
Checks if the symbol table contains the specified symbol.
|
static void |
defaultPrint(WhileLoop l,
java.io.PrintWriter o)
Prints a loop to a stream.
|
Declaration |
findSymbol(IDExpression name)
Retrieves the declaration for a symbol, possibly searching
through parent symbol tables.
|
Statement |
getBody()
Returns the statement that is the body of the loop.
|
Expression |
getCondition()
Returns the expression that determines the duration of the loop.
|
java.util.Set<Declaration> |
getDeclarations()
Returns the set of declarations declared within the symbol table object.
|
java.util.List<SymbolTable> |
getParentTables()
Returns a list of symbol tables that are parents
of this table in the distributed symbol table graph.
|
java.util.Set<Symbol> |
getSymbols()
Returns the set of declared symbols in the symbol table object.
|
void |
setBody(Statement body)
Sets the body statement with the given statement body.
|
static void |
setClassPrintMethod(java.lang.reflect.Method m)
Overrides the class print method, so that all subsequently
created objects will use the supplied method.
|
void |
setCondition(Expression cond)
Sets the condition expression with the given expression cond.
|
annotate, annotateAfter, annotateBefore, containsAnnotation, detach, equals, getAnnotation, getAnnotations, getAnnotations, getAnnotations, getChildren, getParent, getProcedure, hashCode, print, removeAnnotations, removeAnnotations, removeChild, setChild, setLineNumber, setParent, setPrintMethod, swapWith, toString, verify, wheregetChildren, getParent, removeChild, setChild, setParentpublic WhileLoop(Expression condition, Statement body)
condition - the condition expression.body - the body statement.java.lang.IllegalArgumentException - if condition or body is
null.NotAnOrphanException - if condition or body has a
parent.public void addDeclaration(Declaration decl)
SymbolTableaddDeclaration in interface SymbolTabledecl - The declaration to add.public void addDeclarationBefore(Declaration ref, Declaration decl)
SymbolTableaddDeclarationBefore in interface SymbolTableref - The reference point.decl - The declaration to add.public void addDeclarationAfter(Declaration ref, Declaration decl)
SymbolTableaddDeclarationAfter in interface SymbolTableref - The reference point.decl - The declaration to add.public static void defaultPrint(WhileLoop l, java.io.PrintWriter o)
l - The loop to print.o - The writer on which to print the loop.public Declaration findSymbol(IDExpression name)
SymbolTablefindSymbol in interface SymbolTablename - The name of the symbol.public Statement getBody()
Looppublic void setBody(Statement body)
body - the new body statement.java.lang.IllegalArgumentException - if body is null.NotAnOrphanException - if body has a parent object.public Expression getCondition()
LoopgetCondition in interface Looppublic void setCondition(Expression cond)
cond - the new condition expression.java.lang.IllegalArgumentException - if cond is null.NotAnOrphanException - if cond has a parent object.public java.util.List<SymbolTable> getParentTables()
SymbolTablegetParentTables in interface SymbolTablepublic static void setClassPrintMethod(java.lang.reflect.Method m)
m - The new print method.public WhileLoop clone()
public java.util.Set<Symbol> getSymbols()
SymbolTablegetSymbols in interface SymbolTablepublic java.util.Set<Declaration> getDeclarations()
SymbolTablegetDeclarations in interface SymbolTablepublic boolean containsSymbol(Symbol symbol)
SymbolTablecontainsSymbol in interface SymbolTablepublic boolean containsDeclaration(Declaration decl)
SymbolTablecontainsDeclaration in interface SymbolTable