ptolemy.copernicus.c
Class MethodListGenerator

java.lang.Object
  extended by ptolemy.copernicus.c.MethodListGenerator

public class MethodListGenerator
extends java.lang.Object

A class that extracts ordered lists of method declarations with an ordering convention that facilitates translation of methods into function pointers (e.g., for C code generation).

Specifically, the class extracts the class initializer method (if present); the list of constructors; the list of all new public and protected methods that are defined for a given class (i.e., new method definitions, excluding definitions that override methods in superclasses); the list of inherited methods; and the list of private methods. For sub-classes, overridden methods in the inherited methods list are replaced with the overriding definitions. Thus, the inherited methods list is the list of 'active' definitions in the current scope whose declarations originated in superclasses.

For example, consider the following class/method combinations:

class C1(base class), public methods m1, m2, m3; private method p1
class C2(extends C1), public methods m4, m5(overrides m2)
class C3 (extends C2), public methods m6, m7; private methods p1, p2

Then the inherited methods list generated for C3 is

m1, m5, m3, m4;

the private list generated for C3 is

p1, p2;

the inherited methods list generated for C2 is

m1, m5, m3;

and the new methods list generated for C2 is

m4.

If function pointers are declared according to these orderings in the translated type definitions associated with C1, C2, and C3, then virtual functions can be implemented correctly.

The lists constructed by this class are lists of method declarations. That is, each element is of type SootMethod.

Since:
Ptolemy II 2.0
Version:
$Id: MethodListGenerator.java,v 1.37 2005/07/08 19:56:59 cxh Exp $
Author:
Shuvra S. Bhattacharyya
Accepted Rating:
Red (ssb)
Proposed Rating:
Red (ssb)

Method Summary
protected static void _generate(soot.SootClass source)
          Given a class, construct the lists of constructors, inherited methods, new public and protected methods, and private methods.
static soot.SootMethod getClassInitializer(soot.SootClass source)
          Given a class, return the class initializer method if it exists, or return null if the class does not have a class initializer method.
static java.util.LinkedList getConstructors(soot.SootClass source)
          Return the list of constructors for a given class.
static java.util.LinkedList getInheritedMethods(soot.SootClass source)
          Return the list of inherited methods for a given class.
static java.util.LinkedList getNewMethods(soot.SootClass source)
          Return the list of new methods for a given class.
static java.util.LinkedList getPrivateMethods(soot.SootClass source)
          Return the list of private methods for a given class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getClassInitializer

public static soot.SootMethod getClassInitializer(soot.SootClass source)
Given a class, return the class initializer method if it exists, or return null if the class does not have a class initializer method.

Parameters:
source - The class.
Returns:
The class initializer method.
Since:
Ptolemy II 2.0

getConstructors

public static java.util.LinkedList getConstructors(soot.SootClass source)
Return the list of constructors for a given class.

Parameters:
source - The class.
Returns:
The list of constructors.

getInheritedMethods

public static java.util.LinkedList getInheritedMethods(soot.SootClass source)
Return the list of inherited methods for a given class.

Parameters:
source - The class.
Returns:
The list of inherited methods.

getNewMethods

public static java.util.LinkedList getNewMethods(soot.SootClass source)
Return the list of new methods for a given class.

Parameters:
source - The class.
Returns:
The list of new methods.

getPrivateMethods

public static java.util.LinkedList getPrivateMethods(soot.SootClass source)
Return the list of private methods for a given class.

Parameters:
source - The class.
Returns:
The list of private methods.

_generate

protected static void _generate(soot.SootClass source)
Given a class, construct the lists of constructors, inherited methods, new public and protected methods, and private methods. Recursively include methods from superclasses in the inherited methods list.

Parameters:
source - The class.