|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcetus.hir.TranslationUnit
public final class TranslationUnit
Represents a single source file of the program. A TranslationUnit is a collection of Declarations and DeclarationStatements. The compilation of a Program may involve several TranslationUnits.
| Constructor Summary | |
|---|---|
TranslationUnit(java.lang.String input_filename)
Create an empty translation unit associated with a file. |
|
| Method Summary | |
|---|---|
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. |
void |
addDeclarationFirst(Declaration decl)
|
void |
addFirstDeclaration(Declaration decl)
|
static void |
defaultPrint(TranslationUnit tunit,
java.io.OutputStream stream)
Prints a translation unit to a stream without skipping the included headers. |
static void |
defaultPrint2(TranslationUnit tu,
java.io.OutputStream stream)
|
Declaration |
findSymbol(IDExpression name)
Retrieves the declaration for a symbol, possibly searching through parent symbol tables. |
java.util.List<Traversable> |
getChildren()
Provides access to the children of this object as a list. |
Declaration |
getFirstDeclaration()
Returns the first declaration that comes right after header files. |
java.lang.String |
getInputFilename()
Returns the original filename for the translation unit. |
java.lang.String |
getOutputFilename()
Returns the filename for the modified version of the translation unit. |
Traversable |
getParent()
Provides access to the parent of this object. |
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 |
parse()
Parse this translation unit. |
protected void |
parseAntlr()
Parse the associated input file using the Antlr parser and create IR for this translation unit. |
protected void |
parseExternal()
Parse the associated input file using an external parser and create IR for this translation unit. |
void |
print()
Prints this translation unit to the output file with which it is associated. |
void |
print(java.io.OutputStream stream)
Print the code for the IR represented by the object. |
void |
removeChild(Traversable child)
Removes the specified child. |
void |
setChild(int index,
Traversable t)
Sets the indexth child of this object to t. |
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 |
setOutputFilename(java.lang.String output_filename)
Sets the output filename for the translation unit. |
void |
setParent(Traversable t)
Sets the parent program for this translation unit. |
void |
setPrintMethod(java.lang.reflect.Method m)
Overrides the print method for this object only. |
java.lang.String |
toControlledString()
Returns a string representation of this translation unit skipping unnecessary headers. |
java.lang.String |
toString()
Returns a string representation of this translation unit without skipping the included headers. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public TranslationUnit(java.lang.String input_filename)
input_filename - The file name for this TranslationUnit| Method Detail |
|---|
public void addDeclaration(Declaration decl)
SymbolTable
addDeclaration in interface SymbolTabledecl - The declaration to add.public void addDeclarationFirst(Declaration decl)
public void addFirstDeclaration(Declaration decl)
public void addDeclarationBefore(Declaration ref,
Declaration decl)
SymbolTable
addDeclarationBefore in interface SymbolTableref - The reference point.decl - The declaration to add.
public void addDeclarationAfter(Declaration ref,
Declaration decl)
SymbolTable
addDeclarationAfter in interface SymbolTableref - The reference point.decl - The declaration to add.public Declaration getFirstDeclaration()
public static void defaultPrint(TranslationUnit tunit,
java.io.OutputStream stream)
tunit - The translation unit to print.stream - The stream on which to print the translation unit.public java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.String toControlledString()
public Declaration findSymbol(IDExpression name)
SymbolTable
findSymbol in interface SymbolTablename - The name of the symbol.public java.util.List<Traversable> getChildren()
Traversable
getChildren in interface Traversablepublic java.lang.String getInputFilename()
public java.lang.String getOutputFilename()
public Traversable getParent()
Traversable
getParent in interface Traversablepublic java.util.List getParentTables()
SymbolTable
getParentTables in interface SymbolTablepublic java.util.Map<IDExpression,Declaration> getTable()
SymbolTable
getTable in interface SymbolTable
public void parse()
throws java.io.IOException
java.io.IOException - if there is a problem accessing any file.protected void parseAntlr()
java.io.IOException - if there is any problem accessing the file.
protected void parseExternal()
throws java.io.IOException
java.io.IOException - if there is any problem accessing the file.
public static void defaultPrint2(TranslationUnit tu,
java.io.OutputStream stream)
public void print()
throws java.io.FileNotFoundException
java.io.FileNotFoundException - if an output file could not be opened.public void print(java.io.OutputStream stream)
Printable
print in interface Printablestream - The stream on which to print the data.public void removeChild(Traversable child)
Traversable
removeChild in interface Traversablechild - a reference to a child object that must match with ==.
public void setChild(int index,
Traversable t)
Traversable
setChild in interface Traversablepublic static void setClassPrintMethod(java.lang.reflect.Method m)
m - The new print method.public void setOutputFilename(java.lang.String output_filename)
output_filename - The output filename for the translation unit.public void setParent(Traversable t)
setParent in interface Traversablet - The parent program.public void setPrintMethod(java.lang.reflect.Method m)
m - The new print method.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||