Fix parameters complaining they're not valid when they are valid
This commit is contained in:
parent
284ba2cf54
commit
613e9dcb09
|
@ -29,6 +29,16 @@ namespace Upsilon.BaseTypes
|
|||
UserData = userData;
|
||||
}
|
||||
|
||||
public TypeContainer(Type type, string userData)
|
||||
{
|
||||
if (string.IsNullOrEmpty(userData))
|
||||
{
|
||||
throw new Exception("Userdata name was null or empty. Not setting this properly will lead to issues later on.");
|
||||
}
|
||||
Type = type;
|
||||
UserData = userData;
|
||||
}
|
||||
|
||||
public static implicit operator TypeContainer (Type type)
|
||||
{
|
||||
return new TypeContainer(type);
|
||||
|
@ -102,6 +112,11 @@ namespace Upsilon.BaseTypes
|
|||
RealType = realType;
|
||||
}
|
||||
|
||||
public UndefinedUserDataTypeContainer(Type t, System.Type realType) : base(t, "unset")
|
||||
{
|
||||
RealType = realType;
|
||||
}
|
||||
|
||||
private string _userData;
|
||||
|
||||
public override string UserData
|
||||
|
|
|
@ -219,12 +219,15 @@ namespace Upsilon.BoundTypes
|
|||
(UserDataBoundTypeDefinition) ((UserDataVariableSymbol) variable).BoundTypeDefinition;
|
||||
if (parent.ValidInternalTypes.Length != 0)
|
||||
{
|
||||
if (functionParameter.ActualType != null &&
|
||||
!parent.ValidInternalTypes.Any(x => string.Equals(x.Name, functionParameter.ActualType)))
|
||||
if (functionParameter.ActualType != null)
|
||||
{
|
||||
if (!parent.ValidInternalTypes.Any(x =>
|
||||
string.Equals(x.Name, functionParameter.ActualType)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!string.Equals(parent.Name, functionParameter.ActualType, StringComparison.InvariantCultureIgnoreCase))
|
||||
}
|
||||
else if (!string.Equals(parent.Name, functionParameter.ActualType, StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -147,7 +147,12 @@ namespace Upsilon.StandardLibraries
|
|||
public static TypeContainer DeriveValidTypes(System.Type type)
|
||||
{
|
||||
if (type.IsEnum)
|
||||
return Type.UserData | Type.Number;
|
||||
{
|
||||
var boundEnumType = BoundTypeHandler.GetTypeName(type);
|
||||
if (boundEnumType != null)
|
||||
return new TypeContainer(Type.UserData | Type.Number, boundEnumType);
|
||||
return new UndefinedUserDataTypeContainer(Type.UserData | Type.Number, type);
|
||||
}
|
||||
|
||||
var typeCode = System.Type.GetTypeCode(type);
|
||||
switch (typeCode)
|
||||
|
@ -169,9 +174,6 @@ namespace Upsilon.StandardLibraries
|
|||
case TypeCode.Char:
|
||||
case TypeCode.String:
|
||||
return Type.String;
|
||||
case TypeCode.Object:
|
||||
// allows every type
|
||||
return (Type) 255;
|
||||
}
|
||||
if (type == typeof(ScriptString))
|
||||
return Type.String;
|
||||
|
@ -192,8 +194,10 @@ namespace Upsilon.StandardLibraries
|
|||
if (type == typeof(ScriptType))
|
||||
// allows every type
|
||||
return (Type) 255;
|
||||
|
||||
return Type.UserData;
|
||||
var boundType = BoundTypeHandler.GetTypeName(type);
|
||||
if (boundType != null)
|
||||
return new TypeContainer(boundType);
|
||||
return Type.Unknown;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue