Skip to content

Commit

Permalink
Differentiate real matches from guessed ones
Browse files Browse the repository at this point in the history
  • Loading branch information
praeclarum committed Aug 4, 2018
1 parent a1061dc commit 0f5567c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CLanguage/Interpreter/FunctionContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public override ResolvedVariable ResolveVariable (string name, CType[] argTypes)
for (var i = 0; i < exe.Functions.Count; i++) {
var f = exe.Functions[i];
if (f.Name == name && string.IsNullOrEmpty (f.NameContext)) {
var score = f.FunctionType.ScoreParameterTypesMatches (argTypes);
var score = f.FunctionType.ScoreParameterTypeMatches (argTypes);
if (score > fs) {
ff = f;
fi = i;
Expand Down
2 changes: 1 addition & 1 deletion CLanguage/Syntax/FuncallExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ Overload ResolveOverload (Expression function, CType[] argTypes, EmitContext ec)
var methodq = from m in methods
let mt = m.MemberType as CFunctionType
where mt != null
let score = mt.ScoreParameterTypesMatches (argTypes)
let score = mt.ScoreParameterTypeMatches (argTypes)
where score > 0
orderby score descending
select m;
Expand Down
4 changes: 2 additions & 2 deletions CLanguage/Types/CFunctionType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,15 @@ public override string ToString()
return s;
}

public int ScoreParameterTypesMatches (CType[] argTypes)
public int ScoreParameterTypeMatches (CType[] argTypes)
{
if (argTypes == null)
return 1;

if (Parameters.Count != argTypes.Length)
return 0;

var score = 1;
var score = 2;

for (var i = 0; i < Parameters.Count; i++) {
var ft = argTypes[i];
Expand Down

0 comments on commit 0f5567c

Please sign in to comment.