|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectharpoon.Analysis.Transformation.MethodSplitter
public abstract class MethodSplitter
MethodSplitter
makes it easier to implement
transformations which specialize methods for one purpose or
another. It is meant to be subclassed. In your subclass,
you will likely want to create a few static fields of type
MethodSplitter.Token
to name your specialized
versions, override the isValidToken()
method
to include your new tokens, and override
mutateDescriptor()
and/or mutateHCode()
to effect the specialization.
Note that if you mutate the ORIGINAL
version of
a method, all split versions will inherit the mutation.
Be careful not to introduce cycles because of this ordering.
Nested Class Summary | |
---|---|
protected static class |
MethodSplitter.Token
Subclasses of MethodSplitter refer to "versions"
of the underlying method which may be named by creating
static instances of this MethodSplitter.Token
class. |
Field Summary | |
---|---|
static MethodSplitter.Token |
ORIGINAL
The ORIGINAL token represents the original pre-split
version of a method. |
Constructor Summary | |
---|---|
MethodSplitter(HCodeFactory _parent,
ClassHierarchy ch,
boolean mutateOriginalBeforeSplit)
Creates a MethodSplitter , based on the method
representations in the parent HCodeFactory . |
Method Summary | |
---|---|
protected HCodeAndMaps |
cloneHCode(HCode hc,
HMethod newmethod)
Override this method if you do not want the mutatable HCode to be a straight clone of the original HCode: for example, if the input HCodes were QuadSSI and you wanted to
clone them into QuadRSSI s before mutating. |
HCodeFactory |
codeFactory()
Returns a HCodeFactory containing representations for
the methods split by the MethodSplitter . |
protected boolean |
isValidToken(MethodSplitter.Token which)
Check the validity of a given MethodSplitter.Token . |
protected boolean |
isVirtual(HMethod m)
Utility method to determine whether a method is inheritable (and thus it's children should be split whenever it is). |
protected String |
mutateCodeName(String codeName)
Override this method to change the codename which this MethodMutator 's codefactory reports. |
protected String |
mutateDescriptor(HMethod hm,
MethodSplitter.Token which)
Override this method if you want to create mutated methods with descriptors differing from that of the original method. |
protected HCode |
mutateHCode(HCodeAndMaps input,
MethodSplitter.Token which)
Override this method to effect transformations on split methods. |
HMethod |
select(HMethod source,
MethodSplitter.Token which)
Go from a (possibly already split) method to the version of the method named by the token which . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final MethodSplitter.Token ORIGINAL
ORIGINAL
token represents the original pre-split
version of a method.
Constructor Detail |
---|
public MethodSplitter(HCodeFactory _parent, ClassHierarchy ch, boolean mutateOriginalBeforeSplit)
MethodSplitter
, based on the method
representations in the parent
HCodeFactory
.
mutateOriginalBeforeSplit
- if true
, the
mutated version of the original is cloned and given
to mutateHCode
as source for a split methods;
otherwise, the unmutated version of the original is
taken as the source for the split method. If it doesn't
matter, choose true
, as this reduces the
memory footprint.Method Detail |
---|
public final HMethod select(HMethod source, MethodSplitter.Token which)
which
.
protected boolean isVirtual(HMethod m)
public HCodeFactory codeFactory()
HCodeFactory
containing representations for
the methods split by the MethodSplitter
.
protected String mutateDescriptor(HMethod hm, MethodSplitter.Token which)
protected HCode mutateHCode(HCodeAndMaps input, MethodSplitter.Token which)
protected String mutateCodeName(String codeName)
MethodMutator
's codefactory reports.
protected HCodeAndMaps cloneHCode(HCode hc, HMethod newmethod) throws CloneNotSupportedException
QuadSSI
and you wanted to
clone them into QuadRSSI
s before mutating.
By default, this method returns hc.clone(newmethod)
.
CloneNotSupportedException
protected boolean isValidToken(MethodSplitter.Token which)
MethodSplitter.Token
.
Override if (when) your subclass defines new tokens.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |