Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Compil3r.Quad
Class CallGraph  view CallGraph download CallGraph.java

java.lang.Object
  extended byjava.util.AbstractMap
      extended byUtil.Collections.UnmodifiableMultiMap
          extended byCompil3r.Quad.CallGraph
All Implemented Interfaces:
Util.Collections.BinaryRelation, Util.Graphs.Graph, java.util.Map, Util.Collections.MultiMap
Direct Known Subclasses:
AndersenPointerAnalysis.AndersenCallGraph, BDDPointerAnalysis.BDDCallGraph, CachedCallGraph, CHACallGraph, LoadedCallGraph

public abstract class CallGraph
extends Util.Collections.UnmodifiableMultiMap
implements Util.Graphs.Graph

Abstract representation of a call graph.

Version:
$Id: CallGraph.java,v 1.8 2003/07/04 07:31:20 joewhaley Exp $

Nested Class Summary
static class CallGraph.CallGraphMap
           
 class CallGraph.CallGraphNavigator
           
static class CallGraph.CallSiteMap
           
 class CallGraph.CallTargetMap
           
 
Nested classes inherited from class java.util.AbstractMap
 
Nested classes inherited from class java.util.Map
java.util.Map.Entry
 
Field Summary
 
Fields inherited from class Util.Collections.UnmodifiableMultiMap
DEFAULT_HISTOGRAM_SIZE
 
Fields inherited from class java.util.AbstractMap
 
Constructor Summary
CallGraph()
           
 
Method Summary
 java.util.Map calculateBackEdges()
           
 Util.Collections.InvertibleMultiMap calculateEdgeRelation()
          Returns the call graph edge relation in the form of an invertible multi-map.
 java.util.Set calculateReachableMethods(java.util.Collection roots)
          Returns the set of methods that are reachable from the given method root set.
 boolean contains(java.lang.Object a, java.lang.Object b)
          Returns true if a has a mapping to b in this.
 java.util.Set entrySet()
          Returns a Set view that allows you to recapture the MultiMap view.
 java.util.Collection[] findDepths()
           
 java.util.Collection getAllCallSites()
          Returns the collection of all call sites in the call graph.
 java.util.Collection getAllMethods()
          Returns the collection of all methods in the call graph.
 java.util.Collection getCallees(ControlFlowGraph cfg)
          Returns the set of methods that are called by the given CFG.
 java.util.Collection getCallees(Clazz.jq_Method caller)
          Returns the set of methods that are called by the given method.
 java.util.Collection getCallers(Clazz.jq_Method callee)
          Returns the set of methods that can call the given method.
 Util.Collections.MultiMap getCallGraphMap()
           
 Util.Collections.MultiMap getCallSiteMap()
           
 java.util.Collection getCallSites(ControlFlowGraph cfg)
          Returns the set of call sites in the given CFG.
 java.util.Collection getCallSites(Clazz.jq_Method caller)
          Returns the set of call sites in the given method.
static java.util.Collection getCallSites0(ControlFlowGraph cfg)
           
static java.util.Collection getCallSites0(Clazz.jq_Method caller)
           
static java.util.Collection getCallSites1(ControlFlowGraph cfg)
           
 Util.Graphs.Navigator getNavigator()
           
abstract  java.util.Collection getRoots()
           
 Clazz.jq_Method getTargetMethod(java.lang.Object context, ProgramLocation callSite)
          Returns the target method of the given call site under the given context, assuming that it is a single target.
abstract  java.util.Collection getTargetMethods(java.lang.Object context, ProgramLocation callSite)
          Returns the possible target methods of the given call site under the given context.
 java.util.Collection getTargetMethods(ProgramLocation callSite)
          Returns the possible target methods of the given call site.
 java.util.Collection getValues(java.lang.Object key)
          Returns the collection of Values associated with key.
 int numberOfTargetMethods(java.lang.Object context, ProgramLocation callSite)
          Returns the number of possible target methods of the given call site under the given context.
 int numberOfTargetMethods(ProgramLocation callSite)
          Returns the number of possible target methods of the given call site.
abstract  void setRoots(java.util.Collection roots)
          Sets up the root methods to be the given set.
 java.lang.String toString()
          Returns a String representation of this map.
 
Methods inherited from class Util.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, keySet, size, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface Util.Collections.MultiMap
get, size
 
Methods inherited from interface java.util.Map
containsKey, containsValue, equals, hashCode, isEmpty, keySet, values
 

Constructor Detail

CallGraph

public CallGraph()
Method Detail

setRoots

public abstract void setRoots(java.util.Collection roots)
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().


getRoots

public abstract java.util.Collection getRoots()
Specified by:
getRoots in interface Util.Graphs.Graph

getAllMethods

public java.util.Collection getAllMethods()
Returns the collection of all methods in the call graph. The default implementation recalculates the reachable methods based on the root set.


getAllCallSites

public java.util.Collection getAllCallSites()
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.


getTargetMethods

public abstract java.util.Collection getTargetMethods(java.lang.Object context,
                                                      ProgramLocation callSite)
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.


getTargetMethods

public java.util.Collection getTargetMethods(ProgramLocation callSite)
Returns the possible target methods of the given call site.


numberOfTargetMethods

public int numberOfTargetMethods(java.lang.Object context,
                                 ProgramLocation callSite)
Returns the number of 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.


numberOfTargetMethods

public int numberOfTargetMethods(ProgramLocation callSite)
Returns the number of possible target methods of the given call site.


getTargetMethod

public Clazz.jq_Method getTargetMethod(java.lang.Object context,
                                       ProgramLocation callSite)
Returns the target method of the given call site under the given context, assuming that it is a single target. The interpretation of the context object is specific to the type of call graph.


getCallSites

public java.util.Collection getCallSites(Clazz.jq_Method caller)
Returns the set of call sites in the given method.


getCallSites0

public static java.util.Collection getCallSites0(Clazz.jq_Method caller)

getCallSites

public java.util.Collection getCallSites(ControlFlowGraph cfg)
Returns the set of call sites in the given CFG.


getCallSites0

public static java.util.Collection getCallSites0(ControlFlowGraph cfg)

getCallSites1

public static java.util.Collection getCallSites1(ControlFlowGraph cfg)

getCallees

public java.util.Collection getCallees(Clazz.jq_Method caller)
Returns the set of methods that are called by the given method.


getCallees

public java.util.Collection getCallees(ControlFlowGraph cfg)
Returns the set of methods that are called by the given CFG.


getCallers

public java.util.Collection getCallers(Clazz.jq_Method callee)
Returns the set of methods that can call the given method.


calculateReachableMethods

public java.util.Set calculateReachableMethods(java.util.Collection roots)
Returns the set of methods that are reachable from the given method root set.


toString

public java.lang.String toString()
Description copied from class: java.util.AbstractMap
Returns a String representation of this map. This is a listing of the map entries (which are specified in Map.Entry as being getKey() + "=" + getValue()), separated by a comma and space (", "), and surrounded by braces ('{' and '}'). This implementation uses a StringBuffer and iterates over the entrySet to build the String. Note that this can fail with an exception if underlying keys or values complete abruptly in toString().


calculateBackEdges

public java.util.Map calculateBackEdges()

calculateEdgeRelation

public Util.Collections.InvertibleMultiMap calculateEdgeRelation()
Returns the call graph edge relation in the form of an invertible multi-map.


findDepths

public java.util.Collection[] findDepths()

getNavigator

public Util.Graphs.Navigator getNavigator()
Specified by:
getNavigator in interface Util.Graphs.Graph

getCallSiteMap

public Util.Collections.MultiMap getCallSiteMap()

getCallGraphMap

public Util.Collections.MultiMap getCallGraphMap()

entrySet

public java.util.Set entrySet()
Description copied from class: Util.Collections.UnmodifiableMultiMap
Returns a Set view that allows you to recapture the MultiMap view.

Specified by:
entrySet in interface Util.Collections.MultiMap

contains

public boolean contains(java.lang.Object a,
                        java.lang.Object b)
Description copied from interface: Util.Collections.MultiMap
Returns true if a has a mapping to b in this. (MultiMap specific operation).

Specified by:
contains in interface Util.Collections.MultiMap

getValues

public java.util.Collection getValues(java.lang.Object key)
Description copied from interface: Util.Collections.MultiMap
Returns the collection of Values associated with key. Modifications to the returned Collection affect this as well. If there are no Values currently associated with key, constructs a new, potentially mutable, empty Collection and returns it. (MultiMap specific operation).

Specified by:
getValues in interface Util.Collections.MultiMap