Package ptolemy.copernicus.shallow
Class ShallowModelTransformer
- java.lang.Object
-
- soot.Transformer
-
- soot.SceneTransformer
-
- ptolemy.copernicus.shallow.ShallowModelTransformer
-
- All Implemented Interfaces:
soot.HasPhaseOptions
public class ShallowModelTransformer extends soot.SceneTransformer implements soot.HasPhaseOptions
Read in a MoML model and generate a Java class that creates the same model. (i.e. shallow code generation) No attempt is made to analyze actor code. This is primarily useful for using the Java compiler to find bugs, and removing MoML from shipped code.- Since:
- Ptolemy II 2.0
- Version:
- $Id$
- Author:
- Stephen Neuendorffer, Christopher Hylands
- Pt.AcceptedRating:
- Red (cxh)
- Pt.ProposedRating:
- Red (cxh)
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
createFieldsForAttributes(soot.jimple.JimpleBody body, NamedObj context, soot.Local contextLocal, NamedObj namedObj, soot.Local namedObjLocal, soot.SootClass theClass, java.util.HashSet createdSet)
Create and set attributes.static java.lang.String
getBufferFieldName(TypedIORelation relation, int channel, Type type)
Return the name of the field that is created to represent the given channel of the given type of the given relation.java.lang.String
getDeclaredOptions()
Return the declared options.java.lang.String
getDefaultOptions()
Return the default options.static java.lang.String
getFieldNameForAttribute(Attribute attribute, NamedObj context)
Return the name of the field that is created for the given attribute.static java.lang.String
getFieldNameForEntity(Entity entity, NamedObj context)
Return the name of the field that is created for the given entity.static java.lang.String
getFieldNameForPort(Port port, NamedObj context)
Return the name of the field that is created for the given port.static java.lang.String
getFieldNameForRelation(Relation relation, NamedObj context)
Return the name of the field that is created for the given entity.java.lang.String
getPhaseName()
Return the phase name.protected void
internalTransform(java.lang.String phaseName, java.util.Map options)
Perform the shallow model transformation.static ShallowModelTransformer
v(CompositeEntity model)
Return an instance of this transformer that will operate on the given model.
-
-
-
Method Detail
-
v
public static ShallowModelTransformer v(CompositeEntity model)
Return an instance of this transformer that will operate on the given model. The model is assumed to already have been properly initialized so that resolved types and other static properties of the model can be inspected.- Parameters:
model
- The model that this class will operate on.- Returns:
- An instance of ShallowModelTransformer that operates on the model.
-
createFieldsForAttributes
public static void createFieldsForAttributes(soot.jimple.JimpleBody body, NamedObj context, soot.Local contextLocal, NamedObj namedObj, soot.Local namedObjLocal, soot.SootClass theClass, java.util.HashSet createdSet)
Create and set attributes.- Parameters:
body
- The Jimple body.context
- The context.contextLocal
- The context for localsnamedObj
- The NamedObj that contains the attributes.namedObjLocal
- The NamedObj where we create locals.theClass
- The soot class.createdSet
- A set that contains the full names of created objects.
-
getBufferFieldName
public static java.lang.String getBufferFieldName(TypedIORelation relation, int channel, Type type)
Return the name of the field that is created to represent the given channel of the given type of the given relation.- Parameters:
relation
- The relationchannel
- The channel numbertype
- The type- Returns:
- the name of the buffer field.
-
getDefaultOptions
public java.lang.String getDefaultOptions()
Return the default options.- Specified by:
getDefaultOptions
in interfacesoot.HasPhaseOptions
- Returns:
- the empty string.
-
getDeclaredOptions
public java.lang.String getDeclaredOptions()
Return the declared options.- Specified by:
getDeclaredOptions
in interfacesoot.HasPhaseOptions
- Returns:
- The string "targetpackage", which is the only declared option.
-
getFieldNameForEntity
public static java.lang.String getFieldNameForEntity(Entity entity, NamedObj context)
Return the name of the field that is created for the given entity.- Parameters:
entity
- The entitycontext
- The context of the entity- Returns:
- The name of the field that is created for the given entity.
-
getFieldNameForPort
public static java.lang.String getFieldNameForPort(Port port, NamedObj context)
Return the name of the field that is created for the given port.- Parameters:
port
- The portcontext
- The context of the port- Returns:
- The name of the field that is created for the given port.
-
getFieldNameForAttribute
public static java.lang.String getFieldNameForAttribute(Attribute attribute, NamedObj context)
Return the name of the field that is created for the given attribute.- Parameters:
attribute
- The attributecontext
- The context of the attribute- Returns:
- The name of the field that is created for the given attribute.
-
getFieldNameForRelation
public static java.lang.String getFieldNameForRelation(Relation relation, NamedObj context)
Return the name of the field that is created for the given entity.- Parameters:
relation
- The relationcontext
- The context of the relation- Returns:
- The name of the field that is created for the given relation.
-
getPhaseName
public java.lang.String getPhaseName()
Return the phase name.- Specified by:
getPhaseName
in interfacesoot.HasPhaseOptions
- Returns:
- the empty string.
-
internalTransform
protected void internalTransform(java.lang.String phaseName, java.util.Map options)
Perform the shallow model transformation.- Specified by:
internalTransform
in classsoot.SceneTransformer
- Parameters:
phaseName
- The name of the phase.options
- A map of options
-
-