ptolemy.copernicus.c
Class ExceptionTracker

java.lang.Object
  extended by ptolemy.copernicus.c.ExceptionTracker

public class ExceptionTracker
extends java.lang.Object

A class that keeps track of Exceptions and Traps.

Since:
Ptolemy II 2.0
Version:
$Id: ExceptionTracker.java,v 1.29 2006/03/28 23:58:30 cxh Exp $
Author:
Ankush Varma
Accepted Rating:
Red (ankush)
Proposed Rating:
Red (ankush)

Field Summary
protected  java.util.LinkedList _beginUnitList
          The list of beginUnits.
protected  java.util.LinkedList _currently_active_traps
          The list of currently active Traps.
protected  java.util.LinkedList _endUnitList
          The list of endUnits.
protected  int _epc
          The exceptional pc.
protected  java.util.LinkedList _handlerUnitList
          The list of handlerUnits.
protected  soot.util.Chain _trapChain
          The Chain of Traps.
protected  java.util.LinkedList _trapsForEachEpc
          List containing the lists of traps for each epc.
 
Constructor Summary
ExceptionTracker()
          A dummy initializer method.
 
Method Summary
protected  void _storeState()
          Store the current state of the ExceptionTracker.
 int beginIndexOf(soot.Unit u)
          Gives the index of the first incidence of Unit u in the list of beginUnits.
 void beginUnitEncountered(soot.Unit u)
          Record that this beginUnit has been encountered and perform the appropriate housekeeping functions.
 int endIndexOf(soot.Unit u)
          Gives the index of the first incidence of Unit u in the list of endUnits.
 void endUnitEncountered(soot.Unit u)
          Record that this endUnit has been encountered and perform the appropriate housekeeping functions.
 int getEpc()
          Returns the current Exceptional PC.
 java.util.LinkedList getHandlerUnitList(int epc)
          Returns a list of all handler units associated with the given exceptional pc.
 soot.util.Chain getTrapChain()
          Returns a chain of all the Traps in the body.
 java.util.LinkedList getTrapsForEpc(int epc)
          Returns a list of all Traps for the given exceptional PC.
 int handlerIndexOf(soot.Unit u)
          Gives the index of the first incidence of Unit u in the list of handlerUnits.
 void init(soot.Body body)
          Initializes the class with a given body.
 boolean isBeginUnit(soot.Unit u)
          Checks if unit u is the beginUnit for any Trap in the body.
 boolean isEndUnit(soot.Unit u)
          Checks if unit u is the endUnit for any Trap in the body.
 boolean isHandlerUnit(soot.Unit u)
          Checks if unit u is the handlerUnit for any Trap in the body.
 int numberOfTraps()
          Returns the number of traps in the body.
 boolean trapsExist()
          Returns whether the body has any traps in it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_epc

protected int _epc
The exceptional pc.


_trapChain

protected soot.util.Chain _trapChain
The Chain of Traps.


_beginUnitList

protected java.util.LinkedList _beginUnitList
The list of beginUnits.


_endUnitList

protected java.util.LinkedList _endUnitList
The list of endUnits.


_handlerUnitList

protected java.util.LinkedList _handlerUnitList
The list of handlerUnits.


_currently_active_traps

protected java.util.LinkedList _currently_active_traps
The list of currently active Traps.


_trapsForEachEpc

protected java.util.LinkedList _trapsForEachEpc
List containing the lists of traps for each epc. The index in this list is the epc, so the epc is not explicitly stored in this data structure.

Constructor Detail

ExceptionTracker

public ExceptionTracker()
A dummy initializer method.

Method Detail

beginIndexOf

public int beginIndexOf(soot.Unit u)
Gives the index of the first incidence of Unit u in the list of beginUnits.

Parameters:
u - The Unit.
Returns:
The index of Unit u in the list.

beginUnitEncountered

public void beginUnitEncountered(soot.Unit u)
Record that this beginUnit has been encountered and perform the appropriate housekeeping functions.

Parameters:
u - The Unit.

endIndexOf

public int endIndexOf(soot.Unit u)
Gives the index of the first incidence of Unit u in the list of endUnits.

Parameters:
u - The Unit.
Returns:
The index of Unit u in the list.

endUnitEncountered

public void endUnitEncountered(soot.Unit u)
Record that this endUnit has been encountered and perform the appropriate housekeeping functions.

Parameters:
u - The Unit.

getEpc

public int getEpc()
Returns the current Exceptional PC.

Returns:
The current Exceptional PC.

getHandlerUnitList

public java.util.LinkedList getHandlerUnitList(int epc)
Returns a list of all handler units associated with the given exceptional pc.

Parameters:
epc - The exceptional pc.
Returns:
A list of all handlerUnits associated with the given epc.

getTrapChain

public soot.util.Chain getTrapChain()
Returns a chain of all the Traps in the body.

Returns:
A chain of all the Traps in the body.

getTrapsForEpc

public java.util.LinkedList getTrapsForEpc(int epc)
Returns a list of all Traps for the given exceptional PC.

Parameters:
epc - The exceptional pc.
Returns:
A list of all Traps for the given epc.

handlerIndexOf

public int handlerIndexOf(soot.Unit u)
Gives the index of the first incidence of Unit u in the list of handlerUnits.

Parameters:
u - The Unit.
Returns:
The index of Unit u in the list.

init

public void init(soot.Body body)
Initializes the class with a given body. This method must be called before calling any of the other methods.

Parameters:
body - The Body for which exceptions are to be tracked.

isBeginUnit

public boolean isBeginUnit(soot.Unit u)
Checks if unit u is the beginUnit for any Trap in the body.

Parameters:
u - The Unit to be checked.
Returns:
True if u is a beginUnit.

isEndUnit

public boolean isEndUnit(soot.Unit u)
Checks if unit u is the endUnit for any Trap in the body.

Parameters:
u - The Unit to be checked.
Returns:
True if u is an endUnit.

isHandlerUnit

public boolean isHandlerUnit(soot.Unit u)
Checks if unit u is the handlerUnit for any Trap in the body.

Parameters:
u - The Unit to be checked.
Returns:
True if u is a handlerUnit.

numberOfTraps

public int numberOfTraps()
Returns the number of traps in the body.

Returns:
The number of traps in the body.

trapsExist

public boolean trapsExist()
Returns whether the body has any traps in it.

Returns:
True if any traps exist in the body.

_storeState

protected void _storeState()
Store the current state of the ExceptionTracker.