harpoon.Analysis.Realtime
Class ClassReplacer

java.lang.Object
  extended by harpoon.Analysis.Transformation.MethodMutator
      extended by harpoon.Analysis.Realtime.ClassReplacer
All Implemented Interfaces:
Serializable

public class ClassReplacer
extends MethodMutator

ClassReplacer is a MethodMutator which works on any QuadForm and replaces NEW's and CALL's to one class with NEW's and CALL's to another class using a mapping function to map methods of one to methods of the other. It can also ignore (not update) listed classes or packages. This class allows you to write a wrapper for a class for which you don't have the code, and have other code selectively point to the wrapper. Currently, only QuadNoSSA and QuadWithTry are supported. This may change in the future.

See Also:
Serialized Form

Constructor Summary
ClassReplacer(HCodeFactory parent, HClass from, HClass to)
          Construct a ClassReplacer with an HCodeFactory that will replace the HClass from with to.
 
Method Summary
 void addIgnoreClasses(HClass claz)
          Do not replace references to from in the class claz.
 void addIgnorePackage(String pkg)
          Do not replace references to from in the package pkg.
 void map(HMethod from, HMethod to)
          Map a method on the original class to a method on the "to" class.
 void mapAll(HClass from, HClass to)
          Map all of the methods from HClass from to to that share the same name and method signature.
protected  HCode mutateHCode(HCodeAndMaps input)
          Make the actual changes to the HCode.
 
Methods inherited from class harpoon.Analysis.Transformation.MethodMutator
cloneHCode, codeFactory, mutateCodeName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClassReplacer

public ClassReplacer(HCodeFactory parent,
                     HClass from,
                     HClass to)
Construct a ClassReplacer with an HCodeFactory that will replace the HClass from with to.

Method Detail

addIgnorePackage

public void addIgnorePackage(String pkg)
Do not replace references to from in the package pkg.


addIgnoreClasses

public void addIgnoreClasses(HClass claz)
Do not replace references to from in the class claz. from is automatically ignored.


map

public void map(HMethod from,
                HMethod to)
Map a method on the original class to a method on the "to" class. Only mapped method referencesd will be replaced.


mapAll

public void mapAll(HClass from,
                   HClass to)
Map all of the methods from HClass from to to that share the same name and method signature. Warning: slow for big classes.


mutateHCode

protected HCode mutateHCode(HCodeAndMaps input)
Make the actual changes to the HCode.

Overrides:
mutateHCode in class MethodMutator