cetus.hir
Class Initializer

java.lang.Object
  extended by cetus.hir.Initializer
All Implemented Interfaces:
Printable, Traversable, java.lang.Cloneable
Direct Known Subclasses:
ConstructorInitializer, ListInitializer, ValueInitializer

public class Initializer
extends java.lang.Object
implements java.lang.Cloneable, Traversable


Field Summary
protected  java.util.LinkedList<Traversable> children
           
protected  Traversable parent
           
 
Constructor Summary
protected Initializer()
           
  Initializer(Expression value)
           
  Initializer(java.util.List values)
           
 
Method Summary
 java.lang.Object clone()
           
static void defaultPrint(Initializer init, java.io.OutputStream stream)
          Prints an initializer to a stream.
 java.util.List<Traversable> getChildren()
          Provides access to the children of this object as a list.
 Traversable getParent()
          Provides access to the parent of this object.
 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)
          Sets the parent of this object.
 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
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

parent

protected Traversable parent

children

protected java.util.LinkedList<Traversable> children
Constructor Detail

Initializer

protected Initializer()

Initializer

public Initializer(Expression value)

Initializer

public Initializer(java.util.List values)
Method Detail

clone

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

defaultPrint

public static void defaultPrint(Initializer init,
                                java.io.OutputStream stream)
Prints an initializer to a stream.

Parameters:
init - The initializer to print.
stream - The stream on which to print the initializer.

toString

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

getChildren

public java.util.List<Traversable> 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.

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)
Description copied from interface: Traversable
Sets the parent of this object. Cetus checks that the parent already considers this object a child. The intent is to maintain an ordering where first this object becomes a child of another object, and then this object is told who its parent is. Enforcing this order makes it easier for Cetus to enforce other invariants and ensure the IR is correct.

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.