Class ExplodedControlFlowGraph
java.lang.Object
com.ibm.wala.ssa.analysis.ExplodedControlFlowGraph
- All Implemented Interfaces:
ControlFlowGraph<SSAInstruction,
,IExplodedBasicBlock> MinimalCFG<IExplodedBasicBlock>
,EdgeManager<IExplodedBasicBlock>
,Graph<IExplodedBasicBlock>
,NodeManager<IExplodedBasicBlock>
,NumberedEdgeManager<IExplodedBasicBlock>
,NumberedGraph<IExplodedBasicBlock>
,NumberedNodeManager<IExplodedBasicBlock>
,Iterable<IExplodedBasicBlock>
public class ExplodedControlFlowGraph
extends Object
implements ControlFlowGraph<SSAInstruction,IExplodedBasicBlock>
A view of a control flow graph where each basic block corresponds to exactly one SSA instruction
index.
Prototype: Not terribly efficient.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addEdge
(IExplodedBasicBlock src, IExplodedBasicBlock dst) void
add a node to this graphboolean
entry()
Return the entry basic block in the CFGexit()
getBlockForInstruction
(int index) The order of blocks returned should be arbitrary but deterministic.The order of blocks returned must indicate the exception-handling scope.getIR()
int
getNode
(int number) The order of blocks returned should be arbitrary but deterministic.The order of blocks returned should be arbitrary but deterministic.int
int
int
Return the number ofimmediate predecessor
nodes of nReturn anIterator
over the immediate predecessor nodes of nint
getProgramCounter
(int index) TODO: move this into IR?int
Return the number ofimmediate successor
nodes of this Node in the GraphReturn an Iterator over the immediate successor nodes of nboolean
hasEdge
(IExplodedBasicBlock src, IExplodedBasicBlock dst) iterator()
static ExplodedControlFlowGraph
void
void
removeEdge
(IExplodedBasicBlock src, IExplodedBasicBlock dst) void
void
remove a node from this graphvoid
remove a node and all its incident edgesvoid
stream()
toString()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Method Details
-
make
-
entry
Description copied from interface:MinimalCFG
Return the entry basic block in the CFG- Specified by:
entry
in interfaceMinimalCFG<IExplodedBasicBlock>
-
exit
- Specified by:
exit
in interfaceMinimalCFG<IExplodedBasicBlock>
- Returns:
- the synthetic exit block for the cfg
-
getBlockForInstruction
- Specified by:
getBlockForInstruction
in interfaceControlFlowGraph<SSAInstruction,
IExplodedBasicBlock> - Parameters:
index
- an instruction index- Returns:
- the basic block which contains this instruction.
-
getCatchBlocks
- Specified by:
getCatchBlocks
in interfaceControlFlowGraph<SSAInstruction,
IExplodedBasicBlock> - Returns:
- the indices of the catch blocks, as a bit vector
-
getExceptionalPredecessors
Description copied from interface:MinimalCFG
The order of blocks returned should be arbitrary but deterministic.- Specified by:
getExceptionalPredecessors
in interfaceMinimalCFG<IExplodedBasicBlock>
- Returns:
- the basic blocks from which b may be reached via exceptional control flow
-
getExceptionalSuccessors
Description copied from interface:MinimalCFG
The order of blocks returned must indicate the exception-handling scope. So the first block is the first candidate catch block, and so on. With this invariant one can compute the exceptional control flow for a given exception type.- Specified by:
getExceptionalSuccessors
in interfaceMinimalCFG<IExplodedBasicBlock>
- Returns:
- the basic blocks which may be reached from b via exceptional control flow
-
getInstructions
- Specified by:
getInstructions
in interfaceControlFlowGraph<SSAInstruction,
IExplodedBasicBlock> - Returns:
- the instructions of this CFG, as an array.
-
getMethod
- Specified by:
getMethod
in interfaceControlFlowGraph<SSAInstruction,
IExplodedBasicBlock> - Returns:
- the Method this CFG represents
- Throws:
UnimplementedError
-
getNormalPredecessors
Description copied from interface:MinimalCFG
The order of blocks returned should be arbitrary but deterministic.- Specified by:
getNormalPredecessors
in interfaceMinimalCFG<IExplodedBasicBlock>
- Returns:
- the basic blocks from which b may be reached via normal control flow
-
getNormalSuccessors
Description copied from interface:MinimalCFG
The order of blocks returned should be arbitrary but deterministic.- Specified by:
getNormalSuccessors
in interfaceMinimalCFG<IExplodedBasicBlock>
- Returns:
- the basic blocks which may be reached from b via normal control flow
-
getProgramCounter
Description copied from interface:ControlFlowGraph
TODO: move this into IR?- Specified by:
getProgramCounter
in interfaceControlFlowGraph<SSAInstruction,
IExplodedBasicBlock> - Parameters:
index
- an instruction index- Returns:
- the program counter (bytecode index) corresponding to that instruction
- Throws:
UnimplementedError
-
removeNodeAndEdges
Description copied from interface:Graph
remove a node and all its incident edges- Specified by:
removeNodeAndEdges
in interfaceGraph<IExplodedBasicBlock>
- Throws:
UnsupportedOperationException
- if the graph implementation does not allow removal
-
addNode
Description copied from interface:NodeManager
add a node to this graph- Specified by:
addNode
in interfaceNodeManager<IExplodedBasicBlock>
- Throws:
UnsupportedOperationException
-
containsNode
- Specified by:
containsNode
in interfaceNodeManager<IExplodedBasicBlock>
- Returns:
- true iff the graph contains the specified node
-
getNumberOfNodes
public int getNumberOfNodes()- Specified by:
getNumberOfNodes
in interfaceNodeManager<IExplodedBasicBlock>
- Returns:
- the number of nodes in this graph
-
iterator
- Specified by:
iterator
in interfaceIterable<IExplodedBasicBlock>
- Specified by:
iterator
in interfaceNodeManager<IExplodedBasicBlock>
- Returns:
- an
Iterator
of the nodes in this graph
-
stream
- Specified by:
stream
in interfaceNodeManager<IExplodedBasicBlock>
- Returns:
- a
Stream
of the nodes in this graph
-
removeNode
Description copied from interface:NodeManager
remove a node from this graph- Specified by:
removeNode
in interfaceNodeManager<IExplodedBasicBlock>
- Throws:
UnsupportedOperationException
-
addEdge
public void addEdge(IExplodedBasicBlock src, IExplodedBasicBlock dst) throws UnsupportedOperationException - Specified by:
addEdge
in interfaceEdgeManager<IExplodedBasicBlock>
- Throws:
UnsupportedOperationException
-
getPredNodeCount
Description copied from interface:EdgeManager
Return the number ofimmediate predecessor
nodes of n- Specified by:
getPredNodeCount
in interfaceEdgeManager<IExplodedBasicBlock>
- Returns:
- the number of immediate predecessors of n.
- Throws:
IllegalArgumentException
-
getPredNodes
public Iterator<IExplodedBasicBlock> getPredNodes(IExplodedBasicBlock bb) throws IllegalArgumentException Description copied from interface:EdgeManager
Return anIterator
over the immediate predecessor nodes of nThis method never returns
null
.- Specified by:
getPredNodes
in interfaceEdgeManager<IExplodedBasicBlock>
- Returns:
- an
Iterator
over the immediate predecessor nodes of this Node. - Throws:
IllegalArgumentException
-
getSuccNodeCount
Description copied from interface:EdgeManager
Return the number ofimmediate successor
nodes of this Node in the Graph- Specified by:
getSuccNodeCount
in interfaceEdgeManager<IExplodedBasicBlock>
- Returns:
- the number of immediate successor Nodes of this Node in the Graph.
- Throws:
UnimplementedError
-
getSuccNodes
Description copied from interface:EdgeManager
Return an Iterator over the immediate successor nodes of nThis method never returns
null
.- Specified by:
getSuccNodes
in interfaceEdgeManager<IExplodedBasicBlock>
- Returns:
- an Iterator over the immediate successor nodes of n
- See Also:
-
hasEdge
- Specified by:
hasEdge
in interfaceEdgeManager<IExplodedBasicBlock>
- Throws:
UnimplementedError
-
removeAllIncidentEdges
- Specified by:
removeAllIncidentEdges
in interfaceEdgeManager<IExplodedBasicBlock>
- Throws:
UnsupportedOperationException
-
removeEdge
public void removeEdge(IExplodedBasicBlock src, IExplodedBasicBlock dst) throws UnsupportedOperationException - Specified by:
removeEdge
in interfaceEdgeManager<IExplodedBasicBlock>
- Throws:
UnsupportedOperationException
-
removeIncomingEdges
- Specified by:
removeIncomingEdges
in interfaceEdgeManager<IExplodedBasicBlock>
- Throws:
UnsupportedOperationException
-
removeOutgoingEdges
- Specified by:
removeOutgoingEdges
in interfaceEdgeManager<IExplodedBasicBlock>
- Throws:
UnsupportedOperationException
-
getMaxNumber
public int getMaxNumber()- Specified by:
getMaxNumber
in interfaceNumberedNodeManager<IExplodedBasicBlock>
-
getNode
- Specified by:
getNode
in interfaceNumberedNodeManager<IExplodedBasicBlock>
-
getNumber
- Specified by:
getNumber
in interfaceNumberedNodeManager<IExplodedBasicBlock>
- Throws:
IllegalArgumentException
-
iterateNodes
- Specified by:
iterateNodes
in interfaceNumberedNodeManager<IExplodedBasicBlock>
- Returns:
- iterator of nodes with the numbers in set s
- Throws:
UnimplementedError
-
getPredNodeNumbers
- Specified by:
getPredNodeNumbers
in interfaceNumberedEdgeManager<IExplodedBasicBlock>
- Returns:
- the numbers identifying the immediate predecessors of node
-
getSuccNodeNumbers
- Specified by:
getSuccNodeNumbers
in interfaceNumberedEdgeManager<IExplodedBasicBlock>
- Returns:
- the numbers identifying the immediate successors of node
- Throws:
UnimplementedError
-
toString
-
getIR
-