ptolemy.copernicus.kernel
Class CastAndInstanceofEliminator

java.lang.Object
  extended by soot.Transformer
      extended by soot.BodyTransformer
          extended by ptolemy.copernicus.kernel.CastAndInstanceofEliminator

public class CastAndInstanceofEliminator
extends soot.BodyTransformer

A transformer that remove unnecessary casts and instanceof checks. Note that this relies on properly inferred Java types to operate properly. If you create code that has types which are too specific (relative to the inferred types) then this transformer will likely create code that is no longer verifiable.

Since:
Ptolemy II 4.0
Version:
$Id: CastAndInstanceofEliminator.java,v 1.43 2006/10/25 00:17:26 cxh Exp $
Author:
Stephen Neuendorffer
Accepted Rating:
Red (cxh)
Proposed Rating:
Red (cxh)

Method Summary
static void eliminateCastsAndInstanceOf(soot.Body body, java.lang.String phaseName, java.util.Set unsafeLocalSet, boolean debug)
           
 java.lang.String getDeclaredOptions()
           
protected  void internalTransform(soot.Body b, java.lang.String phaseName, java.util.Map options)
           
static void replaceCast(soot.ValueBox box, soot.Hierarchy hierarchy, soot.Type checkType, soot.Value op, soot.Type opType, boolean debug)
          Remove the case in the given box, if possible.
static void replaceInstanceofCheck(soot.ValueBox box, soot.Hierarchy hierarchy, soot.Type checkType, soot.Type opType, boolean debug)
          Statically evaluate the instance of Check in the given box, if possible.
static CastAndInstanceofEliminator v()
           
 
Methods inherited from class soot.BodyTransformer
transform, transform, transform
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

v

public static CastAndInstanceofEliminator v()

getDeclaredOptions

public java.lang.String getDeclaredOptions()

internalTransform

protected void internalTransform(soot.Body b,
                                 java.lang.String phaseName,
                                 java.util.Map options)
Specified by:
internalTransform in class soot.BodyTransformer

eliminateCastsAndInstanceOf

public static void eliminateCastsAndInstanceOf(soot.Body body,
                                               java.lang.String phaseName,
                                               java.util.Set unsafeLocalSet,
                                               boolean debug)

replaceInstanceofCheck

public static void replaceInstanceofCheck(soot.ValueBox box,
                                          soot.Hierarchy hierarchy,
                                          soot.Type checkType,
                                          soot.Type opType,
                                          boolean debug)
Statically evaluate the instance of Check in the given box, if possible. If opType is always an instance of checkType, based on the given hierarchy, then replace with a true constant. If opType is never an instance of checkType, then replace with a false constant.


replaceCast

public static void replaceCast(soot.ValueBox box,
                               soot.Hierarchy hierarchy,
                               soot.Type checkType,
                               soot.Value op,
                               soot.Type opType,
                               boolean debug)
Remove the case in the given box, if possible. If opType is always an instance of checkType, based on the given hierarchy, then replace with an assignment.