Fixed tables in script runtime functions breaking

This commit is contained in:
Deukhoofd 2019-01-26 14:03:22 +01:00
parent 65ae6f6f06
commit ee36060dd6
No known key found for this signature in database
GPG Key ID: B4C087AC81641654
1 changed files with 22 additions and 13 deletions

View File

@ -47,32 +47,41 @@ namespace Upsilon.BaseTypes.ScriptFunction
for (var index = 0; index < variables.Length; index++) for (var index = 0; index < variables.Length; index++)
{ {
var parameter = option.Parameters[index]; var parameter = option.Parameters[index];
var parameterSymbol = ((UserDataVariableSymbol) parameter.VariableSymbol);
var v = variables[index]; var v = variables[index];
if (v == null) if (v == null)
{ {
continue; continue;
} }
System.Type parameterType; System.Type parameterType;
if (v is GenericUserData ud) if (v is GenericUserData ud)
parameterType = ud.GetCSharpType(); parameterType = ud.GetCSharpType();
else else
parameterType = v.GetType(); parameterType = v.GetType();
if (parameterSymbol.BoundTypeDefinition != null) if (parameter.VariableSymbol is UserDataVariableSymbol parameterSymbol)
{ {
var validSymbol = if (parameterSymbol.BoundTypeDefinition != null)
parameterSymbol.BoundTypeDefinition.ValidInternalTypes.Any(validType => {
var validSymbol =
parameterSymbol.BoundTypeDefinition.ValidInternalTypes.Any(validType =>
{
var b = validType.IsAssignableFrom(parameterType);
if (b) return true;
if (parameterType.IsGenericType &&
validType.IsAssignableFrom(parameterType.GetGenericTypeDefinition()))
return true;
return false;
});
if (!validSymbol)
{ {
var b = validType.IsAssignableFrom(parameterType); isCompatible = false;
if (b) return true; break;
if (parameterType.IsGenericType && }
validType.IsAssignableFrom(parameterType.GetGenericTypeDefinition())) }
return true; }
return false; else if (parameter.VariableSymbol is TableVariableSymbol tableVariableSymbol)
}); {
if (!validSymbol) if (parameterType.GetScriptType() != BaseTypes.Type.Table)
{ {
isCompatible = false; isCompatible = false;
break; break;