joeq.Compiler.Quad
Class CachedCallGraph

java.lang.Object
  extended by java.util.AbstractMap
      extended by jwutil.collections.UnmodifiableMultiMap
          extended by joeq.Compiler.Quad.CallGraph
              extended by joeq.Compiler.Quad.CachedCallGraph
All Implemented Interfaces:
Map, jwutil.collections.BinaryRelation, jwutil.collections.MultiMap, jwutil.graphs.Graph

public class CachedCallGraph
extends CallGraph

Version:
$Id: CachedCallGraph.java 1931 2004-09-22 22:17:47Z joewhaley $
Author:
John Whaley

Nested Class Summary
 
Nested classes/interfaces inherited from class joeq.Compiler.Quad.CallGraph
CallGraph.CallGraphCSNavigator, CallGraph.CallGraphMap, CallGraph.CallGraphMethodNavigator, CallGraph.CallSiteMap, CallGraph.CallTargetMap
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Field Summary
 
Fields inherited from class jwutil.collections.UnmodifiableMultiMap
DEFAULT_HISTOGRAM_SIZE
 
Constructor Summary
CachedCallGraph(CallGraph cg)
           
 
Method Summary
 Set entrySet()
           
 Collection getAllCallSites()
          Returns the collection of all call sites in the call graph.
 Collection getAllMethods()
          Returns the collection of all methods in the call graph.
 Collection getCallees(ControlFlowGraph cfg)
          Returns the set of methods that are called by the given CFG.
 Collection getCallees(jq_Method caller)
          Returns the set of methods that are called by the given method.
 Collection getCallerMethods(jq_Method callee)
          Returns the set of methods that can call the given method.
 Collection getCallers(jq_Method callee)
          Returns the set of call sites that can call the given method.
 Collection getCallSites(ControlFlowGraph cfg)
          Returns the set of call sites in the given CFG.
 Collection getCallSites(jq_Method caller)
          Returns the set of call sites in the given method.
static Collection getFromMultiMap(jwutil.collections.MultiMap m1, jwutil.collections.MultiMap m2, jq_Method method)
           
 Collection getRoots()
          Returns the collection of root methods for this call graph.
 Collection getTargetMethods(Object context, ProgramLocation callSite)
          Returns the possible target methods of the given call site under the given context.
 void inlineEdge(jq_Method caller, ProgramLocation callSite, jq_Method callee)
          Inline the given edge in the call graph.
 void invalidateCache()
           
 Set keySet()
           
 void setRoots(Collection roots)
          Sets up the root methods to be the given set.
 
Methods inherited from class joeq.Compiler.Quad.CallGraph
calculateCallerRelation, calculateEdgeRelation, calculateReachableMethods, contains, findDepths, getCallGraphMap, getCallSiteMap, getCallSiteNavigator, getCallSites0, getCallSites0, getCallSites1, getMethodNavigator, getNavigator, getTargetMethod, getTargetMethods, getValues, makeCallGraph, numberOfTargetMethods, numberOfTargetMethods, toString
 
Methods inherited from class jwutil.collections.UnmodifiableMultiMap
add, addAll, addAll, clear, computeHistogram, computeHistogram, entrySetHelper, proxy, put, putAll, remove, remove, removeAll, retainAll
 
Methods inherited from class java.util.AbstractMap
clone, containsKey, containsValue, equals, get, hashCode, isEmpty, size, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface jwutil.collections.MultiMap
get, size
 
Methods inherited from interface java.util.Map
containsKey, containsValue, equals, hashCode, isEmpty, values
 

Constructor Detail

CachedCallGraph

public CachedCallGraph(CallGraph cg)
Method Detail

invalidateCache

public void invalidateCache()

setRoots

public void setRoots(Collection roots)
Description copied from class: CallGraph
Sets up the root methods to be the given set. Later call graph queries use the value that you pass in here. Implementing this method is optional -- it is only necessary if you use methods that require a root set, like getReachableMethods().

Specified by:
setRoots in class CallGraph
Parameters:
roots - collection of root methods

entrySet

public Set entrySet()
Specified by:
entrySet in interface Map
Specified by:
entrySet in interface jwutil.collections.MultiMap
Overrides:
entrySet in class CallGraph

getAllCallSites

public Collection getAllCallSites()
Description copied from class: CallGraph
Returns the collection of all call sites in the call graph. The default implementation just iterates through all of the methods to build up the collection.

Overrides:
getAllCallSites in class CallGraph
Returns:
Collection of all call sites in the call graph

getAllMethods

public Collection getAllMethods()
Description copied from class: CallGraph
Returns the collection of all methods in the call graph. The default implementation recalculates the reachable methods based on the root set.

Overrides:
getAllMethods in class CallGraph
Returns:
Collection of all call sites in the call graph

getCallees

public Collection getCallees(ControlFlowGraph cfg)
Description copied from class: CallGraph
Returns the set of methods that are called by the given CFG.

Overrides:
getCallees in class CallGraph
Returns:
set of callee methods

getCallees

public Collection getCallees(jq_Method caller)
Description copied from class: CallGraph
Returns the set of methods that are called by the given method.

Overrides:
getCallees in class CallGraph
Returns:
set of callee methods

getFromMultiMap

public static Collection getFromMultiMap(jwutil.collections.MultiMap m1,
                                         jwutil.collections.MultiMap m2,
                                         jq_Method method)

getCallers

public Collection getCallers(jq_Method callee)
Description copied from class: CallGraph
Returns the set of call sites that can call the given method.

Overrides:
getCallers in class CallGraph
Returns:
set of callers

getCallerMethods

public Collection getCallerMethods(jq_Method callee)
Description copied from class: CallGraph
Returns the set of methods that can call the given method.

Overrides:
getCallerMethods in class CallGraph
Returns:
set of caller methods

getCallSites

public Collection getCallSites(ControlFlowGraph cfg)
Description copied from class: CallGraph
Returns the set of call sites in the given CFG.

Overrides:
getCallSites in class CallGraph
Returns:
set of call sites

getCallSites

public Collection getCallSites(jq_Method caller)
Description copied from class: CallGraph
Returns the set of call sites in the given method.

Overrides:
getCallSites in class CallGraph
Returns:
set of call sites

getTargetMethods

public Collection getTargetMethods(Object context,
                                   ProgramLocation callSite)
Description copied from class: CallGraph
Returns the possible target methods of the given call site under the given context. The interpretation of the context object is specific to the type of call graph.

Specified by:
getTargetMethods in class CallGraph
Returns:
Collection of jq_Methods that are the possible targets

inlineEdge

public void inlineEdge(jq_Method caller,
                       ProgramLocation callSite,
                       jq_Method callee)
Inline the given edge in the call graph.

Parameters:
caller - caller method
callSite - call site to inline
callee - callee method

keySet

public Set keySet()
Specified by:
keySet in interface Map
Overrides:
keySet in class AbstractMap

getRoots

public Collection getRoots()
Description copied from class: CallGraph
Returns the collection of root methods for this call graph.

Specified by:
getRoots in interface jwutil.graphs.Graph
Specified by:
getRoots in class CallGraph


Copyright © 2001-2008 John Whaley. All Rights Reserved.