harpoon.IR.Tree
Class Code

java.lang.Object
  extended by harpoon.ClassFile.HCode<Tree>
      extended by harpoon.IR.Tree.Code
Direct Known Subclasses:
CanonicalTreeCode, OptimizedTreeCode, TreeCode

public abstract class Code
extends HCode<Tree>

Tree.Code is an abstract superclass of codeviews using the components in IR.Tree. It implements shared methods for the various codeviews using Trees.

Version:
$Id: Code.java,v 1.9 2004/02/08 01:55:51 cananian Exp $
Author:
Duncan Bryce <duncan@lcs.mit.edu>

Nested Class Summary
 class Code.TreeFactory
          Create a proper TreeFactory.
 
Nested classes/interfaces inherited from class harpoon.ClassFile.HCode
HCode.PrintCallback<HCE extends HCodeElement>
 
Field Summary
protected  Frame frame
          The Frame containing machine-specific information
protected  HMethod parent
          The method that this code view represents.
protected  Code.TreeFactory tf
          Tree factory.
protected  Tree tree
          The Tree Objects composing this code view.
 
Constructor Summary
protected Code(HMethod parent, Tree tree, Frame frame)
          constructor.
 
Method Summary
 HCodeAndMaps<Tree> clone(HMethod newMethod)
          Clone this code representation.
abstract  HCodeAndMaps<Tree> clone(HMethod newMethod, Frame frame)
          Clone this code representation.
protected  HCodeAndMaps<Tree> cloneHelper(Code tc, DerivationGenerator dg)
          Helps to create a proper HCodeAndMaps during cloning
 ArrayFactory<Tree> elementArrayFactory()
          Return an ArrayFactory for the HCodeElements composing this HCode.
 Tree[] getElements()
          Deprecated.  
 Iterator<Tree> getElementsI()
          Returns an Iterator of the Tree Objects making up this code view.
 Frame getFrame()
           
 CFGrapher<Tree> getGrapher()
          Returns a means to externally associate control flow with this tree code.
 Tree[] getLeafElements()
          Returns the leaves of the Tree
 HMethod getMethod()
          Return the HMethod this codeview belongs to.
abstract  String getName()
          Return the name of this code view.
 Tree getRootElement()
          Returns the root of the Tree
abstract  TreeDerivation getTreeDerivation()
           
 UseDefer<Tree> getUseDefer()
          Returns a means to externally associate use/def information with this tree code.
abstract  boolean isCanonical()
          Returns true if this codeview is a canonical representation
 void print(PrintWriter pw, HCode.PrintCallback<Tree> callback)
          Pretty-print this code view using the specified callback.
 void remove(Stm stm)
          Removes the specified Stm from the tree in which it resides.
 
Methods inherited from class harpoon.ClassFile.HCode
clone, elementIndexer, getElementsL, print, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

tree

protected Tree tree
The Tree Objects composing this code view.


frame

protected Frame frame
The Frame containing machine-specific information


tf

protected Code.TreeFactory tf
Tree factory.


parent

protected HMethod parent
The method that this code view represents.

Constructor Detail

Code

protected Code(HMethod parent,
               Tree tree,
               Frame frame)
constructor.

Method Detail

clone

public abstract HCodeAndMaps<Tree> clone(HMethod newMethod,
                                         Frame frame)
Clone this code representation. The clone has its own copy of the Tree


cloneHelper

protected final HCodeAndMaps<Tree> cloneHelper(Code tc,
                                               DerivationGenerator dg)
Helps to create a proper HCodeAndMaps during cloning


clone

public final HCodeAndMaps<Tree> clone(HMethod newMethod)
Clone this code representation. The clone has its own copy of the Tree

Overrides:
clone in class HCode<Tree>

getGrapher

public CFGrapher<Tree> getGrapher()
Returns a means to externally associate control flow with this tree code. If this tree code is modified subsequent to a call to getGrapher(), the grapher is invalid, this method should be re-invoked to acquire a new grapher.


getUseDefer

public UseDefer<Tree> getUseDefer()
Returns a means to externally associate use/def information with this tree code. MOVE(TEMP(t), ...) and CALL/NATIVECALLs are treated as defs; all instances of TEMP in any of the subtrees returned by the kids() method are considered uses. Not valid for non-canonical forms.


getName

public abstract String getName()
Return the name of this code view.

Specified by:
getName in class HCode<Tree>

getMethod

public HMethod getMethod()
Return the HMethod this codeview belongs to.

Specified by:
getMethod in class HCode<Tree>

getFrame

public Frame getFrame()

getTreeDerivation

public abstract TreeDerivation getTreeDerivation()

getRootElement

public Tree getRootElement()
Returns the root of the Tree

Overrides:
getRootElement in class HCode<Tree>
Returns:
root of the code view, or null if this notion is not applicable.

getLeafElements

public Tree[] getLeafElements()
Returns the leaves of the Tree

Overrides:
getLeafElements in class HCode<Tree>
Returns:
leaves of the code view, or null if this notion is not applicable.

getElements

public Tree[] getElements()
Deprecated. 

Returns an ordered list of the Tree Objects making up this code view. The root of the tree is in element 0 of the array.

Overrides:
getElements in class HCode<Tree>
See Also:
Instr

getElementsI

public Iterator<Tree> getElementsI()
Returns an Iterator of the Tree Objects making up this code view. The root of the tree is the first element of the Iterator. Returns the elements of the tree in depth-first pre-order.

Overrides:
getElementsI in class HCode<Tree>

elementArrayFactory

public ArrayFactory<Tree> elementArrayFactory()
Description copied from class: HCode
Return an ArrayFactory for the HCodeElements composing this HCode.

Specified by:
elementArrayFactory in class HCode<Tree>

print

public void print(PrintWriter pw,
                  HCode.PrintCallback<Tree> callback)
Description copied from class: HCode
Pretty-print this code view using the specified callback.

Overrides:
print in class HCode<Tree>

isCanonical

public abstract boolean isCanonical()
Returns true if this codeview is a canonical representation


remove

public void remove(Stm stm)
Removes the specified Stm from the tree in which it resides.
Requires:
  1. stm is not of type SEQ.
  2. stm.getParent() must be of type SEQ.
  3. stm is an element of this codeview.
  4. stm is not the root element of this codeview.

Effects: Removes stm from this tree.