Package com.ibm.wala.ssa.analysis
Class ExplodedControlFlowGraph
- java.lang.Object
-
- com.ibm.wala.ssa.analysis.ExplodedControlFlowGraph
-
- All Implemented Interfaces:
ControlFlowGraph<SSAInstruction,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
-
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 Detail
-
make
public static ExplodedControlFlowGraph make(IR ir)
-
entry
public IExplodedBasicBlock entry()
Description copied from interface:ControlFlowGraph
Return the entry basic block in the CFG- Specified by:
entry
in interfaceControlFlowGraph<SSAInstruction,IExplodedBasicBlock>
-
exit
public IExplodedBasicBlock exit()
- Specified by:
exit
in interfaceControlFlowGraph<SSAInstruction,IExplodedBasicBlock>
- Returns:
- the synthetic exit block for the cfg
-
getBlockForInstruction
public IExplodedBasicBlock getBlockForInstruction(int index)
- Specified by:
getBlockForInstruction
in interfaceControlFlowGraph<SSAInstruction,IExplodedBasicBlock>
- Parameters:
index
- an instruction index- Returns:
- the basic block which contains this instruction.
-
getCatchBlocks
public BitVector getCatchBlocks()
- Specified by:
getCatchBlocks
in interfaceControlFlowGraph<SSAInstruction,IExplodedBasicBlock>
- Returns:
- the indices of the catch blocks, as a bit vector
-
getExceptionalPredecessors
public Collection<IExplodedBasicBlock> getExceptionalPredecessors(IExplodedBasicBlock bb)
Description copied from interface:ControlFlowGraph
The order of blocks returned should be arbitrary but deterministic.- Specified by:
getExceptionalPredecessors
in interfaceControlFlowGraph<SSAInstruction,IExplodedBasicBlock>
- Returns:
- the basic blocks from which b may be reached via exceptional control flow
-
getExceptionalSuccessors
public List<IExplodedBasicBlock> getExceptionalSuccessors(IExplodedBasicBlock bb)
Description copied from interface:ControlFlowGraph
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 interfaceControlFlowGraph<SSAInstruction,IExplodedBasicBlock>
- Returns:
- the basic blocks which may be reached from b via exceptional control flow
-
getInstructions
public SSAInstruction[] getInstructions()
- Specified by:
getInstructions
in interfaceControlFlowGraph<SSAInstruction,IExplodedBasicBlock>
- Returns:
- the instructions of this CFG, as an array.
-
getMethod
public IMethod getMethod() throws UnimplementedError
- Specified by:
getMethod
in interfaceControlFlowGraph<SSAInstruction,IExplodedBasicBlock>
- Returns:
- the Method this CFG represents
- Throws:
UnimplementedError
-
getNormalPredecessors
public Collection<IExplodedBasicBlock> getNormalPredecessors(IExplodedBasicBlock bb)
Description copied from interface:ControlFlowGraph
The order of blocks returned should be arbitrary but deterministic.- Specified by:
getNormalPredecessors
in interfaceControlFlowGraph<SSAInstruction,IExplodedBasicBlock>
- Returns:
- the basic blocks from which b may be reached via normal control flow
-
getNormalSuccessors
public Collection<IExplodedBasicBlock> getNormalSuccessors(IExplodedBasicBlock bb)
Description copied from interface:ControlFlowGraph
The order of blocks returned should be arbitrary but deterministic.- Specified by:
getNormalSuccessors
in interfaceControlFlowGraph<SSAInstruction,IExplodedBasicBlock>
- Returns:
- the basic blocks which may be reached from b via normal control flow
-
getProgramCounter
public int getProgramCounter(int index) throws UnimplementedError
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
public void removeNodeAndEdges(IExplodedBasicBlock N) throws UnsupportedOperationException
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
public void addNode(IExplodedBasicBlock n) throws UnsupportedOperationException
Description copied from interface:NodeManager
add a node to this graph- Specified by:
addNode
in interfaceNodeManager<IExplodedBasicBlock>
- Throws:
UnsupportedOperationException
-
containsNode
public boolean containsNode(IExplodedBasicBlock N)
- 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
public Iterator<IExplodedBasicBlock> iterator()
- Specified by:
iterator
in interfaceIterable<IExplodedBasicBlock>
- Specified by:
iterator
in interfaceNodeManager<IExplodedBasicBlock>
- Returns:
- an
Iterator
of the nodes in this graph
-
removeNode
public void removeNode(IExplodedBasicBlock n) throws UnsupportedOperationException
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
public int getPredNodeCount(IExplodedBasicBlock bb) throws IllegalArgumentException
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 n This method never returnsnull
.- Specified by:
getPredNodes
in interfaceEdgeManager<IExplodedBasicBlock>
- Returns:
- an
Iterator
over the immediate predecessor nodes of this Node. - Throws:
IllegalArgumentException
-
getSuccNodeCount
public int getSuccNodeCount(IExplodedBasicBlock N) throws UnimplementedError
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
public Iterator<IExplodedBasicBlock> getSuccNodes(IExplodedBasicBlock bb)
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
-
hasEdge
public boolean hasEdge(IExplodedBasicBlock src, IExplodedBasicBlock dst) throws UnimplementedError
- Specified by:
hasEdge
in interfaceEdgeManager<IExplodedBasicBlock>
- Throws:
UnimplementedError
-
removeAllIncidentEdges
public void removeAllIncidentEdges(IExplodedBasicBlock node) throws UnsupportedOperationException
- 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
public void removeIncomingEdges(IExplodedBasicBlock node) throws UnsupportedOperationException
- Specified by:
removeIncomingEdges
in interfaceEdgeManager<IExplodedBasicBlock>
- Throws:
UnsupportedOperationException
-
removeOutgoingEdges
public void removeOutgoingEdges(IExplodedBasicBlock node) throws UnsupportedOperationException
- Specified by:
removeOutgoingEdges
in interfaceEdgeManager<IExplodedBasicBlock>
- Throws:
UnsupportedOperationException
-
getMaxNumber
public int getMaxNumber()
- Specified by:
getMaxNumber
in interfaceNumberedNodeManager<IExplodedBasicBlock>
-
getNode
public IExplodedBasicBlock getNode(int number)
- Specified by:
getNode
in interfaceNumberedNodeManager<IExplodedBasicBlock>
-
getNumber
public int getNumber(IExplodedBasicBlock n) throws IllegalArgumentException
- Specified by:
getNumber
in interfaceNumberedNodeManager<IExplodedBasicBlock>
- Throws:
IllegalArgumentException
-
iterateNodes
public Iterator<IExplodedBasicBlock> iterateNodes(IntSet s) throws UnimplementedError
- Specified by:
iterateNodes
in interfaceNumberedNodeManager<IExplodedBasicBlock>
- Returns:
- iterator of nodes with the numbers in set s
- Throws:
UnimplementedError
-
getPredNodeNumbers
public IntSet getPredNodeNumbers(IExplodedBasicBlock node)
- Specified by:
getPredNodeNumbers
in interfaceNumberedEdgeManager<IExplodedBasicBlock>
- Returns:
- the numbers identifying the immediate predecessors of node
-
getSuccNodeNumbers
public IntSet getSuccNodeNumbers(IExplodedBasicBlock node) throws UnimplementedError
- Specified by:
getSuccNodeNumbers
in interfaceNumberedEdgeManager<IExplodedBasicBlock>
- Returns:
- the numbers identifying the immediate successors of node
- Throws:
UnimplementedError
-
getIR
public IR getIR()
-
-