ptolemy.copernicus.c
Class CNames

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

public class CNames
extends java.lang.Object

A class that determines names of various entities to use for C code generation.

Since:
Ptolemy II 2.0
Version:
$Id: CNames.java,v 1.54 2007/12/06 21:56:50 cxh Exp $
Author:
Shuvra S. Bhattacharyya, Ankush Varma
Accepted Rating:
Red (ssb)
Proposed Rating:
Red (ssb)

Field Summary
static java.lang.String arrayAllocateFunction
          The name of the runtime function or macro to be used for allocating an array.
static java.lang.String arrayClassPrefix
          The prefix of array class descriptors that correspond to primitive types.
static java.lang.String arrayLengthFunction
          The name of the runtime function or macro to be used for determining the length of an array.
static java.lang.String arrayReferenceFunction
          The name of the runtime function or macro to be used for computing array references.
static java.lang.String instanceOfFunction
          The name of the runtime function or macro to be used for implementing the Java instanceof operator.
 
Method Summary
static java.lang.String classNameOf(soot.SootClass source)
          Determine the C name for the class-specific structure type that implements a Soot class.
static java.lang.String classNameToFileName(java.lang.String className)
          Returns the C filename corresponding to a class.
static java.lang.String classStructureNameOf(soot.SootClass source)
          Determine the C name for the class-specific structure variable that implements a Soot class.
static void clearLocalNames()
          Clear the set of local variable names.
static java.lang.String fieldNameOf(soot.SootField field)
          Return the name associated with a field in a Soot class.
static java.lang.String functionNameOf(soot.SootMethod method)
          Return the name of the C function that implements a given Soot method.
static int hashNumberOf(soot.SootClass source)
          Return a number representing the hashCode for this class.
static int hashNumberOf(soot.SootMethod method)
          Return a number representing the hash code for this method.
static java.lang.String includeFileNameOf(soot.SootClass source)
          Return the include file name for a given class.
static java.lang.String initializerNameOf(soot.SootClass source)
          Given a class, return the name of the function that implements initialization of the class, including all functionality in the static initializer for the class (if it exists), and all class-level initialization required on the C data structures that implement the class.
static java.lang.String instanceNameOf(soot.SootClass source)
          Determine the C name for the instance-specific structure type that implements a Soot class.
static java.lang.String interfaceLookupNameOf(soot.SootClass source)
          Return the C name of the method that performs lookups to disambiguate interface references.
static boolean isSystemClass(java.lang.String className)
          Returns whether a given class is a System class.
static java.lang.String localNameOf(soot.Local local)
          Return the name of a local.
static java.lang.String methodNameOf(soot.SootMethod method)
          Return the name of the C structure member that represents a given Soot method.
static java.lang.String sanitize(java.lang.String name)
          Return a version of a string with all $, <, >, or - characters replaced by _.
static void setup()
          Initialize C name generation.
static java.lang.String superclassPointerName()
          Return the name of the class structure member that points to the superclass structure.
static java.lang.String typeNameOf(soot.Type type)
          Determine the C name associated with a Soot type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

arrayAllocateFunction

public static final java.lang.String arrayAllocateFunction
The name of the runtime function or macro to be used for allocating an array.

See Also:
Constant Field Values

arrayClassPrefix

public static final java.lang.String arrayClassPrefix
The prefix of array class descriptors that correspond to primitive types. For example, if we concatenate "int" to this prefix, we get the run-time struct that represents the class of arrays of integers.

See Also:
Constant Field Values

arrayLengthFunction

public static final java.lang.String arrayLengthFunction
The name of the runtime function or macro to be used for determining the length of an array.

See Also:
Constant Field Values

arrayReferenceFunction

public static final java.lang.String arrayReferenceFunction
The name of the runtime function or macro to be used for computing array references.

See Also:
Constant Field Values

instanceOfFunction

public static final java.lang.String instanceOfFunction
The name of the runtime function or macro to be used for implementing the Java instanceof operator.

See Also:
Constant Field Values
Method Detail

classNameOf

public static java.lang.String classNameOf(soot.SootClass source)
Determine the C name for the class-specific structure type that implements a Soot class. The class-specific structure has type "struct classNameOf(SootClass)". Additionally, the identifier classNameOf(SootClass) (i.e., without the struct qualifier) is defined in the generated code to be a pointer type that points to the class-specific structure.

Parameters:
source - The class.
Returns:
The C name for the class-specific structure type.

classNameToFileName

public static java.lang.String classNameToFileName(java.lang.String className)
Returns the C filename corresponding to a class.

Parameters:
className - The name of a class.
Returns:
The C fileName corresponding to this class.

classStructureNameOf

public static java.lang.String classStructureNameOf(soot.SootClass source)
Determine the C name for the class-specific structure variable that implements a Soot class. The type of this structure is the type pointed to by the pointer type classNameOf(SootClass).

Parameters:
source - The class.
Returns:
The C name for the class-specific structure variable.

clearLocalNames

public static void clearLocalNames()
Clear the set of local variable names.


fieldNameOf

public static java.lang.String fieldNameOf(soot.SootField field)
Return the name associated with a field in a Soot class.

Parameters:
field - The field.
Returns:
The name.

functionNameOf

public static java.lang.String functionNameOf(soot.SootMethod method)
Return the name of the C function that implements a given Soot method.

Parameters:
method - The method.
Returns:
The function name.

hashNumberOf

public static int hashNumberOf(soot.SootMethod method)
Return a number representing the hash code for this method.

Parameters:
method - The SootMethod for which we want the hash number.
Returns:
The number representing this hash.

hashNumberOf

public static int hashNumberOf(soot.SootClass source)
Return a number representing the hashCode for this class.

Parameters:
source - The class.
Returns:
The hashCode.

includeFileNameOf

public static java.lang.String includeFileNameOf(soot.SootClass source)
Return the include file name for a given class.

Parameters:
source - The class.
Returns:
The include file name.

initializerNameOf

public static java.lang.String initializerNameOf(soot.SootClass source)
Given a class, return the name of the function that implements initialization of the class, including all functionality in the static initializer for the class (if it exists), and all class-level initialization required on the C data structures that implement the class. When called, this function must be passed the address of the variable given by classStructureNameOf(soot.SootClass).

Parameters:
source - The class.
Returns:
The function name.

instanceNameOf

public static java.lang.String instanceNameOf(soot.SootClass source)
Determine the C name for the instance-specific structure type that implements a Soot class. The instance-specific structure has type "struct instanceNameOf(SootClass)". Additionally, the identifier instanceNameOf(SootClass) (i.e., without the struct qualifier) is defined in the generated code to be a pointer type that points to the class-specific structure.

Parameters:
source - The Soot class.
Returns:
The C name for the instance-specific structure type.

interfaceLookupNameOf

public static java.lang.String interfaceLookupNameOf(soot.SootClass source)
Return the C name of the method that performs lookups to disambiguate interface references.

Parameters:
source - The class for which this method needs to be generated.
Returns:
The name of the lookup method.

isSystemClass

public static boolean isSystemClass(java.lang.String className)
Returns whether a given class is a System class.

Parameters:
className - A class.
Returns:
True if the given class is a System class.

localNameOf

public static java.lang.String localNameOf(soot.Local local)
Return the name of a local.

Parameters:
local - The local.
Returns:
The name.

methodNameOf

public static java.lang.String methodNameOf(soot.SootMethod method)
Return the name of the C structure member that represents a given Soot method. The identifier returned by this method is a member of the structure that implements the associated class (see classNameOf(SootClass)).

Parameters:
method - The Soot method.
Returns:
The name.

sanitize

public static java.lang.String sanitize(java.lang.String name)
Return a version of a string with all $, <, >, or - characters replaced by _.

Parameters:
name - The String to be converted.
Returns:
The sanitized version of this string.

setup

public static void setup()
Initialize C name generation. This method must be called once before any other method in this class is called.


superclassPointerName

public static java.lang.String superclassPointerName()
Return the name of the class structure member that points to the superclass structure. Each structure that implements a class has as a member a pointer to the superclass. This method returns the name of this pointer member.

Returns:
The name of the pointer member.

typeNameOf

public static java.lang.String typeNameOf(soot.Type type)
Determine the C name associated with a Soot type. For RefType types, the C name returned is the name of the instance-specific data structure. To obtain the name of the class-specific data structure associated with a RefType, see instanceNameOf(SootClass).

Parameters:
type - The type.
Returns:
The C name.