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;
|
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)
|
public static implicit operator TypeContainer (Type type)
|
||||||
{
|
{
|
||||||
return new TypeContainer(type);
|
return new TypeContainer(type);
|
||||||
|
@ -102,6 +112,11 @@ namespace Upsilon.BaseTypes
|
||||||
RealType = realType;
|
RealType = realType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public UndefinedUserDataTypeContainer(Type t, System.Type realType) : base(t, "unset")
|
||||||
|
{
|
||||||
|
RealType = realType;
|
||||||
|
}
|
||||||
|
|
||||||
private string _userData;
|
private string _userData;
|
||||||
|
|
||||||
public override string UserData
|
public override string UserData
|
||||||
|
|
|
@ -219,12 +219,15 @@ namespace Upsilon.BoundTypes
|
||||||
(UserDataBoundTypeDefinition) ((UserDataVariableSymbol) variable).BoundTypeDefinition;
|
(UserDataBoundTypeDefinition) ((UserDataVariableSymbol) variable).BoundTypeDefinition;
|
||||||
if (parent.ValidInternalTypes.Length != 0)
|
if (parent.ValidInternalTypes.Length != 0)
|
||||||
{
|
{
|
||||||
if (functionParameter.ActualType != null &&
|
if (functionParameter.ActualType != null)
|
||||||
!parent.ValidInternalTypes.Any(x => string.Equals(x.Name, functionParameter.ActualType)))
|
{
|
||||||
|
if (!parent.ValidInternalTypes.Any(x =>
|
||||||
|
string.Equals(x.Name, functionParameter.ActualType)))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!string.Equals(parent.Name, functionParameter.ActualType, StringComparison.InvariantCultureIgnoreCase))
|
}
|
||||||
|
else if (!string.Equals(parent.Name, functionParameter.ActualType, StringComparison.InvariantCultureIgnoreCase))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -147,7 +147,12 @@ namespace Upsilon.StandardLibraries
|
||||||
public static TypeContainer DeriveValidTypes(System.Type type)
|
public static TypeContainer DeriveValidTypes(System.Type type)
|
||||||
{
|
{
|
||||||
if (type.IsEnum)
|
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);
|
var typeCode = System.Type.GetTypeCode(type);
|
||||||
switch (typeCode)
|
switch (typeCode)
|
||||||
|
@ -169,9 +174,6 @@ namespace Upsilon.StandardLibraries
|
||||||
case TypeCode.Char:
|
case TypeCode.Char:
|
||||||
case TypeCode.String:
|
case TypeCode.String:
|
||||||
return Type.String;
|
return Type.String;
|
||||||
case TypeCode.Object:
|
|
||||||
// allows every type
|
|
||||||
return (Type) 255;
|
|
||||||
}
|
}
|
||||||
if (type == typeof(ScriptString))
|
if (type == typeof(ScriptString))
|
||||||
return Type.String;
|
return Type.String;
|
||||||
|
@ -192,8 +194,10 @@ namespace Upsilon.StandardLibraries
|
||||||
if (type == typeof(ScriptType))
|
if (type == typeof(ScriptType))
|
||||||
// allows every type
|
// allows every type
|
||||||
return (Type) 255;
|
return (Type) 255;
|
||||||
|
var boundType = BoundTypeHandler.GetTypeName(type);
|
||||||
return Type.UserData;
|
if (boundType != null)
|
||||||
|
return new TypeContainer(boundType);
|
||||||
|
return Type.Unknown;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue