soot.toolkits.graph
Class ExceptionalBlockGraph

java.lang.Object
  extended by soot.toolkits.graph.BlockGraph
      extended by soot.toolkits.graph.ExceptionalBlockGraph
All Implemented Interfaces:
Iterable<Block>, DirectedGraph<Block>, ExceptionalGraph<Block>
Direct Known Subclasses:
CompleteBlockGraph

public class ExceptionalBlockGraph
extends BlockGraph
implements ExceptionalGraph<Block>

Represents a CFG where the nodes are Blocks and the edges are derived from control flow. Control flow associated with exceptions is taken into account: when a Unit may throw an exception that is caught by a Trap within the Body, the excepting Unit starts a new basic block (Units do not start a new block when all the exceptions they might throw would escape the method without being caught).


Nested Class Summary
static class ExceptionalBlockGraph.ExceptionDest
           
 
Field Summary
 
Fields inherited from class soot.toolkits.graph.BlockGraph
mBlocks, mBody, mHeads, mTails, mUnits
 
Constructor Summary
ExceptionalBlockGraph(Body body)
          Constructs an ExceptionalBlockGraph for the blocks found by partitioning the the units of the provided Body instance into basic blocks.
ExceptionalBlockGraph(ExceptionalUnitGraph unitGraph)
          Constructs a graph for the blocks found by partitioning the the Units in an ExceptionalUnitGraph.
 
Method Summary
protected  Map<Unit,Block> buildBlocks(Set<Unit> leaders, UnitGraph uncastUnitGraph)
          A utility method that does most of the work of constructing basic blocks, once the set of block leaders has been determined, and which designates the heads and tails of the graph.
 List<Block> getExceptionalPredsOf(Block b)
          Returns a list of nodes which are predecessors of a given node when only exceptional control flow is considered.
 List<Block> getExceptionalSuccsOf(Block b)
          Returns a list of nodes which are successors of a given node when only exceptional control flow is considered.
 Collection<ExceptionalBlockGraph.ExceptionDest> getExceptionDests(Block b)
          Returns a collection of ExceptionDest objects which represent how exceptions thrown by a specified node will be handled.
 List<Block> getUnexceptionalPredsOf(Block b)
          Returns a list of nodes which are predecessors of a given node when only unexceptional control flow is considered.
 List<Block> getUnexceptionalSuccsOf(Block b)
          Returns a list of nodes which are successors of a given node when only unexceptional control flow is considered.
 
Methods inherited from class soot.toolkits.graph.BlockGraph
computeLeaders, getBlocks, getBody, getHeads, getPredsOf, getSuccsOf, getTails, iterator, size, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface soot.toolkits.graph.ExceptionalGraph
getBody
 
Methods inherited from interface soot.toolkits.graph.DirectedGraph
getHeads, getPredsOf, getSuccsOf, getTails, iterator, size
 

Constructor Detail

ExceptionalBlockGraph

public ExceptionalBlockGraph(Body body)

Constructs an ExceptionalBlockGraph for the blocks found by partitioning the the units of the provided Body instance into basic blocks.

Note that this constructor builds an ExceptionalUnitGraph internally when splitting body's Units into Blocks. Callers who already have an ExceptionalUnitGraph to hand can use the constructor taking an ExceptionalUnitGraph as a parameter, as a minor optimization.

Parameters:
body - The underlying body we want to make a graph for.

ExceptionalBlockGraph

public ExceptionalBlockGraph(ExceptionalUnitGraph unitGraph)
Constructs a graph for the blocks found by partitioning the the Units in an ExceptionalUnitGraph.

Parameters:
unitGraph - The ExceptionalUnitGraph whose Units are to be split into blocks.
Method Detail

buildBlocks

protected Map<Unit,Block> buildBlocks(Set<Unit> leaders,
                                      UnitGraph uncastUnitGraph)

A utility method that does most of the work of constructing basic blocks, once the set of block leaders has been determined, and which designates the heads and tails of the graph.

BlockGraph provides an implementation of buildBlocks() which splits the Units in unitGraph so that each Unit in the passed set of block leaders is the first unit in a block. It defines as heads the blocks which begin with Units which are heads in unitGraph, and defines as tails the blocks which end with Units which are tails in unitGraph. Subclasses might override this behavior. This implementation calls the inherited implementation to split units into blocks, before adding the distinctions between exceptional and unexceptional control flow.

Overrides:
buildBlocks in class BlockGraph
Parameters:
{@inheritDoc} -
Returns:
a Map from Units which begin or end a block to the block which contains them.

getUnexceptionalPredsOf

public List<Block> getUnexceptionalPredsOf(Block b)
Description copied from interface: ExceptionalGraph
Returns a list of nodes which are predecessors of a given node when only unexceptional control flow is considered.

Specified by:
getUnexceptionalPredsOf in interface ExceptionalGraph<Block>
Parameters:
b - The node whose predecessors are to be returned.
Returns:
a List of the nodes in this graph from which there is an unexceptional edge to n.

getUnexceptionalSuccsOf

public List<Block> getUnexceptionalSuccsOf(Block b)
Description copied from interface: ExceptionalGraph
Returns a list of nodes which are successors of a given node when only unexceptional control flow is considered.

Specified by:
getUnexceptionalSuccsOf in interface ExceptionalGraph<Block>
Parameters:
b - The node whose successors are to be returned.
Returns:
a List of nodes in this graph to which there is an unexceptional edge from n.

getExceptionalPredsOf

public List<Block> getExceptionalPredsOf(Block b)
Description copied from interface: ExceptionalGraph
Returns a list of nodes which are predecessors of a given node when only exceptional control flow is considered.

Specified by:
getExceptionalPredsOf in interface ExceptionalGraph<Block>
Parameters:
b - The node whose predecessors are to be returned.
Returns:
a List of nodes in this graph from which there is an exceptional edge to n.

getExceptionalSuccsOf

public List<Block> getExceptionalSuccsOf(Block b)
Description copied from interface: ExceptionalGraph
Returns a list of nodes which are successors of a given node when only exceptional control flow is considered.

Specified by:
getExceptionalSuccsOf in interface ExceptionalGraph<Block>
Parameters:
b - The node whose successors are to be returned.
Returns:
a List of nodes in this graph to which there is an exceptional edge from n.

getExceptionDests

public Collection<ExceptionalBlockGraph.ExceptionDest> getExceptionDests(Block b)
Description copied from interface: ExceptionalGraph
Returns a collection of ExceptionDest objects which represent how exceptions thrown by a specified node will be handled.

Specified by:
getExceptionDests in interface ExceptionalGraph<Block>
Parameters:
b - The node for which to provide exception information.
Returns:
a collection of ExceptionDest objects describing the traps and handlers, if any, which catch the exceptions which may be thrown by n.