From b9183be4e7487d56762ae1e11892baa7f6dd6656 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Sun, 20 Jan 2019 22:27:47 +0100 Subject: [PATCH] Fixes for script binding not working --- Upsilon/BaseTypes/ScriptFunction/ScriptRuntimeFunction.cs | 4 ++-- Upsilon/Binder/Binder.cs | 2 +- .../Binder/VariableSymbols/InternalFunctionVariableSymbol.cs | 3 +-- Upsilon/BoundTypes/UserDataBoundTypeDefinition.cs | 5 ++++- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Upsilon/BaseTypes/ScriptFunction/ScriptRuntimeFunction.cs b/Upsilon/BaseTypes/ScriptFunction/ScriptRuntimeFunction.cs index f3e93ea..4f8fe59 100644 --- a/Upsilon/BaseTypes/ScriptFunction/ScriptRuntimeFunction.cs +++ b/Upsilon/BaseTypes/ScriptFunction/ScriptRuntimeFunction.cs @@ -41,11 +41,11 @@ namespace Upsilon.BaseTypes.ScriptFunction { if (option.Parameters.Length != variables.Length) continue; - bool isCompatible = true; + var isCompatible = true; for (var index = 0; index < variables.Length; index++) { var parameter = option.Parameters[index]; - var parameterSymbol = ((UserDataVariableSymbol)parameter.VariableSymbol); + var parameterSymbol = ((UserDataVariableSymbol) parameter.VariableSymbol); var parameterType = variables[index].GetType(); if (parameterSymbol.BoundTypeDefinition != null) { diff --git a/Upsilon/Binder/Binder.cs b/Upsilon/Binder/Binder.cs index 5468bf0..f3ae074 100644 --- a/Upsilon/Binder/Binder.cs +++ b/Upsilon/Binder/Binder.cs @@ -245,7 +245,7 @@ namespace Upsilon.Binder } UnboundFunctionExpression unbound = null; - foreach (var functionExpression in this._unboundFunctions.Where(x => + foreach (var functionExpression in _unboundFunctions.Where(x => { if (x.Name == function.Name) { diff --git a/Upsilon/Binder/VariableSymbols/InternalFunctionVariableSymbol.cs b/Upsilon/Binder/VariableSymbols/InternalFunctionVariableSymbol.cs index 87a232f..8f7de5b 100644 --- a/Upsilon/Binder/VariableSymbols/InternalFunctionVariableSymbol.cs +++ b/Upsilon/Binder/VariableSymbols/InternalFunctionVariableSymbol.cs @@ -39,8 +39,7 @@ namespace Upsilon.Binder.VariableSymbols var callingParameter = callingParameters[i]; if (callingParameter.Type == Type.Unknown || callingParameter.Type == Type.Nil) { - isValid = false; - break; + continue; } if (!functionParameter.ValidTypes.Type.HasFlag(callingParameter.Type)) diff --git a/Upsilon/BoundTypes/UserDataBoundTypeDefinition.cs b/Upsilon/BoundTypes/UserDataBoundTypeDefinition.cs index 75038b1..f4a913b 100644 --- a/Upsilon/BoundTypes/UserDataBoundTypeDefinition.cs +++ b/Upsilon/BoundTypes/UserDataBoundTypeDefinition.cs @@ -84,7 +84,10 @@ namespace Upsilon.BoundTypes else { methods.Add(methodName, - new UserDataBoundMethod(methodName, new List() {option})); + new UserDataBoundMethod(methodName, new List() {option}) + { + Type = Type.Function + }); } }