ptolemy.copernicus.java
Class TypeSpecializerAnalysis

java.lang.Object
  extended byptolemy.copernicus.java.TypeSpecializerAnalysis

public class TypeSpecializerAnalysis
extends java.lang.Object

A transformer that modifies each class using the token types from ports. In particular, this class creates constraints in the same fashion as the Ptolemy II type system and solves those constraints. The resulting solution should correspond to valid Java types which are more specific (in the Ptolemy II sense) than the original Java types. The code is then transformed to use these more specific types.

This transformer is necessary because there are some token types that we want to make more specific, but that don't directly depend on the the types of a port. This transformation enables the token unboxing performed by the TokenToNativeTransformer

Note that this analysis assumes very little flow of control... Or at least that the types of each variable along each path are the same... as such, it works very badly if there are any instanceof checks, along with some other program constructs.

Since:
Ptolemy II 4.0
Version:
$Id: TypeSpecializerAnalysis.java,v 1.44 2004/04/13 03:16:01 cxh Exp $
Author:
Stephen Neuendorffer
Accepted Rating:
Red (cxh)
Proposed Rating:
Red (cxh)

Constructor Summary
TypeSpecializerAnalysis(java.util.List list, java.util.Set unsafeLocals)
          Specialize all token types that appear in the given list of class.
TypeSpecializerAnalysis(soot.SootClass theClass, java.util.Set unsafeLocals)
          Specialize all token types that appear in the given class.
 
Method Summary
static InequalityTerm _getInequalityTerm(soot.SootMethod method, boolean debug, soot.Value value, InequalitySolver solver, java.util.Map objectToInequalityTerm, soot.Unit unit, soot.toolkits.scalar.LocalDefs localDefs, soot.toolkits.scalar.LocalUses localUses)
           
 Type _getTokenType(java.lang.Object object)
           
 soot.Type getSpecializedSootType(soot.Local local)
           
 soot.Type getSpecializedSootType(soot.jimple.NewArrayExpr expr)
           
 soot.Type getSpecializedSootType(soot.SootField field)
           
 Type getSpecializedType(soot.Local local)
           
 Type getSpecializedType(soot.jimple.NewArrayExpr expr)
           
 Type getSpecializedType(soot.SootField field)
           
 void inlineTypeLatticeMethods(soot.SootMethod method, soot.Unit unit, soot.ValueBox box, soot.jimple.StaticInvokeExpr expr, soot.toolkits.scalar.LocalDefs localDefs, soot.toolkits.scalar.LocalUses localUses)
          Inline the given invocation point in the given box, unit, and method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TypeSpecializerAnalysis

public TypeSpecializerAnalysis(soot.SootClass theClass,
                               java.util.Set unsafeLocals)
Specialize all token types that appear in the given class. Return a map from locals and fields in the class to their new specific Ptolemy type. Exclude locals in the given set from the typing algorithm.


TypeSpecializerAnalysis

public TypeSpecializerAnalysis(java.util.List list,
                               java.util.Set unsafeLocals)
Specialize all token types that appear in the given list of class. Return a map from locals and fields in the class to their new specific Ptolemy type. Exclude locals in the given set from the typing algorithm.

Parameters:
list - A list of SootClass.
Method Detail

getSpecializedSootType

public soot.Type getSpecializedSootType(soot.Local local)

getSpecializedSootType

public soot.Type getSpecializedSootType(soot.jimple.NewArrayExpr expr)

getSpecializedSootType

public soot.Type getSpecializedSootType(soot.SootField field)

getSpecializedType

public Type getSpecializedType(soot.Local local)

getSpecializedType

public Type getSpecializedType(soot.jimple.NewArrayExpr expr)

getSpecializedType

public Type getSpecializedType(soot.SootField field)

inlineTypeLatticeMethods

public void inlineTypeLatticeMethods(soot.SootMethod method,
                                     soot.Unit unit,
                                     soot.ValueBox box,
                                     soot.jimple.StaticInvokeExpr expr,
                                     soot.toolkits.scalar.LocalDefs localDefs,
                                     soot.toolkits.scalar.LocalUses localUses)
                              throws IllegalActionException
Inline the given invocation point in the given box, unit, and method. Use the given local definition information to perform the inlining.

Throws:
IllegalActionException

_getTokenType

public Type _getTokenType(java.lang.Object object)
                   throws IllegalActionException
Throws:
IllegalActionException

_getInequalityTerm

public static InequalityTerm _getInequalityTerm(soot.SootMethod method,
                                                boolean debug,
                                                soot.Value value,
                                                InequalitySolver solver,
                                                java.util.Map objectToInequalityTerm,
                                                soot.Unit unit,
                                                soot.toolkits.scalar.LocalDefs localDefs,
                                                soot.toolkits.scalar.LocalUses localUses)