Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.jxcl.cl
Class TryStacks  view TryStacks download TryStacks.java

java.lang.Object
  extended byorg.jxcl.cl.TryStacks

public class TryStacks
extends java.lang.Object

Manages try/catch blocks. Adds subgraphs to the method graph for each exception handler, building the graph that GraphTransformer hangs bytecode off. This module must cope with the fact that the compiler may allocate exception handlers in no particular order.


Nested Class Summary
private  class TryStacks.CmpHandlers
          Comparator for exception handlers.
 
Field Summary
private  SortedBlocks blox
           
private  boolean[] done
           
private  org.apache.bcel.generic.ObjectType[] exception
           
private  ControlFlowGraph graph
           
private  int handlerCount
           
private  int[] handlerPC
           
private  int index
           
private  int[] tryEnd
           
private  java.util.Map tryEndNdx
          Hash of bytecode offsets of end of try blocks.
private  int[] tryStart
           
 
Constructor Summary
TryStacks(org.apache.bcel.generic.CodeExceptionGen[] handlers, SortedBlocks blocks, ControlFlowGraph g)
          Constructor setting up try/catch arrays.
 
Method Summary
 CatchData[] getCatchData()
          Return an array of CatchData, with vertices for the beginning and end of the try block, a vertex for the handler, and the exception handled.
 java.util.Comparator getComparator()
          Return the class TryStack uses to sort exception handlers.
(package private)  int getEndTry(ControlFlowGraph graph)
          Get the bytecode offset of end of the try block for this graph.
private  java.lang.String handlerToString(int index)
           
private  ControlFlowGraph handleTry(ControlFlowGraph g, org.jxcl.graph.Edge parentEdge)
          Initialize the graph and set up catch blocks for the i-th try block.
private  ControlFlowGraph handleTryGroup(ControlFlowGraph parent, org.jxcl.graph.Edge parentEdge)
          Deal with a try block with one or more catch blocks.
 java.lang.String toString()
          Convert this Object to a human-readable String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

graph

private ControlFlowGraph graph

blox

private SortedBlocks blox

handlerCount

private int handlerCount

index

private int index

tryStart

private int[] tryStart

tryEnd

private int[] tryEnd

handlerPC

private int[] handlerPC

exception

private org.apache.bcel.generic.ObjectType[] exception

done

private boolean[] done

tryEndNdx

private java.util.Map tryEndNdx
Hash of bytecode offsets of end of try blocks.

Constructor Detail

TryStacks

public TryStacks(org.apache.bcel.generic.CodeExceptionGen[] handlers,
                 SortedBlocks blocks,
                 ControlFlowGraph g)
Constructor setting up try/catch arrays. Sorts the exception handlers and then builds a nested control flow graph, including the first code vertex in each try block who first vertex is a code vertex. XXX This does not deal correctly with code generated for a finally, which will have an additional exception handler for the try block extended by one instruction (a goto), an exception handler covering the catch blocks, a finally catch block that covers each of these extra handlers, and then an exception handler covering the finally catch block.

Method Detail

handleTry

private ControlFlowGraph handleTry(ControlFlowGraph g,
                                   org.jxcl.graph.Edge parentEdge)
Initialize the graph and set up catch blocks for the i-th try block.


handlerToString

private java.lang.String handlerToString(int index)

handleTryGroup

private ControlFlowGraph handleTryGroup(ControlFlowGraph parent,
                                        org.jxcl.graph.Edge parentEdge)
Deal with a try block with one or more catch blocks. If there is a finally block, there will be three extra exception handlers,
  • one covering the try block extended by one instruction or more
  • one covering the normal catch blocks
  • and one covering the finally catch handler itself
and two more edges from the Entry, one to the finally catch handler and one to the finally block. These last two edges are there only to help in the layout of the bytecode. They do not represent flow control edges.


getCatchData

public CatchData[] getCatchData()
Return an array of CatchData, with vertices for the beginning and end of the try block, a vertex for the handler, and the exception handled.


getComparator

public java.util.Comparator getComparator()
Return the class TryStack uses to sort exception handlers.


getEndTry

int getEndTry(ControlFlowGraph graph)
Get the bytecode offset of end of the try block for this graph.


toString

public java.lang.String toString()
Description copied from class: java.lang.Object
Convert this Object to a human-readable String. There are no limits placed on how long this String should be or what it should contain. We suggest you make it as intuitive as possible to be able to place it into System.out.println() 55 and such.

It is typical, but not required, to ensure that this method never completes abruptly with a java.lang.RuntimeException.

This method will be called when performing string concatenation with this object. If the result is null, string concatenation will instead use "null".

The default implementation returns getClass().getName() + "@" + Integer.toHexString(hashCode()).