Fixed ListUserData type being unknown
This commit is contained in:
parent
e74d061177
commit
47a80d2153
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using Upsilon.BaseTypes.Number;
|
||||
using Upsilon.BaseTypes.ScriptTypeInterfaces;
|
||||
using Upsilon.BoundTypes;
|
||||
|
@ -18,7 +19,16 @@ namespace Upsilon.BaseTypes.UserData
|
|||
public ListUserData(IList list)
|
||||
{
|
||||
List = list;
|
||||
TypeName = BoundTypeHandler.GetTypeName(list.GetType());
|
||||
var type = list.GetType();
|
||||
if (type.IsArray)
|
||||
{
|
||||
TypeName = BoundTypeHandler.GetTypeName(type.GetElementType());
|
||||
}
|
||||
else
|
||||
{
|
||||
var generic = type.GetGenericArguments()[0];
|
||||
TypeName = BoundTypeHandler.GetTypeName(generic);
|
||||
}
|
||||
}
|
||||
|
||||
public ScriptType Get(Diagnostics diagnostics, TextSpan span, ScriptType index, EvaluationScope scope)
|
||||
|
@ -78,7 +88,10 @@ namespace Upsilon.BaseTypes.UserData
|
|||
}
|
||||
}
|
||||
|
||||
public override TypeContainer Type => new TypeContainer(TypeName);
|
||||
public override TypeContainer Type => new CompositeTypeContainer()
|
||||
{
|
||||
Types = new TypeContainer[]{BaseTypes.Type.Number, new TypeContainer(TypeName)}.ToImmutableArray()
|
||||
};
|
||||
public override object ToCSharpObject()
|
||||
{
|
||||
return List;
|
||||
|
|
Loading…
Reference in New Issue