ptolemy.copernicus.c
Class RequiredFileGenerator

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

public class RequiredFileGenerator
extends java.lang.Object

A class that generates the other required files in the transitive closure.

Since:
Ptolemy II 2.0
Version:
$Id: RequiredFileGenerator.java,v 1.56 2007/12/06 18:28:42 cxh Exp $
Author:
Ankush Varma
Accepted Rating:
Red (ankush)
Proposed Rating:
Red (ankush)

Constructor Summary
RequiredFileGenerator()
           
 
Method Summary
static void generateTransitiveClosureOf(java.lang.String classPath, java.lang.String className)
          Generate the .h files for all classes in the transitive closure of the given class, and the .c files for required classes only.
static java.util.HashSet generateUserClasses(java.lang.StringBuffer code)
          Appends the list of C files corresponding to user classes to a given StringBuffer and returns the list of C files corresponding to library files.
static java.util.Collection getRequiredClasses()
          Returns the set of all required classes.
 void init(java.lang.String classPath, java.lang.String className)
          Initialize and compute the required classes and methods.
static boolean isRequired(soot.SootClass source)
          Returns whether a given class is required or not.
static boolean isRequired(soot.SootField field)
          Returns whether a given field is required or not.
static boolean isRequired(soot.SootMethod method)
          Returns whether a given method is required or not.
static boolean isRequired(soot.Type type)
          Returns whether a given Type is required or not.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RequiredFileGenerator

public RequiredFileGenerator()
Method Detail

generateTransitiveClosureOf

public static void generateTransitiveClosureOf(java.lang.String classPath,
                                               java.lang.String className)
                                        throws java.io.IOException
Generate the .h files for all classes in the transitive closure of the given class, and the .c files for required classes only. A class is considered "required" if it contains at least one method that is in the transitive closure of methods called in the main class.

Parameters:
classPath - The classPath.
className - The main class.
Throws:
java.io.IOException - If file I/O errors occur.

generateUserClasses

public static java.util.HashSet generateUserClasses(java.lang.StringBuffer code)
Appends the list of C files corresponding to user classes to a given StringBuffer and returns the list of C files corresponding to library files. This is used by the MakeFileGenerator.

Parameters:
code - The StringBuffer to which the C filenames of user classes are to be added.
Returns:
The list of C file names of required library files.

getRequiredClasses

public static java.util.Collection getRequiredClasses()
Returns the set of all required classes.

Returns:
The set of all required Classes.

init

public void init(java.lang.String classPath,
                 java.lang.String className)
Initialize and compute the required classes and methods.

Parameters:
classPath - The classpath.
className - The name of the class which we will take as the root from which others are called.

isRequired

public static boolean isRequired(soot.SootClass source)
Returns whether a given class is required or not.

Parameters:
source - Any class.
Returns:
True if it is a required class.

isRequired

public static boolean isRequired(soot.SootField field)
Returns whether a given field is required or not.

Parameters:
field - Any field.
Returns:
True if it is a required field.

isRequired

public static boolean isRequired(soot.SootMethod method)
Returns whether a given method is required or not.

Parameters:
method - Any method.
Returns:
True if it is a required method.

isRequired

public static boolean isRequired(soot.Type type)
Returns whether a given Type is required or not. A type is required if it is not a RefType, or its corresponding class is not required.

Parameters:
type - The type to be checked.
Returns:
True if the type is required.