cetus.hir
Class CompoundStatement

java.lang.Object
  extended by cetus.hir.Statement
      extended by cetus.hir.CompoundStatement
All Implemented Interfaces:
Annotatable, Printable, SymbolTable, Traversable, java.lang.Cloneable
Direct Known Subclasses:
ExceptionHandler

public class CompoundStatement
extends Statement
implements SymbolTable

Represents a group of statements that are treated as a single statement.


Field Summary
 
Fields inherited from class cetus.hir.Statement
annotations, children, line_number, object_print_method, parent
 
Constructor Summary
CompoundStatement()
          Creates an empty compound statement.
 
Method Summary
 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 this Statement
 void addStatementBefore(Statement ref_stmt, Statement new_stmt)
          Add a new Statement Before this Statement
 java.lang.Object clone()
           
 int countStatements()
          Returns the total number of Statements contained within this CompoundStatement.
static void defaultPrint(CompoundStatement stmt, java.io.OutputStream stream)
          Prints a statement to a stream.
 Declaration findSymbol(IDExpression name)
          Retrieves the declaration for a symbol, possibly searching through parent symbol tables.
 java.util.List getParentTables()
          Returns a list of symbol tables that are parents of this table in the distributed symbol table graph.
 java.util.Map<IDExpression,Declaration> getTable()
          Provides direct access to the symbol table; it's generally not a good idea to modify this directly.
 void removeChild(Traversable child)
          Removes a specific child of this statement; some statements do not support this method.
 java.lang.String toString()
          Returns a string representation of this compound statement.
 
Methods inherited from class cetus.hir.Statement
annotate, annotateAfter, annotateBefore, annotationToString, containsAnnotation, detach, getAnnotation, getAnnotations, getAnnotations, getAnnotations, getChildren, getParent, getProcedure, print, removeAnnotations, removeAnnotations, setChild, setLineNumber, setParent, setPrintMethod, swapWith, toAnnotatedString, verify, where
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CompoundStatement

public CompoundStatement()
Creates an empty compound statement.

Method Detail

addDeclaration

public 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.

Specified by:
addDeclaration in interface SymbolTable
Parameters:
decl - The declaration to add.

addDeclarationBefore

public void addDeclarationBefore(Declaration ref,
                                 Declaration decl)
Description copied from interface: SymbolTable
Add a declaration before the reference declaration.

Specified by:
addDeclarationBefore in interface SymbolTable
Parameters:
ref - The reference point.
decl - The declaration to add.

addDeclarationAfter

public void addDeclarationAfter(Declaration ref,
                                Declaration decl)
Description copied from interface: SymbolTable
Add a declaration after the reference declaration.

Specified by:
addDeclarationAfter in interface SymbolTable
Parameters:
ref - The reference point.
decl - The declaration to add.

addStatement

public void addStatement(Statement stmt)
Adds a statement to the end of this compound statement.

Parameters:
stmt - The statement to add.

addStatementBefore

public void addStatementBefore(Statement ref_stmt,
                               Statement new_stmt)
Add a new Statement Before this Statement

Parameters:
new_stmt - The Statement to be added
ref_stmt - Reference point

addStatementAfter

public void addStatementAfter(Statement ref_stmt,
                              Statement new_stmt)
Add a new Statement After this Statement

Parameters:
new_stmt - The Statement to be added
ref_stmt - Reference point

clone

public java.lang.Object clone()
Overrides:
clone in class Statement

countStatements

public int countStatements()
Returns the total number of Statements contained within this CompoundStatement.

Returns:
the number of statements within this compound statement

defaultPrint

public static void defaultPrint(CompoundStatement stmt,
                                java.io.OutputStream stream)
Prints a statement to a stream.

Parameters:
stmt - The statement to print.
stream - The stream on which to print the statement.

toString

public java.lang.String toString()
Returns a string representation of this compound statement. Printing of children's annotations are controlled in this method.

Specified by:
toString in class Statement

findSymbol

public Declaration findSymbol(IDExpression name)
Description copied from interface: SymbolTable
Retrieves the declaration for a symbol, possibly searching through parent symbol tables.

Specified by:
findSymbol in interface SymbolTable
Parameters:
name - The name of the symbol.

getParentTables

public java.util.List getParentTables()
Description copied from interface: SymbolTable
Returns a list of symbol tables that are parents of this table in the distributed symbol table graph. A list is necessary because representing multiple inheritence in C++ requires it. Note that the parent tables are not necessarily tables of the immediate parent. The list is all symbol tables enclosing this object which appear at the same level such that no other symbol tables appear between this object and those tables.

Specified by:
getParentTables in interface SymbolTable
Returns:
a List of SymbolTables.

getTable

public java.util.Map<IDExpression,Declaration> getTable()
Description copied from interface: SymbolTable
Provides direct access to the symbol table; it's generally not a good idea to modify this directly.

Specified by:
getTable in interface SymbolTable
Returns:
a map of IDExpressions to Declarations.

removeChild

public void removeChild(Traversable child)
Description copied from class: Statement
Removes a specific child of this statement; some statements do not support this method.

Specified by:
removeChild in interface Traversable
Overrides:
removeChild in class Statement
Parameters:
child - The child to remove.