ptolemy.copernicus.kernel
Class KernelMain

java.lang.Object
  extended by ptolemy.copernicus.kernel.KernelMain
Direct Known Subclasses:
Main, Main, Main

public abstract class KernelMain
extends java.lang.Object

Base class that provides common functionality to be used by various code generators. Particular code generators should extend this class and generally override the addTransforms method to instantiate the correct transforms and the _parseArgs method to extract arguments. These subclasses should be not be instantiated directly, but will instead be instantiated by the Copernicus class according to a selected code generator.

Since:
Ptolemy II 2.0
Version:
$Id: KernelMain.java,v 1.87 2006/10/25 00:17:26 cxh Exp $
Author:
Stephen Neuendorffer, Christopher Hylands
Accepted Rating:
Red (cxh)
Proposed Rating:
Red (cxh)

Nested Class Summary
static class KernelMain._IgnoreAllApplicationClasses
           
 
Field Summary
protected  java.lang.String _momlClassName
          The name of the MoML class, either as a top level model or as an xml file that we are generating code for.
protected  CompositeActor _toplevel
          The CompositeActor we are generating code for.
 
Constructor Summary
KernelMain()
           
 
Method Summary
protected  java.lang.String[] _parseArgs(GeneratorAttribute attribute)
          Parse any code generator specific arguments.
static void addStandardOptimizations(soot.Pack pack, int time)
          Add transforms corresponding to the standard soot optimizations to the given pack.
static void addTransform(soot.Pack pack, java.lang.String name, soot.Transformer transformer)
          Add a new transform to the given pack, dealing properly with options specified in the transformer.
static void addTransform(soot.Pack pack, java.lang.String name, soot.Transformer transformer, java.lang.String defaultOptions)
          Add a new transform to the given pack, dealing properly with options specified in the transformer.
abstract  void addTransforms()
          Add transforms to the Scene.
 void compile(java.lang.String modelName, CompositeActor toplevel, GeneratorAttribute attribute)
          Compile the given model with the given name.
 void generateCode(java.lang.String[] args)
          Call soot.Main.main(), which does command line argument processing and then starts the transformation.
 void initialize(CompositeActor toplevel)
          Read in a MoML class, sanitize the top level name, initialize the model.
 CompositeActor toplevel()
          Return the model that we are generating code for.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_momlClassName

protected java.lang.String _momlClassName
The name of the MoML class, either as a top level model or as an xml file that we are generating code for.


_toplevel

protected CompositeActor _toplevel
The CompositeActor we are generating code for.

Constructor Detail

KernelMain

public KernelMain()
Method Detail

addTransform

public static void addTransform(soot.Pack pack,
                                java.lang.String name,
                                soot.Transformer transformer,
                                java.lang.String defaultOptions)
Add a new transform to the given pack, dealing properly with options specified in the transformer.


addTransform

public static void addTransform(soot.Pack pack,
                                java.lang.String name,
                                soot.Transformer transformer)
Add a new transform to the given pack, dealing properly with options specified in the transformer.


addTransforms

public abstract void addTransforms()
Add transforms to the Scene. Derived classes should do most of their added functionality in this method.


compile

public void compile(java.lang.String modelName,
                    CompositeActor toplevel,
                    GeneratorAttribute attribute)
             throws java.lang.Exception
Compile the given model with the given name. This method invokes other methods of this class to actually perform the compilation.

Throws:
java.lang.Exception

generateCode

public void generateCode(java.lang.String[] args)
Call soot.Main.main(), which does command line argument processing and then starts the transformation. This method should be called after calling initialize() and addTransforms().

Parameters:
args - Soot command line arguments to be passed to soot.Main.main().

initialize

public void initialize(CompositeActor toplevel)
                throws IllegalActionException,
                       NameDuplicationException
Read in a MoML class, sanitize the top level name, initialize the model. Usually initialize() is called after calling readInModel().

If the director is an SDF director, then the number of iterations is handled specially. If the director is an SDF director and a parameter called "copernicus_iterations" is present, then the value of that parameter is used as the number of iterations. If the director is an SDF director, and there is no "copernicus_iterations" parameter but the "ptolemy.ptII.copernicusIterations" Java property is set, then the value of that property is used as the number of iterations.

Parameters:
toplevel - The model we are generating code for.
Throws:
IllegalActionException
NameDuplicationException

toplevel

public CompositeActor toplevel()
Return the model that we are generating code for.


addStandardOptimizations

public static void addStandardOptimizations(soot.Pack pack,
                                            int time)
Add transforms corresponding to the standard soot optimizations to the given pack.


_parseArgs

protected java.lang.String[] _parseArgs(GeneratorAttribute attribute)
                                 throws java.lang.Exception
Parse any code generator specific arguments. Derived classes should override this method to extract any code generator-specific variables from the GeneratorAttribute.

Throws:
java.lang.Exception