cetus.hir
Class Program

java.lang.Object
  extended by cetus.hir.Program
All Implemented Interfaces:
Printable, Traversable

public final class Program
extends java.lang.Object
implements Traversable

Represents the entire program.


Constructor Summary
Program()
          Make an empty program.
Program(java.util.List<java.lang.String> files)
          Make a program from a group of source files.
Program(java.lang.String[] files)
          Make a program from a group of source files.
 
Method Summary
 void addTranslationUnit(TranslationUnit tunit)
          Adds a translation unit to the program.
 void createNewDDGraph()
          Adds a Data Dependence Graph Object to this program, created by DDTDriver
static void defaultPrint(Program prog, java.io.OutputStream stream)
          Prints the entire program to a stream.
 java.util.List<TranslationUnit> getChildren()
          Provides access to the children of this object as a list.
 DDGraph getDDGraph()
          Return program data dependence graph
 Traversable getParent()
          Provides access to the parent of this object.
 void parallelParse()
          Spawns threads to parse all of the translation units in parallel.
 void parse()
          Parse all of the translation units that belong to this program.
 void print()
          Write all translation units to their respective files.
 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 setParent(Traversable t)
          Unsupported - the parent of a program is null and may not be changed.
 void setPrintMethod(java.lang.reflect.Method m)
          Overrides the print method for this object only.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Program

public Program()
Make an empty program.


Program

public Program(java.util.List<java.lang.String> files)
Make a program from a group of source files.

Parameters:
files - A list of strings that are source file names.

Program

public Program(java.lang.String[] files)
Make a program from a group of source files.

Parameters:
files - An array of strings that are source file names.
Method Detail

addTranslationUnit

public void addTranslationUnit(TranslationUnit tunit)
Adds a translation unit to the program.

Parameters:
tunit - The translation unit to add. Its parent will be set to this program.

defaultPrint

public static void defaultPrint(Program prog,
                                java.io.OutputStream stream)
Prints the entire program to a stream.

Parameters:
prog - The program to print.
stream - The stream on which to print the program.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getChildren

public java.util.List<TranslationUnit> getChildren()
Description copied from interface: Traversable
Provides access to the children of this object as a list. This object is free to internally implement its list as a LinkedList or an LinkedList. It is generally not good practice to call this method yourself; the ordering of children is not guaranteed so instead you should use the methods of the particular class whose children you wish to access.

Specified by:
getChildren in interface Traversable
Returns:
the children as a list.

getParent

public Traversable getParent()
Description copied from interface: Traversable
Provides access to the parent of this object. Every IR object has at most one parent. (The parent relationship is the same as the parent relationship in the parse tree, and is not to be confused with the base class of a derived class declaration.)

Specified by:
getParent in interface Traversable
Returns:
the parent of this object.

parallelParse

public void parallelParse()
                   throws java.io.IOException
Spawns threads to parse all of the translation units in parallel.

Throws:
java.io.IOException - if there is a problem accessing any file.

parse

public void parse()
           throws java.io.IOException
Parse all of the translation units that belong to this program.

Throws:
java.io.IOException - if there is a problem accessing any file.

print

public void print()
           throws java.io.IOException
Write all translation units to their respective files.

Throws:
java.io.FileNotFoundException - if a file could not be opened.
java.io.IOException

print

public void print(java.io.OutputStream stream)
Description copied from interface: Printable
Print the code for the IR represented by the object. Always calls object_print_method(this, stream). If the object's print method is null, nothing is printed; this provides an easy mechanism to temporarily hide something.

Specified by:
print in interface Printable
Parameters:
stream - The stream on which to print the data.

removeChild

public void removeChild(Traversable child)
Description copied from interface: Traversable
Removes the specified child.

Specified by:
removeChild in interface Traversable
Parameters:
child - a reference to a child object that must match with ==.

setChild

public void setChild(int index,
                     Traversable t)
Description copied from interface: Traversable
Sets the indexth child of this object to t. It is generally not good practice to call this method yourself; the ordering of children is not guaranteed so instead you should use the methods of the particular class whose children you wish to access. There are checks to prevent such actions as making a statement a child of an expression, but you still may be able to do some damage with this method if you are not careful.

Specified by:
setChild in interface Traversable

setClassPrintMethod

public static void setClassPrintMethod(java.lang.reflect.Method m)
Overrides the class print method, so that all subsequently created objects will use the supplied method.

Parameters:
m - The new print method.

setParent

public void setParent(Traversable t)
Unsupported - the parent of a program is null and may not be changed.

Specified by:
setParent in interface Traversable

setPrintMethod

public void setPrintMethod(java.lang.reflect.Method m)
Overrides the print method for this object only.

Parameters:
m - The new print method.

createNewDDGraph

public void createNewDDGraph()
Adds a Data Dependence Graph Object to this program, created by DDTDriver


getDDGraph

public DDGraph getDDGraph()
Return program data dependence graph