Score scoreMostSpecific(IMethodDeclaration d1, IMethodDeclaration d2, bool useInstance) { try { Context s1 = context.newLocalContext(); d1.registerParameters(s1); Context s2 = context.newLocalContext(); d2.registerParameters(s2); IEnumerator <Argument> it1 = methodCall.makeArguments(context, d1).GetEnumerator(); IEnumerator <Argument> it2 = methodCall.makeArguments(context, d2).GetEnumerator(); while (it1.MoveNext() && it2.MoveNext()) { Argument as1 = it1.Current; Argument as2 = it2.Current; IParameter ar1 = d1.getParameters().find(as1.GetName()); IParameter ar2 = d2.getParameters().find(as2.GetName()); if (as1.GetName().Equals(as2.GetName())) { // the general case with named arguments IType t1 = ar1.GetIType(s1); IType t2 = ar2.GetIType(s2); // try resolving runtime type if (useInstance && t1 is CategoryType && t2 is CategoryType) { Object value = as1.getExpression().interpret(context); // in the named case as1==as2, so only interpret 1 if (value is IInstance) { CategoryType actual = ((IInstance)value).getType(); Score score = actual.scoreMostSpecific(context, (CategoryType)t1, (CategoryType)t2); if (score != Score.SIMILAR) { return(score); } } } if (t1.isMoreSpecificThan(s2, t2)) { return(Score.BETTER); } if (t2.isMoreSpecificThan(s1, t1)) { return(Score.WORSE); } } else { // specific case for single anonymous argument Specificity?sp1 = d1.computeSpecificity(s1, ar1, as1, useInstance); Specificity?sp2 = d2.computeSpecificity(s2, ar2, as2, useInstance); if (sp1 > sp2) { return(Score.BETTER); } if (sp2 > sp1) { return(Score.WORSE); } } } } catch (PromptoError) { } return(Score.SIMILAR); }
public Specificity?computeSpecificity(Context context, IParameter parameter, Argument argument, bool useInstance) { return(wrapped.computeSpecificity(context, parameter, argument, useInstance)); }