harpoon.IR.Bytecode
Class Code

java.lang.Object
  |
  +--harpoon.ClassFile.HCode
        |
        +--harpoon.IR.Bytecode.Code

public class Code
extends HCode

Bytecode.Code is a code view that exposes the raw java classfile bytecodes.

Version:
$Id: Code.java,v 1.10 2002/02/25 21:04:17 cananian Exp $
Author:
C. Scott Ananian <cananian@alumni.princeton.edu>
See Also:
HCode

Nested Class Summary
static class Code.ExceptionEntry
          Represents exception handlers in this code view.
 
Nested classes inherited from class harpoon.ClassFile.HCode
HCode.PrintCallback
 
Field Summary
static String codename
          The name of this code view.
 
Constructor Summary
Code(HMethod parent, MethodInfo methodinfo)
          Constructor.
 
Method Summary
 HCodeAndMaps clone(HMethod newMethod)
          Clone this code representation.
static HCodeFactory codeFactory()
          Return an HCodeFactory for Bytecode form.
 ArrayFactory elementArrayFactory()
          Return an ArrayFactory for the HCodeElements composing this HCode.
 Constant getConstant(int index)
          Look up a constant in the appropriate constant_pool.
 HCodeElement[] getElements()
          Return an ordered list of the component objects making up this code view.
 Enumeration getElementsE()
          Return an Enumeration of the component objects making up this code view.
 Iterator getElementsI()
          Return an Iterator over the component objects making up this code view.
 List getElementsL()
          Return an ordered list of the Bytecode.Instrs making up this code view.
 HCodeElement[] getLeafElements()
          Return the 'leaves' of this code view; that is, the elements with no successors.
 List getLeafElementsL()
           
 int getMaxLocals()
          Get the number of local variables used in this method, including the parameters passed to the method on invocation.
 int getMaxStack()
          Get the maximum number of words on the operand stack at any point during execution of this method.
 HMethod getMethod()
          Return the HMethod this codeview belongs to.
 String getName()
          Return the name of this code view, "bytecode".
 Code.ExceptionEntry[] getTryBlocks()
          Get an array with the try-catch blocks/handlers for this bytecode.
 
Methods inherited from class harpoon.ClassFile.HCode
clone, elementIndexer, getRootElement, print, print, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

codename

public static final String codename
The name of this code view.

See Also:
Constant Field Values
Constructor Detail

Code

public Code(HMethod parent,
            MethodInfo methodinfo)
Constructor.

Method Detail

clone

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

Overrides:
clone in class HCode

getMethod

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

Specified by:
getMethod in class HCode

getName

public String getName()
Return the name of this code view, "bytecode".

Specified by:
getName in class HCode
Returns:
the string "bytecode".

getElementsL

public List getElementsL()
Return an ordered list of the Bytecode.Instrs making up this code view. The first instruction to be executed is in element 0 of the array.

Overrides:
getElementsL in class HCode

getElements

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

Description copied from class: HCode
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.

Overrides:
getElements in class HCode
See Also:
Instr

getElementsE

public Enumeration getElementsE()
Deprecated. use getElementsI()

Description copied from class: HCode
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().

Overrides:
getElementsE in class HCode
See Also:
Instr

getElementsI

public Iterator getElementsI()
Description copied from class: HCode
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().

Overrides:
getElementsI in class HCode

getLeafElementsL

public List getLeafElementsL()

getLeafElements

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

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

elementArrayFactory

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

Specified by:
elementArrayFactory in class HCode

getMaxLocals

public int getMaxLocals()
Get the number of local variables used in this method, including the parameters passed to the method on invocation.


getMaxStack

public int getMaxStack()
Get the maximum number of words on the operand stack at any point during execution of this method.


getTryBlocks

public Code.ExceptionEntry[] getTryBlocks()
Get an array with the try-catch blocks/handlers for this bytecode.


getConstant

public Constant getConstant(int index)
Look up a constant in the appropriate constant_pool.


codeFactory

public static HCodeFactory codeFactory()
Return an HCodeFactory for Bytecode form.