|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectharpoon.Analysis.MetaMethods.MetaMethod
public class MetaMethod
MetaMethod
is a specialization of a method, function of the
types of its arguments.
For example, if we have a method foo
declared as having a single parameter of type Object
, if we
know that in a specific call site it is called with an argument of type
A
and in some other call site with an argument of type
B
, then we can
say that in the first case we call the meta-method consisting of method
<foo,A>
while in the second one we call the meta-method
<foo,B>
.
In languages that relies very heavily on
inheritance and dynamic dispatch (virtual methods) such as Java, this will
lead to a
sparser call graph, removing some unrealizable call chains. In particular,
it will simplify or even totally remove some artificial strongly connected
components of pseudo mutually recursive methods.
In short, a meta-method is simply a method plus some types for its
parameters. These types are supposed to be identically to or, preferably,
narrower than the declared types for that method. Something you should
keep in mind if you plan to use meta-methods is that many meta-methods
can be generated through specialization from the same method. So,
if you decide to modify only one of them, you should first make a copy
of it, do whatever optimizations you do on that copy and modify the
concerned call-sites to point to it.
Constructor Summary | |
---|---|
MetaMethod(HMethod hm)
Creates a MetaMethod corresponding to the method
hm and the types declared for it. |
|
MetaMethod(HMethod hm,
boolean polymorphic)
Creates a MetaMethod corresponding to the method
hm and the types declared for it. |
|
MetaMethod(HMethod hm,
GenType[] types)
Creates a MetaMethod corresponding to the method
hm and the types from the array "types". |
Method Summary | |
---|---|
boolean |
equals(Object o)
Checks the equality of this object with object
o . |
HMethod |
getHMethod()
Returns the HMethod that this meta-method
is a specialization of. |
GenType |
getType(int i)
Returns the type of the i -th parameter. |
int |
hashCode()
Computes the hash code of this object. |
static boolean |
identical(MetaMethod mm1,
MetaMethod mm2)
Checks whether two MetaMethod s are equal or not. |
int |
nbParams()
Returns the number of parameters of this metamethod. |
void |
setType(int i,
GenType gt)
Set the type of the i -th argument of this
meta-method. |
String |
toString()
Pretty printer for debug purposes. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public MetaMethod(HMethod hm, GenType[] types)
MetaMethod
corresponding to the method
hm
and the types from the array "types".
public MetaMethod(HMethod hm, boolean polymorphic)
MetaMethod
corresponding to the method
hm
and the types declared for it. The types appearing
in the declaration of the method are considered to be polymorphic or
not, depending whether polymorphic
is switched on/off.
public MetaMethod(HMethod hm)
MetaMethod
corresponding to the method
hm
and the types declared for it. All the types appearing
in the declaration of the method are considered to be polymorphic.,
that is we are maximally conservative in our initial estimation.
The types of can be specialized to by using setType
.
Method Detail |
---|
public HMethod getHMethod()
HMethod
that this
meta-method
is a specialization of.
public GenType getType(int i)
i
-th parameter.
public void setType(int i, GenType gt)
i
-th argument of this
meta-method. The arguments are 0-indexed, with the receiver of the
method in the first place if the method is non-static. This method
should be used to specialize the types of the arguments.
public int nbParams()
this
metamethod.
public int hashCode()
this
object.
hashCode
in class Object
public boolean equals(Object o)
this
object with object
o
.
equals
in class Object
public static boolean identical(MetaMethod mm1, MetaMethod mm2)
MetaMethod
s are equal or not.
handle null
arguments.
public String toString()
toString
in class Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |