org.quilt.cl
Class GraphTransformer

java.lang.Object
  |
  +--org.quilt.cl.GraphTransformer

public class GraphTransformer
extends java.lang.Object

Build the control flow graph for a method, apply an arbitrary number of GraphXformers to it, and then collapse the graph back to an instruction list. Exception handlers are collected from the control flow graph and made available to callers.

XXX Debug statements should be removed when code is definitely stable. XXX

Author:
Jim Dixon

Constructor Summary
GraphTransformer(java.util.List gxf)
          Creates method control flow graphs, applies application- specific transforms, and then collapses the graph to produce a new instruction list.
 
Method Summary
protected  BytecodeCollector collapseGraph(ControlFlowGraph graph)
          Collapse a method control flow graph, writing bytecode back into the MethodGen data structures.
 org.apache.bcel.generic.CodeExceptionGen[] getExceptionHandlers()
          Returns array of exception handlers, empty if the instruction list was null or there were no exception handlers.
static boolean hasInbound(org.apache.bcel.generic.InstructionHandle ih)
          Whether this instruction is target of branch instruction or starts catch block.
protected  ControlFlowGraph makeGraph(org.apache.bcel.generic.ClassGen clazz, org.apache.bcel.generic.MethodGen method)
          Build the graph for the method.
 org.apache.bcel.generic.InstructionList xform(org.apache.bcel.generic.ClassGen clazz, org.apache.bcel.generic.MethodGen method)
          Build a control flow graph for a method's instruction list, apply any transformers to it, and collapse the graph into a new instruction list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GraphTransformer

public GraphTransformer(java.util.List gxf)
Creates method control flow graphs, applies application- specific transforms, and then collapses the graph to produce a new instruction list.

Parameters:
gxf - List of application-specific graph transformers.
Method Detail

xform

public org.apache.bcel.generic.InstructionList xform(org.apache.bcel.generic.ClassGen clazz,
                                                     org.apache.bcel.generic.MethodGen method)
Build a control flow graph for a method's instruction list, apply any transformers to it, and collapse the graph into a new instruction list.

Parameters:
clazz - Class being transformed.
method - The method being transformed.
Returns:
The transformed instruction list.

getExceptionHandlers

public org.apache.bcel.generic.CodeExceptionGen[] getExceptionHandlers()
Returns array of exception handlers, empty if the instruction list was null or there were no exception handlers.

Returns:
Array of CodeExceptionGen.

makeGraph

protected final ControlFlowGraph makeGraph(org.apache.bcel.generic.ClassGen clazz,
                                           org.apache.bcel.generic.MethodGen method)
Build the graph for the method.

Parameters:
clazz - Class being transformed in bcel ClassGen.

hasInbound

public static final boolean hasInbound(org.apache.bcel.generic.InstructionHandle ih)
Whether this instruction is target of branch instruction or starts catch block.

Parameters:
ih - Handle on instruction.
Returns:
True if targeted by branch or CodeExceptionGen.

collapseGraph

protected final BytecodeCollector collapseGraph(ControlFlowGraph graph)
Collapse a method control flow graph, writing bytecode back into the MethodGen data structures.



Copyright © 2001-2003 Apache Software Foundation. All Rights Reserved.