Adds basics for predefined function parameter types

This commit is contained in:
2018-11-28 16:18:56 +01:00
parent 062f0f84ad
commit 27a7465961
6 changed files with 98 additions and 14 deletions

View File

@@ -0,0 +1,42 @@
using System.Collections.Generic;
using Upsilon.BaseTypes;
namespace Upsilon.BoundTypes
{
public static class BoundTypeHandler
{
private static Dictionary<string, BoundTypeDefinition> _typeDefinitions = new Dictionary<string, BoundTypeDefinition>
{
{"string", new BoundTypeDefinition(Type.String, typeof(string))},
{
"number",
new BoundTypeDefinition(Type.Number,
new[] {typeof(int), typeof(long), typeof(float), typeof(double)})
},
{"bool", new BoundTypeDefinition(Type.Boolean, typeof(bool))}
};
public static BoundTypeDefinition GetTypeDefinition(string key)
{
return _typeDefinitions[key.ToLowerInvariant()];
}
}
public class BoundTypeDefinition
{
public BoundTypeDefinition(Type scriptType, System.Type[] validInternalTypes)
{
ScriptType = scriptType;
ValidInternalTypes = validInternalTypes;
}
public BoundTypeDefinition(Type scriptType, System.Type validInternalType)
{
ScriptType = scriptType;
ValidInternalTypes = new []{validInternalType};
}
public Type ScriptType { get; }
public System.Type[] ValidInternalTypes { get; }
}
}