Class BasicCallGraph<T>
java.lang.Object
com.ibm.wala.util.graph.AbstractGraph<CGNode>
com.ibm.wala.util.graph.AbstractNumberedGraph<CGNode>
com.ibm.wala.ipa.callgraph.impl.BasicCallGraph<T>
- All Implemented Interfaces:
CallGraph
,EdgeManager<CGNode>
,Graph<CGNode>
,NodeManager<CGNode>
,NumberedEdgeManager<CGNode>
,NumberedGraph<CGNode>
,NumberedNodeManager<CGNode>
,Iterable<CGNode>
- Direct Known Subclasses:
CHACallGraph
,ExplicitCallGraph
Basic data structure support for a call graph.
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static final class
static class
A class that represents the a normal node in a call graph. -
Field Summary
Modifier and TypeFieldDescriptionprotected final Map
<MethodReference, Set<CGNode>> A mapping from MethodReference to Set of nodes that represent this methodReference. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
This implementation is necessary because the underlying SparseNumberedGraph may not support node membership tests.abstract CGNode
findOrCreateNode
(IMethod method, Context C) Use with extreme care.Note: not all successors of the root node are entrypointsReturn the (fake) interproceduralroot node
of the call graph.protected T
getInterpreter
(CGNode node) If you want to get all the nodes corresponding to a particular method, regardless of context, then usegetNodes
protected CGNode
protected NumberedNodeManager
<CGNode> int
We override this since this class supports remove() on nodes, but the superclass doesn't.void
init()
iterator()
We override this since this class supports remove() on nodes, but the superclass doesn't.protected abstract CGNode
protected abstract CGNode
static String
nodeToString
(CallGraph CG, CGNode n) void
registerEntrypoint
(CGNode node) record that a node is an entrypointprotected void
void
remove a node and all its incident edgesvoid
setInterpreter
(T interpreter) void
toString()
Methods inherited from class com.ibm.wala.util.graph.AbstractNumberedGraph
getEdgeManager, getMaxNumber, getNode, getNumber, getPredNodeNumbers, getSuccNodeNumbers, iterateNodes
Methods inherited from class com.ibm.wala.util.graph.AbstractGraph
addEdge, addNode, edgeString, getPredNodeCount, getPredNodes, getSuccNodeCount, getSuccNodes, hasEdge, nodeString, removeAllIncidentEdges, removeEdge, removeIncomingEdges, removeNode, removeOutgoingEdges, stream
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.ibm.wala.ipa.callgraph.CallGraph
getClassHierarchy, getNumberOfTargets, getPossibleSites, getPossibleTargets
Methods inherited from interface com.ibm.wala.util.graph.EdgeManager
addEdge, getPredNodeCount, getPredNodes, getSuccNodeCount, getSuccNodes, hasEdge, removeAllIncidentEdges, removeEdge, removeIncomingEdges, removeOutgoingEdges
Methods inherited from interface java.lang.Iterable
forEach, spliterator
Methods inherited from interface com.ibm.wala.util.graph.NodeManager
addNode, removeNode, stream
Methods inherited from interface com.ibm.wala.util.graph.NumberedEdgeManager
getPredNodeNumbers, getSuccNodeNumbers
Methods inherited from interface com.ibm.wala.util.graph.NumberedNodeManager
getMaxNumber, getNode, getNumber, iterateNodes
-
Field Details
-
mr2Nodes
A mapping from MethodReference to Set of nodes that represent this methodReference.TODO: rhs of mapping doesn't have to be a set if it's a singleton; could be a node instead.
TODO: this is a bit redundant with the nodes Map. Restructure these data structures for space efficiency.
-
-
Constructor Details
-
BasicCallGraph
public BasicCallGraph()
-
-
Method Details
-
init
- Throws:
CancelException
-
makeFakeRootNode
- Throws:
CancelException
-
makeFakeWorldClinitNode
- Throws:
CancelException
-
findOrCreateNode
Use with extreme care.- Throws:
CancelException
- TODO
-
registerNode
-
getNode
-
getFakeRootNode
Description copied from interface:CallGraph
Return the (fake) interproceduralroot node
of the call graph.- Specified by:
getFakeRootNode
in interfaceCallGraph
- Returns:
- the "fake" root node the call graph
-
getFakeWorldClinitNode
- Specified by:
getFakeWorldClinitNode
in interfaceCallGraph
-
registerEntrypoint
record that a node is an entrypoint -
getEntrypointNodes
Note: not all successors of the root node are entrypoints- Specified by:
getEntrypointNodes
in interfaceCallGraph
- Returns:
- an Iterator of the nodes designated as "root nodes"
-
toString
- Overrides:
toString
in classAbstractGraph<CGNode>
-
nodeToString
-
removeNodeAndEdges
Description copied from interface:Graph
remove a node and all its incident edges- Specified by:
removeNodeAndEdges
in interfaceGraph<T>
- Overrides:
removeNodeAndEdges
in classAbstractGraph<CGNode>
- Throws:
UnimplementedError
- See Also:
-
getNode
-
getNodes
-
getInterpreter
-
getNumberOfNodes
public int getNumberOfNodes()We override this since this class supports remove() on nodes, but the superclass doesn't.- Specified by:
getNumberOfNodes
in interfaceNodeManager<T>
- Overrides:
getNumberOfNodes
in classAbstractGraph<CGNode>
- Returns:
- the number of nodes in this graph
- See Also:
-
iterator
We override this since this class supports remove() on nodes, but the superclass doesn't.- Specified by:
iterator
in interfaceIterable<T>
- Specified by:
iterator
in interfaceNodeManager<T>
- Overrides:
iterator
in classAbstractGraph<CGNode>
- Returns:
- an
Iterator
of the nodes in this graph - See Also:
-
containsNode
This implementation is necessary because the underlying SparseNumberedGraph may not support node membership tests.- Specified by:
containsNode
in interfaceNodeManager<T>
- Overrides:
containsNode
in classAbstractGraph<CGNode>
- Returns:
- true iff the graph contains the specified node
- Throws:
IllegalArgumentException
- if N is null- See Also:
-
setInterpreter
-
getNodeManager
- Specified by:
getNodeManager
in classAbstractNumberedGraph<CGNode>
- Returns:
- the object which manages nodes in the graph
-
summarizeByPackage
public void summarizeByPackage()
-