public abstract class UnitGraph extends java.lang.Object implements DirectedGraph<Unit>
Represents a CFG where the nodes are Unit
instances and edges
represent unexceptional and (possibly) exceptional control flow between
Units.
This is an abstract class, providing the facilities used to build CFGs for specific purposes.
Modifier and Type | Field and Description |
---|---|
protected Body |
body |
protected java.util.List<Unit> |
heads |
protected SootMethod |
method |
protected java.util.List<Unit> |
tails |
protected Chain<Unit> |
unitChain |
protected java.util.Map<Unit,java.util.List<Unit>> |
unitToPreds |
protected java.util.Map<Unit,java.util.List<Unit>> |
unitToSuccs |
Modifier | Constructor and Description |
---|---|
protected |
UnitGraph(Body body)
Performs the work that is required to construct any sort of
UnitGraph.
|
Modifier and Type | Method and Description |
---|---|
protected void |
addEdge(java.util.Map<Unit,java.util.List<Unit>> unitToSuccs,
java.util.Map<Unit,java.util.List<Unit>> unitToPreds,
Unit head,
Unit tail)
Utility method for adding an edge to maps representing the CFG.
|
protected void |
buildHeadsAndTails()
Utility method used in the construction of
UnitGraph s, to be
called only after the unitToPreds and unitToSuccs maps have been built. |
protected void |
buildUnexceptionalEdges(java.util.Map<Unit,java.util.List<Unit>> unitToSuccs,
java.util.Map<Unit,java.util.List<Unit>> unitToPreds)
Utility method for UnitGraph constructors.
|
protected java.util.Map<Unit,java.util.List<Unit>> |
combineMapValues(java.util.Map<Unit,java.util.List<Unit>> mapA,
java.util.Map<Unit,java.util.List<Unit>> mapB)
Utility method that produces a new map from the
Unit s of this
graph's body to the union of the values stored in the two argument
Map s, used to combine the maps of exceptional and unexceptional
predecessors and successors into maps of all predecessors and successors. |
Body |
getBody() |
java.util.List<Unit> |
getExtendedBasicBlockPathBetween(Unit from,
Unit to)
Look for a path in graph, from def to use.
|
java.util.List<Unit> |
getHeads()
Returns a list of entry points for this graph.
|
java.util.List<Unit> |
getPredsOf(Unit u)
Returns a list of predecessors for the given node in the graph.
|
java.util.List<Unit> |
getSuccsOf(Unit u)
Returns a list of successors for the given node in the graph.
|
java.util.List<Unit> |
getTails()
Returns a list of exit points for this graph.
|
java.util.Iterator<Unit> |
iterator()
Returns an iterator for the nodes in this graph.
|
int |
size()
Returns the node count for this graph.
|
java.lang.String |
toString() |
protected java.util.List<Unit> heads
protected java.util.List<Unit> tails
protected SootMethod method
protected Body body
protected UnitGraph(Body body)
body
- The body of the method for which to construct a control flow
graph.protected void buildUnexceptionalEdges(java.util.Map<Unit,java.util.List<Unit>> unitToSuccs, java.util.Map<Unit,java.util.List<Unit>> unitToPreds)
unitToSuccs
- A Map
from Unit
s to List
s of
Unit
s. This is an ``out parameter''; callers must pass
an empty Map
. buildUnexceptionalEdges will
add a mapping for every Unit in the body to a list of
its unexceptional successors.unitToPreds
- A Map
from Unit
s to List
s of
Unit
s. This is an ``out parameter''; callers must pass
an empty Map
. buildUnexceptionalEdges will
add a mapping for every Unit in the body to a list of
its unexceptional predecessors.protected void buildHeadsAndTails()
Utility method used in the construction of UnitGraph
s, to be
called only after the unitToPreds and unitToSuccs maps have been built.
UnitGraph
provides an implementation of
buildHeadsAndTails()
which defines the graph's set of heads
to include the first Unit
in the graph's body, together with any
other Unit which has no predecessors. It defines the graph's set
of tails to include all Units with no successors. Subclasses of
UnitGraph
may override this method to change the criteria
for classifying a node as a head or tail.
protected java.util.Map<Unit,java.util.List<Unit>> combineMapValues(java.util.Map<Unit,java.util.List<Unit>> mapA, java.util.Map<Unit,java.util.List<Unit>> mapB)
Unit
s of this
graph's body to the union of the values stored in the two argument
Map
s, used to combine the maps of exceptional and unexceptional
predecessors and successors into maps of all predecessors and successors.
The values stored in both argument maps must be List
s of
Unit
s, which are assumed not to contain any duplicate
Units.mapA
- The first map to be combined.mapB
- The second map to be combined.protected void addEdge(java.util.Map<Unit,java.util.List<Unit>> unitToSuccs, java.util.Map<Unit,java.util.List<Unit>> unitToPreds, Unit head, Unit tail)
public java.util.List<Unit> getExtendedBasicBlockPathBetween(Unit from, Unit to)
from
- start point for the path.to
- end point for the path.public java.util.List<Unit> getHeads()
DirectedGraph
getHeads
in interface DirectedGraph<Unit>
public java.util.List<Unit> getTails()
DirectedGraph
getTails
in interface DirectedGraph<Unit>
public java.util.List<Unit> getPredsOf(Unit u)
DirectedGraph
getPredsOf
in interface DirectedGraph<Unit>
public java.util.List<Unit> getSuccsOf(Unit u)
DirectedGraph
getSuccsOf
in interface DirectedGraph<Unit>
public int size()
DirectedGraph
size
in interface DirectedGraph<Unit>
public java.util.Iterator<Unit> iterator()
DirectedGraph
iterator
in interface java.lang.Iterable<Unit>
iterator
in interface DirectedGraph<Unit>
public java.lang.String toString()
toString
in class java.lang.Object