Better handling of getting composite script types
This commit is contained in:
parent
86f47ae002
commit
44bfc90fe3
|
@ -1,5 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.Immutable;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using Upsilon.BaseTypes.Number;
|
using Upsilon.BaseTypes.Number;
|
||||||
|
@ -140,6 +142,31 @@ namespace Upsilon.BaseTypes
|
||||||
return Type.Nil;
|
return Type.Nil;
|
||||||
if (t == typeof(SimpleScriptTable))
|
if (t == typeof(SimpleScriptTable))
|
||||||
return Type.Table;
|
return Type.Table;
|
||||||
|
if (t.IsArray)
|
||||||
|
{
|
||||||
|
var elementType = t.GetElementType();
|
||||||
|
return new CompositeTypeContainer()
|
||||||
|
{
|
||||||
|
Types = new TypeContainer[]{Type.Number, GetScriptType(elementType)}.ToImmutableArray()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (typeof(IList).IsAssignableFrom(t))
|
||||||
|
{
|
||||||
|
var generic = t.GetGenericArguments()[0];
|
||||||
|
return new CompositeTypeContainer()
|
||||||
|
{
|
||||||
|
Types = new TypeContainer[]{Type.Number, GetScriptType(generic)}.ToImmutableArray()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (typeof(IDictionary).IsAssignableFrom(t))
|
||||||
|
{
|
||||||
|
var key = t.GetGenericArguments()[0];
|
||||||
|
var value = t.GetGenericArguments()[1];
|
||||||
|
return new CompositeTypeContainer()
|
||||||
|
{
|
||||||
|
Types = new[]{GetScriptType(key), GetScriptType(value)}.ToImmutableArray()
|
||||||
|
};
|
||||||
|
}
|
||||||
if (typeof(IEnumerable).IsAssignableFrom(t))
|
if (typeof(IEnumerable).IsAssignableFrom(t))
|
||||||
return Type.Table;
|
return Type.Table;
|
||||||
if (typeof(IIndexable).IsAssignableFrom(t))
|
if (typeof(IIndexable).IsAssignableFrom(t))
|
||||||
|
|
Loading…
Reference in New Issue