ptolemy.copernicus.c
Class OverriddenMethodGenerator

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

public class OverriddenMethodGenerator
extends java.lang.Object

A class that handles generation and management of Java methods that are over-ridden by pre-defined C code. The class allows conventional java methods to be replaced with pre-defined C code. This may be done for platform-specificness, correctness or performance considerations. Note that "overridden" here means that the code for a method is replaced with either dummy or user-defined C code. It does not refer to overriding methods by inheritance in java.

Since:
Ptolemy II 4.0
Version:
$Id: OverriddenMethodGenerator.java,v 1.37 2006/03/28 23:58:37 cxh Exp $
Author:
Ankush Varma
Accepted Rating:
Red (ankush)
Proposed Rating:
Red (ankush)

Constructor Summary
OverriddenMethodGenerator()
           
 
Method Summary
protected static java.lang.String _getBodyCode(soot.SootMethod method)
          Returns the code for the body of a given overridden method.
protected static java.lang.String _getHeaderCode(soot.SootMethod method)
          Returns the code for the header of the overridden method.
static java.lang.String fileContainingCodeFor(soot.SootMethod method)
          Return the name of the file where the C code for an overridden method should be.
static java.lang.String getCode(soot.SootMethod method)
          Returns the code for a given overridden method.
static java.lang.String getOverriddenBodyLib()
          Returns the location of the directory containing the overridden bodies for methods.
static void init()
          Perform initialization functions and set up the list of force-overridden methods.
static boolean isOverridden(soot.SootClass sootClass)
          Checks if the given class is overridden.
static boolean isOverridden(soot.SootMethod method)
          Checks if the given method is overridden.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OverriddenMethodGenerator

public OverriddenMethodGenerator()
Method Detail

fileContainingCodeFor

public static java.lang.String fileContainingCodeFor(soot.SootMethod method)
Return the name of the file where the C code for an overridden method should be. This name also includes the appropriate directory path.

Parameters:
method - The method.
Returns:
The name of the file.

getCode

public static java.lang.String getCode(soot.SootMethod method)
Returns the code for a given overridden method.

Parameters:
method - The method for which C code is needed.
Returns:
The code for the method.

getOverriddenBodyLib

public static java.lang.String getOverriddenBodyLib()
Returns the location of the directory containing the overridden bodies for methods.

Returns:
The location.

init

public static void init()
Perform initialization functions and set up the list of force-overridden methods.


isOverridden

public static boolean isOverridden(soot.SootMethod method)
Checks if the given method is overridden.

Parameters:
method - The method to be checked.
Returns:
True if the method is overridden.

isOverridden

public static boolean isOverridden(soot.SootClass sootClass)
Checks if the given class is overridden.

Parameters:
sootClass - The class to check.
Returns:
True if the entire class is overridden.

_getBodyCode

protected static java.lang.String _getBodyCode(soot.SootMethod method)
Returns the code for the body of a given overridden method. If a file exists containing the body of this overridden method, that file is used, otherwise a dummy method stub is generated that just allows the method to be compiled correctly. Note that auto-generated dummy method stubs cannot provide correct functionality. This may lead to problems(for example, segmentation faults) due to uninitialized fields/function pointers. These problems can be solved by using a file instead of a dummy stub for the method body. A large majority of overridden methods have no problems with dummy stubs.

Parameters:
method - The overridden method.
Returns:
The code for the body of the method.

_getHeaderCode

protected static java.lang.String _getHeaderCode(soot.SootMethod method)
Returns the code for the header of the overridden method. This is almost identical to NativeMethodGenerator._getStubHeader(SootMethod).

Parameters:
method - The overridden method.
Returns:
The code for the header of the method.