public class DoLoop extends Statement implements Loop, SymbolTable
Constructor and Description |
---|
DoLoop(Statement body,
Expression condition)
Constructs a new do loop with the given body statement and the condition
expression.
|
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.
|
DoLoop |
clone()
Returns a clone of this do 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(DoLoop l,
java.io.PrintWriter o)
Prints a do loop to a print writer.
|
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.
|
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, where
getChildren, getParent, removeChild, setChild, setParent
public DoLoop(Statement body, Expression condition)
body
- the loop body statement.condition
- the condition expression.java.lang.IllegalArgumentException
- if body or condition is
null.NotAnOrphanException
- if body or condition has a
parent.public void addDeclaration(Declaration decl)
SymbolTable
addDeclaration
in interface SymbolTable
decl
- The declaration to add.public void addDeclarationBefore(Declaration ref, Declaration decl)
SymbolTable
addDeclarationBefore
in interface SymbolTable
ref
- The reference point.decl
- The declaration to add.public void addDeclarationAfter(Declaration ref, Declaration decl)
SymbolTable
addDeclarationAfter
in interface SymbolTable
ref
- The reference point.decl
- The declaration to add.public static void defaultPrint(DoLoop l, java.io.PrintWriter o)
l
- The loop to print.o
- The writer on which to print the loop.public Declaration findSymbol(IDExpression name)
SymbolTable
findSymbol
in interface SymbolTable
name
- The name of the symbol.public Statement getBody()
Loop
public Expression getCondition()
Loop
getCondition
in interface Loop
public java.util.List<SymbolTable> getParentTables()
SymbolTable
getParentTables
in interface SymbolTable
public void setBody(Statement body)
body
- the new body statement.java.lang.IllegalArgumentException
- if body is null.NotAnOrphanException
- if body has a parent object.public static void setClassPrintMethod(java.lang.reflect.Method m)
m
- The new print method.public 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.Set<Symbol> getSymbols()
SymbolTable
getSymbols
in interface SymbolTable
public java.util.Set<Declaration> getDeclarations()
SymbolTable
getDeclarations
in interface SymbolTable
public boolean containsSymbol(Symbol symbol)
SymbolTable
containsSymbol
in interface SymbolTable
public boolean containsDeclaration(Declaration decl)
SymbolTable
containsDeclaration
in interface SymbolTable