Overview Package Class Tree Deprecated Index Help
PREV CLASS NEXT CLASS FRAMES NO FRAMES All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD

ptolemy.copernicus.c
Class CallGraphPruner

java.lang.Object
 extended byptolemy.copernicus.c.CallGraphPruner

public class CallGraphPruner
extends java.lang.Object

Class that uses the Soot Framework to find out which methods/classes are really needed for code generation.

Since:
Ptolemy II 4.0
Version:
$Id: CallGraphPruner.java,v 1.27 2006年08月20日 19:55:54 cxh Exp $
Author:
Ankush Varma
Accepted Rating:
Red (ssb)
Proposed Rating:
Red (ankush)

Field Summary
protected java.util.LinkedList _gray
The list of all classes, methods, and fields discovered but not yet processed.
protected java.util.HashSet _reachableClasses
The list of all reachable classes.
protected java.util.HashSet _reachableFields
The list of all reachable fields.
protected java.util.HashSet _reachableMethods
The list of all reachable methods.
Constructor Summary
CallGraphPruner()
Dummy constructor to allow inheritance.
CallGraphPruner(soot.SootClass source)
Constructor.
Method Summary
protected void _add(java.util.Collection nodes)
Adds a whole collection of classes/methods/fields to _gray.
protected void _add(java.lang.Object node)
Adds an object to the _gray list if the object is not in the gray or a _reachable list.
protected void _done(java.lang.Object node)
Adds a class, method or field to the appropriate reachable list.
protected java.util.LinkedList _getCallGraphEntryPoints(soot.SootClass source)
Returns the list of methods that should be considered entry points for building the CallGraph.
protected java.util.LinkedList _getCompulsoryNodes()
Returns the list of nodes(methods/classes/fields) that are always needed, regardless of whether the source class reaches them explicitly.
protected java.util.HashSet _getMethodsRequiredByInheritance(java.util.Collection classSet, java.util.Collection methodSet)
Returns the list of methods required by inheritance.
protected java.util.HashSet _getNodesAccessedInBodyOf(soot.SootMethod method)
Returns a set of the nodes referenced in the body of a given method.
protected java.util.HashSet _getRoots(soot.SootClass source)
Gets the set of fields, methods and classes to be started off with.
protected void _growTree(soot.SootClass source)
Computes the set of classes, methods and fields reachable from a given class.
protected boolean _isLeaf(soot.SootMethod method)
Figures out if a the targets of a method need to be computed.
protected void _processClass(soot.SootClass node)
Performs the appropriate operations for the discovery of a new class.
protected void _processField(soot.SootField field)
Performs the appropriate operations for the discovery of a new field.
protected void _processMethod(soot.SootMethod method)
Performs the appropriate operations for the discovery of a new method.
java.util.HashSet getReachableClasses()
Get the set of all reachable classes.
java.util.HashSet getReachableFields()
Get the set of all reachable fields.
java.util.HashSet getReachableMethods()
Get the set of all reachable methods.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail

_gray

protected java.util.LinkedList _gray
The list of all classes, methods, and fields discovered but not yet processed.


_reachableClasses

protected java.util.HashSet _reachableClasses
The list of all reachable classes.


_reachableFields

protected java.util.HashSet _reachableFields
The list of all reachable fields.


_reachableMethods

protected java.util.HashSet _reachableMethods
The list of all reachable methods.

Constructor Detail

CallGraphPruner

public CallGraphPruner()
Dummy constructor to allow inheritance.


CallGraphPruner

public CallGraphPruner(soot.SootClass source)
Constructor. Creates an CallGraph and applies a specialized pruning strategy to it, tailored for C code generation.

Parameters:
source - The class to use as the root for the pruned tree.
Method Detail

getReachableClasses

public java.util.HashSet getReachableClasses()
Get the set of all reachable classes.

Returns:
The set of all reachable classes.

getReachableFields

public java.util.HashSet getReachableFields()
Get the set of all reachable fields.

Returns:
The set of all reachable fields.

getReachableMethods

public java.util.HashSet getReachableMethods()
Get the set of all reachable methods.

Returns:
The set of all reachable methods.

_add

protected void _add(java.util.Collection nodes)
Adds a whole collection of classes/methods/fields to _gray.

Parameters:
nodes - The collection of nodes to add.

_add

protected void _add(java.lang.Object node)
Adds an object to the _gray list if the object is not in the gray or a _reachable list. The object is assumed to be a class, method or field.

Parameters:
node - The object to add.

_done

protected void _done(java.lang.Object node)
Adds a class, method or field to the appropriate reachable list.

Parameters:
node - The class/field/method to process.

_getCallGraphEntryPoints

protected java.util.LinkedList _getCallGraphEntryPoints(soot.SootClass source)
Returns the list of methods that should be considered entry points for building the CallGraph.

Parameters:
source - The main class in the Scene.
Returns:
The list of entry points.

_getCompulsoryNodes

protected java.util.LinkedList _getCompulsoryNodes()
Returns the list of nodes(methods/classes/fields) that are always needed, regardless of whether the source class reaches them explicitly.

Returns:
The list of compulsory methods.

_getMethodsRequiredByInheritance

protected java.util.HashSet _getMethodsRequiredByInheritance(java.util.Collection classSet,
 java.util.Collection methodSet)
Returns the list of methods required by inheritance. If a class C implements an interface I or extends a class I, then C.m is required if I.m is required.

Parameters:
classSet - The set of classes that are candidates for C.
methodSet - The set of methods to which I.m may belong.
Returns:
The set of all methods of classes that may be implementing a method in methods .

_getNodesAccessedInBodyOf

protected java.util.HashSet _getNodesAccessedInBodyOf(soot.SootMethod method)
Returns a set of the nodes referenced in the body of a given method. This includes:
  • Methods directly called (sometimes invokegraph fails to catch these).
  • Fields accessed.
  • Classes called by instanceof expressions.
These are computed here in the same method so that only one pass through the statements in the body is required.

Parameters:
method - The method.
Returns:
The set of nodes unambiguously referenced in the statements comprising its body.

_getRoots

protected java.util.HashSet _getRoots(soot.SootClass source)
Gets the set of fields, methods and classes to be started off with.

Parameters:
source - The source class.
Returns:
The set of nodes that are needed to start off with.

_growTree

protected void _growTree(soot.SootClass source)
Computes the set of classes, methods and fields reachable from a given class.

Parameters:
source - The class.

_isLeaf

protected boolean _isLeaf(soot.SootMethod method)
Figures out if a the targets of a method need to be computed. Computation terminates at a "leaf" method. All native and force-overridden methods are leaves.

Parameters:
method - The method.
Returns:
True if the method is a leaf.

_processClass

protected void _processClass(soot.SootClass node)
Performs the appropriate operations for the discovery of a new class.

Parameters:
node - The class.

_processField

protected void _processField(soot.SootField field)
Performs the appropriate operations for the discovery of a new field.

Parameters:
field - The field.

_processMethod

protected void _processMethod(soot.SootMethod method)
Performs the appropriate operations for the discovery of a new method.

Parameters:
method - The method.

Overview Package Class Tree Deprecated Index Help
PREV CLASS NEXT CLASS FRAMES NO FRAMES All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD

AltStyle によって変換されたページ (->オリジナル) /