create or get an entry for the class clazz.
if the corresponding entry already exist, the entry is returned
else entry is first created else returned.
this algorithm is done in all class inheritance DAG until
the corresponding entry exist or the class Object is found.
unlike to the Java inheritance DAG, the parent class of an
interface is the Object class.
return the parameter types of the current method.
a parameter type is the lowest common subtype of all parameter
types of the methods that composed the multi-method.
return the return type of the current method.
a return type is the lowest common subtype of all return
types of the methods that composed the multi-method.
init the current entry, called after the first creation
of the Entry object.
this method is called once by parent.
this method is used by addToParentEntry.
return true if there is a path in the dag that
begin at the entry of the class a and end at the entry of
the class b.
the classes a and b must be already known.
see isPath(Class, Class)
cause isPath() is called in propagate method,
operation number must be the minorOp.
if this method is called directly, the minorOp must be
incremented.
class Test extends PatternMatcher
{
interface Tree {}
class Leaf implements Tree {
int value;
}
class Node implements Tree {
Tree left,right;
}
public int sum(Node node)
{ return sum(left)+sum(right); }
public int sum(Leaf leaf)
{ return value; }
public int sum(Tree tree)
{ return ((Integer)match("sum",tree)).intValue(); }
public static void main(String[] args) {
Tree tree=new Node(new Node(new Leaf(1),new Leaf(3)),new Leaf(7));
System.out.println("sum "+sum(tree));
}
}