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
Nested ClassesModifier and TypeClassDescriptionprotected static final classstatic classA class that represents the a normal node in a call graph. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Map<MethodReference, Set<CGNode>> A mapping from MethodReference to Set of nodes that represent this methodReference. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanThis implementation is necessary because the underlying SparseNumberedGraph may not support node membership tests.abstract CGNodefindOrCreateNode(IMethod method, Context C) Use with extreme care.Note: not all successors of the root node are entrypointsReturn the (fake) interproceduralroot nodeof the call graph.protected TgetInterpreter(CGNode node) If you want to get all the nodes corresponding to a particular method, regardless of context, then usegetNodesprotected CGNodeprotected NumberedNodeManager<CGNode> intWe override this since this class supports remove() on nodes, but the superclass doesn't.voidinit()iterator()We override this since this class supports remove() on nodes, but the superclass doesn't.protected abstract CGNodeprotected abstract CGNodestatic StringnodeToString(CallGraph CG, CGNode n) voidregisterEntrypoint(CGNode node) record that a node is an entrypointprotected voidvoidremove a node and all its incident edgesvoidsetInterpreter(T interpreter) voidtoString()Methods inherited from class AbstractNumberedGraph
getEdgeManager, getMaxNumber, getNode, getNumber, getPredNodeNumbers, getSuccNodeNumbers, iterateNodesMethods inherited from class AbstractGraph
addEdge, addNode, edgeString, getPredNodeCount, getPredNodes, getSuccNodeCount, getSuccNodes, hasEdge, nodeString, removeAllIncidentEdges, removeEdge, removeIncomingEdges, removeNode, removeOutgoingEdges, streamMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface CallGraph
getClassHierarchy, getNumberOfTargets, getPossibleSites, getPossibleTargetsMethods inherited from interface EdgeManager
addEdge, getPredNodeCount, getPredNodes, getSuccNodeCount, getSuccNodes, hasEdge, removeAllIncidentEdges, removeEdge, removeIncomingEdges, removeOutgoingEdgesMethods inherited from interface Iterable
forEach, spliteratorMethods inherited from interface NodeManager
addNode, removeNode, streamMethods inherited from interface NumberedEdgeManager
getPredNodeNumbers, getSuccNodeNumbersMethods inherited from interface 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:CallGraphReturn the (fake) interproceduralroot nodeof the call graph.- Specified by:
getFakeRootNodein interfaceCallGraph- Returns:
- the "fake" root node the call graph
-
getFakeWorldClinitNode
- Specified by:
getFakeWorldClinitNodein interfaceCallGraph
-
registerEntrypoint
record that a node is an entrypoint -
getEntrypointNodes
Note: not all successors of the root node are entrypoints- Specified by:
getEntrypointNodesin interfaceCallGraph- Returns:
- an Iterator of the nodes designated as "root nodes"
-
toString
- Overrides:
toStringin classAbstractGraph<CGNode>
-
nodeToString
-
removeNodeAndEdges
Description copied from interface:Graphremove a node and all its incident edges- Specified by:
removeNodeAndEdgesin interfaceGraph<T>- Overrides:
removeNodeAndEdgesin 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:
getNumberOfNodesin interfaceNodeManager<T>- Overrides:
getNumberOfNodesin 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:
iteratorin interfaceIterable<T>- Specified by:
iteratorin interfaceNodeManager<T>- Overrides:
iteratorin classAbstractGraph<CGNode>- Returns:
- an
Iteratorof the nodes in this graph - See Also:
-
containsNode
This implementation is necessary because the underlying SparseNumberedGraph may not support node membership tests.- Specified by:
containsNodein interfaceNodeManager<T>- Overrides:
containsNodein classAbstractGraph<CGNode>- Returns:
- true iff the graph contains the specified node
- Throws:
IllegalArgumentException- if N is null- See Also:
-
setInterpreter
-
getNodeManager
- Specified by:
getNodeManagerin classAbstractNumberedGraph<CGNode>- Returns:
- the object which manages nodes in the graph
-
summarizeByPackage
public void summarizeByPackage()
-