Class 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 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 locals
        namedObj - 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 relation
        channel - The channel number
        type - The type
        Returns:
        the name of the buffer field.
      • getDefaultOptions

        public java.lang.String getDefaultOptions()
        Return the default options.
        Specified by:
        getDefaultOptions in interface soot.HasPhaseOptions
        Returns:
        the empty string.
      • getDeclaredOptions

        public java.lang.String getDeclaredOptions()
        Return the declared options.
        Specified by:
        getDeclaredOptions in interface soot.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 entity
        context - 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 port
        context - 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 attribute
        context - 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 relation
        context - 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 interface soot.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 class soot.SceneTransformer
        Parameters:
        phaseName - The name of the phase.
        options - A map of options