Class BackwardsSupergraph<T,P>
java.lang.Object
com.ibm.wala.dataflow.IFDS.BackwardsSupergraph<T,P>
- All Implemented Interfaces:
ISupergraph<T,P>, EdgeManager<T>, Graph<T>, NodeManager<T>, NumberedEdgeManager<T>, NumberedGraph<T>, NumberedNodeManager<T>, Iterable<T>
A "reversed" supergraph for backwards analysis.
In this view, a return is treated like a call, and vice-versa. All normal edges are reversed.
-
Field Summary
Fields inherited from interface ISupergraph
CALL_EDGE, CALL_TO_RETURN_EDGE, OTHER, RETURN_EDGE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidadd a node to this graphbyteclassifyEdge(T src, T dest) booleancontainsNode(T N) getCalledNodes(T ret) get the "called" (sic) nodes for a return site; i.e., the exit nodes that flow directly to this return site.getCallSites(T r, P callee) T[]getEntriesForProcedure(P object) T[]getExitsForProcedure(P object) getLocalBlock(P procedure, int i) intintgetNode(int number) getNormalSuccessors(T ret) get the "normal" successors (sic) for a return site; i.e., the "normal" CFG predecessors that are not call nodes.intintgetNumberOfBlocks(P procedure) intintReturn the number ofimmediate predecessornodes of ngetPredNodeNumbers(Object node) getPredNodes(T N) Return anIteratorover the immediate predecessor nodes of nTODO: for now, this is not inverted.getReturnSites(T c, P callee) intReturn the number ofimmediate successornodes of this Node in the GraphgetSuccNodeNumbers(T node) getSuccNodes(T N) Return an Iterator over the immediate successor nodes of nbooleanbooleanbooleanbooleanbooleaniterator()static <T,P> BackwardsSupergraph <T, P> make(ISupergraph<T, P> forwardGraph) voidremoveAllIncidentEdges(Object node) voidremoveEdge(Object src, Object dst) voidremoveIncomingEdges(Object node) voidremoveNode(Object n) remove a node from this graphvoidremove a node and all its incident edgesvoidremoveOutgoingEdges(T node) stream()toString()Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface Iterable
forEach, spliterator
-
Constructor Details
-
BackwardsSupergraph
- Parameters:
forwardGraph- the graph to ``reverse''
-
-
Method Details
-
make
-
getProcedureGraph
TODO: for now, this is not inverted.- Specified by:
getProcedureGraphin interfaceISupergraph<T,P> - Returns:
- the graph of procedures (e.g. a call graph) over which this supergraph is induced.
-
isCall
- Specified by:
isCallin interfaceISupergraph<T,P> - Parameters:
n- a node in this supergraph- Returns:
- true iff this node includes a call.
-
getCalledNodes
get the "called" (sic) nodes for a return site; i.e., the exit nodes that flow directly to this return site.- Specified by:
getCalledNodesin interfaceISupergraph<T,P> - Parameters:
ret- a "call" node in the supergraph- Returns:
- an Iterator of nodes that are targets of this call.
-
getNormalSuccessors
get the "normal" successors (sic) for a return site; i.e., the "normal" CFG predecessors that are not call nodes.- Specified by:
getNormalSuccessorsin interfaceISupergraph<T,P> - Parameters:
ret- a "call" node in the supergraph- Returns:
- an Iterator of nodes that are normal (non-call) successors of this call. This should only apply to backwards problems, where we might have, say, a call and a goto flow into a return site.
- See Also:
-
getReturnSites
- Specified by:
getReturnSitesin interfaceISupergraph<T,P> - Parameters:
c- a "call" node in the supergraphcallee- a "called" "procedure" in the supergraph. if callee is null, answer return sites for which no callee was found.- Returns:
- the corresponding return nodes. There may be many, because of exceptional control flow.
-
isExit
- Specified by:
isExitin interfaceISupergraph<T,P> - Parameters:
n- a node in the supergraph- Returns:
- true iff this node is an exit node
-
getProcOf
-
removeNodeAndEdges
Description copied from interface:Graphremove a node and all its incident edges- Specified by:
removeNodeAndEdgesin interfaceGraph<T>- Throws:
UnsupportedOperationException- if the graph implementation does not allow removal- See Also:
-
iterator
-
stream
-
getNumberOfNodes
public int getNumberOfNodes()- Specified by:
getNumberOfNodesin interfaceNodeManager<T>- Returns:
- the number of nodes in this graph
- See Also:
-
addNode
Description copied from interface:NodeManageradd a node to this graph- Specified by:
addNodein interfaceNodeManager<T>- Throws:
UnsupportedOperationException- See Also:
-
removeNode
Description copied from interface:NodeManagerremove a node from this graph- Specified by:
removeNodein interfaceNodeManager<T>- Throws:
UnsupportedOperationException- See Also:
-
containsNode
- Specified by:
containsNodein interfaceNodeManager<T>- Returns:
- true iff the graph contains the specified node
- See Also:
-
getPredNodes
Description copied from interface:EdgeManagerReturn anIteratorover the immediate predecessor nodes of nThis method never returns
null.- Specified by:
getPredNodesin interfaceEdgeManager<T>- Returns:
- an
Iteratorover the immediate predecessor nodes of this Node. - See Also:
-
getPredNodeCount
Description copied from interface:EdgeManagerReturn the number ofimmediate predecessornodes of n- Specified by:
getPredNodeCountin interfaceEdgeManager<T>- Returns:
- the number of immediate predecessors of n.
- See Also:
-
getSuccNodes
Description copied from interface:EdgeManagerReturn an Iterator over the immediate successor nodes of nThis method never returns
null.- Specified by:
getSuccNodesin interfaceEdgeManager<T>- Returns:
- an Iterator over the immediate successor nodes of n
- See Also:
-
hasEdge
- Specified by:
hasEdgein interfaceEdgeManager<T>
-
getSuccNodeCount
Description copied from interface:EdgeManagerReturn the number ofimmediate successornodes of this Node in the Graph- Specified by:
getSuccNodeCountin interfaceEdgeManager<T>- Returns:
- the number of immediate successor Nodes of this Node in the Graph.
- See Also:
-
addEdge
- Specified by:
addEdgein interfaceEdgeManager<T>- Throws:
UnsupportedOperationException- See Also:
-
removeEdge
- Specified by:
removeEdgein interfaceEdgeManager<T>- Throws:
UnsupportedOperationException
-
removeAllIncidentEdges
- Specified by:
removeAllIncidentEdgesin interfaceEdgeManager<T>- Throws:
UnsupportedOperationException- See Also:
-
getEntriesForProcedure
- Specified by:
getEntriesForProcedurein interfaceISupergraph<T,P> - Returns:
- the blocks in the supergraph that represents entry nodes for procedure p
-
getExitsForProcedure
- Specified by:
getExitsForProcedurein interfaceISupergraph<T,P> - Returns:
- the blocks in the supergraph that represents exit nodes for procedure p
- See Also:
-
isReturn
- Specified by:
isReturnin interfaceISupergraph<T,P> - Parameters:
n- a node in this supergraph- Returns:
- true iff this node is a return site.
- Throws:
UnimplementedError
-
getCallSites
- Specified by:
getCallSitesin interfaceISupergraph<T,P> - Parameters:
r- a "return" node in the supergraphcallee- a "called" "procedure" in the supergraph. if callee is null, answer return sites for which no callee was found.- Returns:
- the corresponding call nodes. There may be many.
-
isEntry
- Specified by:
isEntryin interfaceISupergraph<T,P> - Returns:
- true iff this node is an entry node s_p for a procedure
-
classifyEdge
- Specified by:
classifyEdgein interfaceISupergraph<T,P> - Parameters:
src- node in the supergraphdest- a successor of src in the supergraph- Returns:
- one of CALL_EDGE, RETURN_EDGE, CALL_TO_RETURN_EDGE, or OTHER
-
toString
-
removeIncomingEdges
- Specified by:
removeIncomingEdgesin interfaceEdgeManager<T>- Throws:
UnsupportedOperationException
-
removeOutgoingEdges
- Specified by:
removeOutgoingEdgesin interfaceEdgeManager<T>- Throws:
UnsupportedOperationException
-
getNumberOfBlocks
- Specified by:
getNumberOfBlocksin interfaceISupergraph<T,P> - Parameters:
procedure- an object that represents a procedure- Returns:
- the number of blocks from this procedure in this supergraph
-
getLocalBlockNumber
- Specified by:
getLocalBlockNumberin interfaceISupergraph<T,P> - Parameters:
n- a node in the supergraph- Returns:
- the "logical" basic block number of n in its procedure
-
getLocalBlock
- Specified by:
getLocalBlockin interfaceISupergraph<T,P> - Parameters:
procedure- an object that represents a procedurei- the "logical" basic block number of a node in the procedure- Returns:
- the corresponding node in the supergraph
-
getNumber
- Specified by:
getNumberin interfaceNumberedNodeManager<T>
-
getNode
- Specified by:
getNodein interfaceNumberedNodeManager<T>
-
getMaxNumber
public int getMaxNumber()- Specified by:
getMaxNumberin interfaceNumberedNodeManager<T>
-
iterateNodes
- Specified by:
iterateNodesin interfaceNumberedNodeManager<T>- Returns:
- iterator of nodes with the numbers in set s
- Throws:
UnimplementedError
-
getSuccNodeNumbers
- Specified by:
getSuccNodeNumbersin interfaceNumberedEdgeManager<T>- Returns:
- the numbers identifying the immediate successors of node
-
getPredNodeNumbers
- Specified by:
getPredNodeNumbersin interfaceNumberedEdgeManager<T>- Returns:
- the numbers identifying the immediate predecessors of node
- Throws:
UnimplementedError
-