public ConsList<Binding> matches(TypeHierarchy types, Method method, TACInstruction instr) {
if (!(instr instanceof EntryInstruction))
return null;
EntryInstruction invoke = (EntryInstruction) instr;
IMethodBinding binding = invoke.resolveBinding();
if (methodName != null && !(methodName.equals(binding.getName())))
return null;
if (thisType != null && !types.existsCommonSubtype(thisType, binding.getDeclaringClass().getQualifiedName()))
return null;
//it's ok if we have a receiver and we're static (we just won't use it), but not the other way around.
if (invoke.getReceiver() == null && !isStatic)
return null;
ConsList<Binding> vars = ConsList.empty();
if (paramTypes != null) {
if (binding.getParameterTypes().length != paramTypes.length)
return null;
Variable[] params = method.getParams();
for (int ndx = 0; ndx < paramTypes.length; ndx++) {
if (!types.existsCommonSubtype(paramTypes[ndx], binding.getParameterTypes()[ndx].getQualifiedName()))
return null;
vars = ConsList.cons(new Binding(paramNames[ndx], params[ndx]), vars);
}
}
if (!isStatic)
vars = ConsList.cons(new Binding(Constraint.RECEIVER, invoke.getReceiver()), vars);
return vars;
}