harpoon.IR.Tree
Class Code

java.lang.Object
  |
  +--harpoon.ClassFile.HCode
        |
        +--harpoon.IR.Tree.Code
Direct Known Subclasses:
CanonicalTreeCode, OptimizedTreeCode, TreeCode

public abstract class Code
extends HCode

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.3 2002/02/26 22:46:10 cananian Exp $
Author:
Duncan Bryce <duncan@lcs.mit.edu>

Nested Class Summary
 class Code.TreeFactory
          Create a proper TreeFactory.
 
Nested classes inherited from class harpoon.ClassFile.HCode
HCode.PrintCallback
 
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 clone(HMethod newMethod)
          Clone this code representation.
abstract  HCodeAndMaps clone(HMethod newMethod, Frame frame)
          Clone this code representation.
protected  HCodeAndMaps cloneHelper(Code tc, DerivationGenerator dg)
          Helps to create a proper HCodeAndMaps during cloning
 ArrayFactory elementArrayFactory()
          Return an ArrayFactory for the HCodeElements composing this HCode.
 HCodeElement[] getElements()
          Returns an ordered list of the Tree Objects making up this code view.
 Iterator getElementsI()
          Returns an Iterator of the Tree Objects making up this code view.
 Frame getFrame()
           
 CFGrapher getGrapher()
          Returns a means to externally associate control flow with this tree code.
 HCodeElement[] 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.
 HCodeElement getRootElement()
          Returns the root of the Tree
abstract  TreeDerivation getTreeDerivation()
           
 UseDefer 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 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, getElementsE, 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 clone(HMethod newMethod,
                                   Frame frame)
Clone this code representation. The clone has its own copy of the Tree


cloneHelper

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


clone

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

Overrides:
clone in class HCode

getGrapher

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

getMethod

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

Specified by:
getMethod in class HCode

getFrame

public Frame getFrame()

getTreeDerivation

public abstract TreeDerivation getTreeDerivation()

getRootElement

public HCodeElement getRootElement()
Returns the root of the Tree

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

getLeafElements

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

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

getElements

public HCodeElement[] getElements()
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
See Also:
Instr

getElementsI

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

elementArrayFactory

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

Specified by:
elementArrayFactory in class HCode

print

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

Overrides:
print in class HCode

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.