Class BaseCallGraph
- java.lang.Object
-
- it.unive.lisa.util.datastructures.graph.Graph<BaseCallGraph,CallGraphNode,CallGraphEdge>
-
- it.unive.lisa.interprocedural.callgraph.BaseCallGraph
-
- All Implemented Interfaces:
CallGraph
public abstract class BaseCallGraph extends Graph<BaseCallGraph,CallGraphNode,CallGraphEdge> implements CallGraph
An instance ofCallGraphthat provides the basic mechanism to resolveUnresolvedCalls.
The graph underlying this call graph is built lazily through each call to resolve: querying for information about the graph before the completion of the analysis might lead to wrong results.
-
-
Field Summary
-
Fields inherited from class it.unive.lisa.util.datastructures.graph.Graph
adjacencyMatrix, entrypoints
-
-
Constructor Summary
Constructors Constructor Description BaseCallGraph()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description java.util.Collection<CodeMember>getCallees(CodeMember cm)Yields all theCodeMembers that are called by the given one.java.util.Collection<CodeMember>getCallers(CodeMember cm)Yields all theCodeMembers that call the given one.java.util.Collection<Call>getCallSites(CodeMember cm)Yields all theCalls that targets the givenCodeMember.protected abstract java.util.Collection<Type>getPossibleTypesOfReceiver(Expression receiver)Returns all the possible types of the given expression, that is a receiver of a method call.voidinit(Program program)Initializes the call graph of the given program.voidregisterCall(CFGCall call)Callresolve(UnresolvedCall call)Yields aCallimplementation that corresponds to the resolution of the givenUnresolvedCall.protected DotGraph<CallGraphNode,CallGraphEdge,BaseCallGraph>toDot(java.util.function.Function<CallGraphNode,java.lang.String> labelGenerator)Converts this graph to aDotGraphinstance.-
Methods inherited from class it.unive.lisa.util.datastructures.graph.Graph
accept, addEdge, addNode, addNode, dump, dump, followersOf, getAdjacencyMatrix, getEdgeConnecting, getEdges, getEdgesCount, getEntrypoints, getIngoingEdges, getNodes, getNodesCount, getOutgoingEdges, isEqualTo, predecessorsOf, preSimplify, simplify, toString
-
-
-
-
Method Detail
-
init
public final void init(Program program) throws CallGraphConstructionException
Description copied from interface:CallGraphInitializes the call graph of the given program.- Specified by:
initin interfaceCallGraph- Parameters:
program- the program to analyze- Throws:
CallGraphConstructionException- if an exception happens while building the call graph
-
registerCall
public void registerCall(CFGCall call)
Description copied from interface:CallGraph- Specified by:
registerCallin interfaceCallGraph- Parameters:
call- the call to register
-
resolve
public final Call resolve(UnresolvedCall call) throws CallResolutionException
Description copied from interface:CallGraphYields aCallimplementation that corresponds to the resolution of the givenUnresolvedCall.- Specified by:
resolvein interfaceCallGraph- Parameters:
call- the call to resolve- Returns:
- a collection of all the possible runtime targets
- Throws:
CallResolutionException- if this call graph is unable to resolve the given call
-
getPossibleTypesOfReceiver
protected abstract java.util.Collection<Type> getPossibleTypesOfReceiver(Expression receiver) throws CallResolutionException
Returns all the possible types of the given expression, that is a receiver of a method call. How we choose this set varies from the call graph algorithm we decide to adopt (e.g., CHA, RTA, 0-CFA, ...)- Parameters:
receiver- an expression- Returns:
- the possible types of the given expression
- Throws:
CallResolutionException- if the types cannot be computed
-
getCallees
public java.util.Collection<CodeMember> getCallees(CodeMember cm)
Description copied from interface:CallGraphYields all theCodeMembers that are called by the given one. The returned collection might contain partial results if this call graph is not fully built.- Specified by:
getCalleesin interfaceCallGraph- Parameters:
cm- the target code member- Returns:
- the collection of called code members
-
getCallers
public java.util.Collection<CodeMember> getCallers(CodeMember cm)
Description copied from interface:CallGraphYields all theCodeMembers that call the given one. The returned collection might contain partial results if this call graph is not fully built.- Specified by:
getCallersin interfaceCallGraph- Parameters:
cm- the target code member- Returns:
- the collection of callers code members
-
getCallSites
public java.util.Collection<Call> getCallSites(CodeMember cm)
Description copied from interface:CallGraphYields all theCalls that targets the givenCodeMember. The returned collection might contain partial results if this call graph is not fully built.- Specified by:
getCallSitesin interfaceCallGraph- Parameters:
cm- the target code member- Returns:
- the collection of calls that target the code member
-
toDot
protected DotGraph<CallGraphNode,CallGraphEdge,BaseCallGraph> toDot(java.util.function.Function<CallGraphNode,java.lang.String> labelGenerator)
Description copied from class:GraphConverts this graph to aDotGraphinstance.- Specified by:
toDotin classGraph<BaseCallGraph,CallGraphNode,CallGraphEdge>- Parameters:
labelGenerator- the generator that theDotGraphwill use to enrich node labels- Returns:
- the converted
DotGraph
-
-