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:ControlFlowGraphReturn the entry basic block in the CFG- Specified by:
entryin interfaceControlFlowGraph<SSAInstruction,IExplodedBasicBlock>
-
exit
public IExplodedBasicBlock exit()
- Specified by:
exitin interfaceControlFlowGraph<SSAInstruction,IExplodedBasicBlock>- Returns:
- the synthetic exit block for the cfg
-
getBlockForInstruction
public IExplodedBasicBlock getBlockForInstruction(int index)
- Specified by:
getBlockForInstructionin interfaceControlFlowGraph<SSAInstruction,IExplodedBasicBlock>- Parameters:
index- an instruction index- Returns:
- the basic block which contains this instruction.
-
getCatchBlocks
public BitVector getCatchBlocks()
- Specified by:
getCatchBlocksin 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:ControlFlowGraphThe order of blocks returned should be arbitrary but deterministic.- Specified by:
getExceptionalPredecessorsin 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:ControlFlowGraphThe 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:
getExceptionalSuccessorsin interfaceControlFlowGraph<SSAInstruction,IExplodedBasicBlock>- Returns:
- the basic blocks which may be reached from b via exceptional control flow
-
getInstructions
public SSAInstruction[] getInstructions()
- Specified by:
getInstructionsin interfaceControlFlowGraph<SSAInstruction,IExplodedBasicBlock>- Returns:
- the instructions of this CFG, as an array.
-
getMethod
public IMethod getMethod() throws UnimplementedError
- Specified by:
getMethodin interfaceControlFlowGraph<SSAInstruction,IExplodedBasicBlock>- Returns:
- the Method this CFG represents
- Throws:
UnimplementedError
-
getNormalPredecessors
public Collection<IExplodedBasicBlock> getNormalPredecessors(IExplodedBasicBlock bb)
Description copied from interface:ControlFlowGraphThe order of blocks returned should be arbitrary but deterministic.- Specified by:
getNormalPredecessorsin 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:ControlFlowGraphThe order of blocks returned should be arbitrary but deterministic.- Specified by:
getNormalSuccessorsin interfaceControlFlowGraph<SSAInstruction,IExplodedBasicBlock>- Returns:
- the basic blocks which may be reached from b via normal control flow
-
getProgramCounter
public int getProgramCounter(int index) throws UnimplementedErrorDescription copied from interface:ControlFlowGraphTODO: move this into IR?- Specified by:
getProgramCounterin 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:Graphremove a node and all its incident edges- Specified by:
removeNodeAndEdgesin interfaceGraph<IExplodedBasicBlock>- Throws:
UnsupportedOperationException- if the graph implementation does not allow removal
-
addNode
public void addNode(IExplodedBasicBlock n) throws UnsupportedOperationException
Description copied from interface:NodeManageradd a node to this graph- Specified by:
addNodein interfaceNodeManager<IExplodedBasicBlock>- Throws:
UnsupportedOperationException
-
containsNode
public boolean containsNode(IExplodedBasicBlock N)
- Specified by:
containsNodein interfaceNodeManager<IExplodedBasicBlock>- Returns:
- true iff the graph contains the specified node
-
getNumberOfNodes
public int getNumberOfNodes()
- Specified by:
getNumberOfNodesin interfaceNodeManager<IExplodedBasicBlock>- Returns:
- the number of nodes in this graph
-
iterator
public Iterator<IExplodedBasicBlock> iterator()
- Specified by:
iteratorin interfaceIterable<IExplodedBasicBlock>- Specified by:
iteratorin interfaceNodeManager<IExplodedBasicBlock>- Returns:
- an
Iteratorof the nodes in this graph
-
removeNode
public void removeNode(IExplodedBasicBlock n) throws UnsupportedOperationException
Description copied from interface:NodeManagerremove a node from this graph- Specified by:
removeNodein interfaceNodeManager<IExplodedBasicBlock>- Throws:
UnsupportedOperationException
-
addEdge
public void addEdge(IExplodedBasicBlock src, IExplodedBasicBlock dst) throws UnsupportedOperationException
- Specified by:
addEdgein interfaceEdgeManager<IExplodedBasicBlock>- Throws:
UnsupportedOperationException
-
getPredNodeCount
public int getPredNodeCount(IExplodedBasicBlock bb) throws IllegalArgumentException
Description copied from interface:EdgeManagerReturn the number ofimmediate predecessornodes of n- Specified by:
getPredNodeCountin 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:EdgeManagerReturn anIteratorover the immediate predecessor nodes of n This method never returnsnull.- Specified by:
getPredNodesin interfaceEdgeManager<IExplodedBasicBlock>- Returns:
- an
Iteratorover the immediate predecessor nodes of this Node. - Throws:
IllegalArgumentException
-
getSuccNodeCount
public int getSuccNodeCount(IExplodedBasicBlock N) throws UnimplementedError
Description copied from interface:EdgeManagerReturn the number ofimmediate successornodes of this Node in the Graph- Specified by:
getSuccNodeCountin 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:EdgeManagerReturn an Iterator over the immediate successor nodes of nThis method never returns
null.- Specified by:
getSuccNodesin interfaceEdgeManager<IExplodedBasicBlock>- Returns:
- an Iterator over the immediate successor nodes of n
-
hasEdge
public boolean hasEdge(IExplodedBasicBlock src, IExplodedBasicBlock dst) throws UnimplementedError
- Specified by:
hasEdgein interfaceEdgeManager<IExplodedBasicBlock>- Throws:
UnimplementedError
-
removeAllIncidentEdges
public void removeAllIncidentEdges(IExplodedBasicBlock node) throws UnsupportedOperationException
- Specified by:
removeAllIncidentEdgesin interfaceEdgeManager<IExplodedBasicBlock>- Throws:
UnsupportedOperationException
-
removeEdge
public void removeEdge(IExplodedBasicBlock src, IExplodedBasicBlock dst) throws UnsupportedOperationException
- Specified by:
removeEdgein interfaceEdgeManager<IExplodedBasicBlock>- Throws:
UnsupportedOperationException
-
removeIncomingEdges
public void removeIncomingEdges(IExplodedBasicBlock node) throws UnsupportedOperationException
- Specified by:
removeIncomingEdgesin interfaceEdgeManager<IExplodedBasicBlock>- Throws:
UnsupportedOperationException
-
removeOutgoingEdges
public void removeOutgoingEdges(IExplodedBasicBlock node) throws UnsupportedOperationException
- Specified by:
removeOutgoingEdgesin interfaceEdgeManager<IExplodedBasicBlock>- Throws:
UnsupportedOperationException
-
getMaxNumber
public int getMaxNumber()
- Specified by:
getMaxNumberin interfaceNumberedNodeManager<IExplodedBasicBlock>
-
getNode
public IExplodedBasicBlock getNode(int number)
- Specified by:
getNodein interfaceNumberedNodeManager<IExplodedBasicBlock>
-
getNumber
public int getNumber(IExplodedBasicBlock n) throws IllegalArgumentException
- Specified by:
getNumberin interfaceNumberedNodeManager<IExplodedBasicBlock>- Throws:
IllegalArgumentException
-
iterateNodes
public Iterator<IExplodedBasicBlock> iterateNodes(IntSet s) throws UnimplementedError
- Specified by:
iterateNodesin interfaceNumberedNodeManager<IExplodedBasicBlock>- Returns:
- iterator of nodes with the numbers in set s
- Throws:
UnimplementedError
-
getPredNodeNumbers
public IntSet getPredNodeNumbers(IExplodedBasicBlock node)
- Specified by:
getPredNodeNumbersin interfaceNumberedEdgeManager<IExplodedBasicBlock>- Returns:
- the numbers identifying the immediate predecessors of node
-
getSuccNodeNumbers
public IntSet getSuccNodeNumbers(IExplodedBasicBlock node) throws UnimplementedError
- Specified by:
getSuccNodeNumbersin interfaceNumberedEdgeManager<IExplodedBasicBlock>- Returns:
- the numbers identifying the immediate successors of node
- Throws:
UnimplementedError
-
getIR
public IR getIR()
-
-