Fixes for binding

This commit is contained in:
Deukhoofd 2018-12-13 19:04:23 +01:00
parent 599c535ddd
commit 07043e1ab4
No known key found for this signature in database
GPG Key ID: B4C087AC81641654
3 changed files with 9 additions and 6 deletions

View File

@ -289,7 +289,8 @@ namespace Upsilon.Binder
{ {
if (udSymbol.Parent != null ) if (udSymbol.Parent != null )
{ {
if (udSymbol.Parent.Properties.TryGetValue(resolved.Name, out var ubProperty) && ubProperty is UserDataBoundMethod ubMethod) if (udSymbol.Parent.Properties.TryGetValue(resolved.Name.ToLowerInvariant(),
out var ubProperty) && ubProperty is UserDataBoundMethod ubMethod)
{ {
returnType = ubMethod.ResultType; returnType = ubMethod.ResultType;
var (isValid, error, wrongParameter) = ubMethod.ValidateParameters(parameters.ToImmutable()); var (isValid, error, wrongParameter) = ubMethod.ValidateParameters(parameters.ToImmutable());

View File

@ -9,17 +9,19 @@ namespace Upsilon.Binder.VariableSymbols
{ {
public class InternalFunctionParameter public class InternalFunctionParameter
{ {
public InternalFunctionParameter(Type type, bool isOptional) public InternalFunctionParameter(string name, Type type, bool isOptional)
{ {
ValidTypes = type; ValidTypes = type;
IsOptional = isOptional; IsOptional = isOptional;
Name = name;
} }
public string Name { get; }
public Type ValidTypes { get; } public Type ValidTypes { get; }
public bool IsOptional { get; } public bool IsOptional { get; }
} }
private InternalFunctionParameter[] FunctionParameters { get; } public InternalFunctionParameter[] FunctionParameters { get; }
private int MinimalParametersRequired { get; } private int MinimalParametersRequired { get; }
public InternalFunctionVariableSymbol(string name, bool local, Type resultType, InternalFunctionParameter[] functionParameters) public InternalFunctionVariableSymbol(string name, bool local, Type resultType, InternalFunctionParameter[] functionParameters)

View File

@ -63,7 +63,7 @@ namespace Upsilon.StandardLibraries
func.Value.MethodInfoFunction.GetParameterInfo().Select(typeInfo => func.Value.MethodInfoFunction.GetParameterInfo().Select(typeInfo =>
{ {
var derivedType = DeriveValidTypes(typeInfo.Type); var derivedType = DeriveValidTypes(typeInfo.Type);
return new InternalFunctionVariableSymbol.InternalFunctionParameter(derivedType, return new InternalFunctionVariableSymbol.InternalFunctionParameter(func.Key, derivedType,
typeInfo.IsOptional); typeInfo.IsOptional);
}).ToArray()) }).ToArray())
{ {
@ -123,7 +123,7 @@ namespace Upsilon.StandardLibraries
for (var i = 0; i < genericParameters.Length - 1; i++) for (var i = 0; i < genericParameters.Length - 1; i++)
{ {
var t = DeriveValidTypes(genericParameters[i]); var t = DeriveValidTypes(genericParameters[i]);
parameters.Add(new InternalFunctionVariableSymbol.InternalFunctionParameter(t, false)); parameters.Add(new InternalFunctionVariableSymbol.InternalFunctionParameter(name, t, false));
} }
} }
@ -136,7 +136,7 @@ namespace Upsilon.StandardLibraries
var genericParameters = type.GetGenericArguments(); var genericParameters = type.GetGenericArguments();
return new InternalFunctionVariableSymbol(name, true, Type.Nil, return new InternalFunctionVariableSymbol(name, true, Type.Nil,
genericParameters.Select(DeriveValidTypes).Select(t => genericParameters.Select(DeriveValidTypes).Select(t =>
new InternalFunctionVariableSymbol.InternalFunctionParameter(t, false)).ToArray()); new InternalFunctionVariableSymbol.InternalFunctionParameter(name, t, false)).ToArray());
} }
public static Type DeriveValidTypes(System.Type type) public static Type DeriveValidTypes(System.Type type)