public class CompoundStatement extends Statement implements SymbolTable
| Constructor and Description |
|---|
CompoundStatement()
Creates an empty compound statement.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addDeclaration(Declaration decl)
Adds a declaration after the last declaration; this models the C
language's requirement that all declarations appear at the beginning of a
block.
|
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.
|
void |
addStatement(Statement stmt)
Adds a statement to the end of this compound statement.
|
void |
addStatementAfter(Statement ref_stmt,
Statement new_stmt)
Add a new statement after the reference statement.
|
void |
addStatementBefore(Statement ref_stmt,
Statement new_stmt)
Add a new statement before the reference statement.
|
CompoundStatement |
clone()
Returns a clone of this compound statement.
|
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.
|
int |
countStatements()
Returns the total number of statements contained within
this CompoundStatement.
|
static void |
defaultPrint(CompoundStatement s,
java.io.PrintWriter o)
Prints a statement to the given print writer.
|
Declaration |
findSymbol(IDExpression name)
Retrieves the declaration for a symbol, possibly searching
through parent symbol tables.
|
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 |
removeChild(Traversable child)
Removes the specified child object if it exists.
|
void |
removeStatement(Statement stmt)
Remove the given statement if it exists.
|
annotate, annotateAfter, annotateBefore, containsAnnotation, detach, equals, getAnnotation, getAnnotations, getAnnotations, getAnnotations, getChildren, getParent, getProcedure, hashCode, print, removeAnnotations, removeAnnotations, setChild, setLineNumber, setParent, setPrintMethod, swapWith, toString, verify, wheregetChildren, getParent, setChild, setParentpublic CompoundStatement()
public void addDeclaration(Declaration decl)
addDeclaration in interface SymbolTabledecl - The declaration to add.NotAnOrphanException - if decl has a parent.public void addDeclarationBefore(Declaration ref, Declaration decl)
SymbolTableaddDeclarationBefore in interface SymbolTableref - The reference point.decl - The declaration to add.java.lang.IllegalArgumentException - if ref is not found.NotAnOrphanException - if decl has a parent.public void addDeclarationAfter(Declaration ref, Declaration decl)
SymbolTableaddDeclarationAfter in interface SymbolTableref - The reference point.decl - The declaration to add.java.lang.IllegalArgumentException - if ref is not found.NotAnOrphanException - if decl has a parent.public void addStatement(Statement stmt)
addDeclaration(cetus.hir.Declaration).stmt - The statement to add.java.lang.IllegalArgumentException - If stmt is null.NotAnOrphanException - if stmt has a parent.java.lang.UnsupportedOperationException - if stmt is a declaration
statement.public void addStatementBefore(Statement ref_stmt, Statement new_stmt)
new_stmt - the statement to be added.ref_stmt - the reference statement.java.lang.IllegalArgumentException - If ref_stmt is not found or
new_stmt is null.NotAnOrphanException - if new_stmt has a parent.java.lang.UnsupportedOperationException - If new_stmt is a declaration
statement.public void addStatementAfter(Statement ref_stmt, Statement new_stmt)
new_stmt - the statement to be added.ref_stmt - the reference statement.java.lang.IllegalArgumentException - If ref_stmt is not found or
new_stmt is null.NotAnOrphanException - if new_stmt has a parent.java.lang.UnsupportedOperationException - If stmt is a declaration
statement.public void removeStatement(Statement stmt)
stmt - the statement to be removed.public CompoundStatement clone()
public int countStatements()
public static void defaultPrint(CompoundStatement s, java.io.PrintWriter o)
s - The statement to print.o - The writer on which to print the statement.public Declaration findSymbol(IDExpression name)
SymbolTablefindSymbol in interface SymbolTablename - The name of the symbol.public java.util.List<SymbolTable> getParentTables()
SymbolTablegetParentTables in interface SymbolTablepublic void removeChild(Traversable child)
removeChild in interface TraversableremoveChild in class Statementchild - the child object to be removed.java.lang.IllegalArgumentException - if child is not found.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