harpoon.ClassFile
Class HCode

java.lang.Object
  |
  +--harpoon.ClassFile.HCode
Direct Known Subclasses:
Code, Code, Code, Code

public abstract class HCode
extends Object

HCode is an abstract class that all views of a particular method's executable code should extend.

An HCode corresponds roughly to a "list of instructions".

Version:
$Id: HCode.java,v 1.13 2002/02/25 21:03:03 cananian Exp $
Author:
C. Scott Ananian <cananian@alumni.princeton.edu>
See Also:
HMethod, HCodeElement, Code, Instr

Nested Class Summary
static class HCode.PrintCallback
          Callback interface for annotating pretty-prints of HCodes.
 
Constructor Summary
HCode()
           
 
Method Summary
 Object clone()
          Clone this HCode and all associated HCodeElements.
 HCodeAndMaps clone(HMethod newMethod)
          Clone this HCode, possibly moving it to a different method.
abstract  ArrayFactory elementArrayFactory()
          Return an ArrayFactory for the HCodeElements composing this HCode.
 Indexer elementIndexer()
          Return an Indexer for the HCodeElements composing this HCode.
 HCodeElement[] getElements()
          Deprecated. use getElementsL() instead.
 Enumeration getElementsE()
          Deprecated. use getElementsI() instead.
 Iterator getElementsI()
          Return an Iterator over the component objects making up this code view.
 List getElementsL()
          Return an ordered Collection (a List) of the component objects making up this code view.
 HCodeElement[] getLeafElements()
          Return the 'leaves' of this code view; that is, the elements with no successors.
abstract  HMethod getMethod()
          Return the HMethod to which this HCode belongs.
abstract  String getName()
          Return the name of this code view.
 HCodeElement getRootElement()
          Return the 'root' element of this code view.
 void print(PrintWriter pw)
          Pretty-print this code view using an empty callback.
 void print(PrintWriter pw, HCode.PrintCallback callback)
          Pretty-print this code view using the specified callback.
 String toString()
          Returns a human-readable representation of this HCode.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

HCode

public HCode()
Method Detail

getMethod

public abstract HMethod getMethod()
Return the HMethod to which this HCode belongs.


getName

public abstract String getName()
Return the name of this code view. The default bytecode view is named "bytecode". It is suggested that additional views be named in a similarly human-friendly fashion.


getElements

public HCodeElement[] getElements()
Deprecated. use getElementsL() instead.

Return an ordered list of the component objects making up this code view. If there is a 'root' to the code view, it should occupy index 0 of the HCodeElement array.

Either getElementsI() or getElementsE() must have been implemented for the default implementation to work properly.

See Also:
Instr

getElementsL

public List getElementsL()
Return an ordered Collection (a List) of the component objects making up this code view. If there is a 'root' to the code view, it should be the first element in the List.

Either getElementsI() or getElementsE() must have been implemented for the default implementation to work properly.


getElementsE

public Enumeration getElementsE()
Deprecated. use getElementsI() instead.

Return an Enumeration of the component objects making up this code view. If there is a 'root' to the code view, it should be the first element enumerated.

Implementations must implement at least one of getElementsE(), or getElementsI().

See Also:
Instr

getElementsI

public Iterator getElementsI()
Return an Iterator over the component objects making up this code view. If there is a 'root' to the code view, it should be the first element enumerated.

Implementations must implement at least one of getElementsE(), or getElementsI().


getRootElement

public HCodeElement getRootElement()
Return the 'root' element of this code view.

Returns:
root of the code view, or null if this notion is not applicable.

getLeafElements

public HCodeElement[] getLeafElements()
Return the 'leaves' of this code view; that is, the elements with no successors.

Returns:
leaves of the code view, or null if this notion is not applicable.

elementArrayFactory

public abstract ArrayFactory elementArrayFactory()
Return an ArrayFactory for the HCodeElements composing this HCode.


elementIndexer

public Indexer elementIndexer()
Return an Indexer for the HCodeElements composing this HCode. The default Indexer returned does not implement Indexer.getByID().


clone

public HCodeAndMaps clone(HMethod newMethod)
                   throws CloneNotSupportedException
Clone this HCode, possibly moving it to a different method. Throws CloneNotSupportedException if not overridden.

Throws:
CloneNotSupportedException - if it is not possible to clone this HCode.

clone

public Object clone()
             throws CloneNotSupportedException
Clone this HCode and all associated HCodeElements. Calls clone(getMethod()).

Overrides:
clone in class Object
CloneNotSupportedException

print

public final void print(PrintWriter pw)
Pretty-print this code view using an empty callback.


print

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


toString

public String toString()
Returns a human-readable representation of this HCode.

Overrides:
toString in class Object