harpoon.IR.Bytecode
Class Code

java.lang.Object
  extended by harpoon.ClassFile.HCode
      extended by harpoon.IR.Bytecode.Code
All Implemented Interfaces:
Graph<Instr,harpoon.IR.Bytecode.InstrEdge>

public class Code
extends HCode
implements Graph<Instr,harpoon.IR.Bytecode.InstrEdge>

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

Version:
$Id: Code.java,v 1.15 2005/09/30 18:58:13 salcianu 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/interfaces inherited from class harpoon.ClassFile.HCode
HCode.PrintCallback<HCE extends HCodeElement>
 
Nested classes/interfaces inherited from interface harpoon.Util.Collections.Graph
Graph.Edge<N extends Graph.Node<N,E>,E extends Graph.Edge<N,E>>, Graph.Node<N extends Graph.Node<N,E>,E extends Graph.Edge<N,E>>
 
Field Summary
static String codename
          The name of this code view.
static boolean VERBOSE_BYTECODE_METHOD_CREATION
          If turned on, we print a short message each time the bytecode representation for a method is created.
 
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<Instr> elementArrayFactory()
          Return an ArrayFactory for the HCodeElements composing this HCode.
 Constant getConstant(int index)
          Look up a constant in the appropriate constant_pool.
 List<Instr> getElementsL()
          Return an ordered list of the Bytecode.Instrs making up this code view.
 Instr[] getLeafElements()
          Return the 'leaves' of this code view; that is, the elements with no successors.
 List<Instr> 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.
 Set<Instr> nodes()
          Return the set of nodes comprising this Graph.
 
Methods inherited from class harpoon.ClassFile.HCode
clone, elementIndexer, getElements, getElementsI, 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

VERBOSE_BYTECODE_METHOD_CREATION

public static boolean VERBOSE_BYTECODE_METHOD_CREATION
If turned on, we print a short message each time the bytecode representation for a method is created. A top-level command line option turns this on, to allow us to see which methods are parsed by Flex.

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<Instr> 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

getLeafElementsL

public List<Instr> getLeafElementsL()

getLeafElements

public Instr[] 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<Instr> elementArrayFactory()
Description copied from class: HCode
Return an ArrayFactory for the HCodeElements composing this HCode.

Specified by:
elementArrayFactory in class HCode

nodes

public Set<Instr> nodes()
Description copied from interface: Graph
Return the set of nodes comprising this Graph.

Specified by:
nodes in interface Graph<Instr,harpoon.IR.Bytecode.InstrEdge>

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.