Adds basics for predefined function parameter types
This commit is contained in:
42
Upsilon/BoundTypes/BoundTypeHandler.cs
Normal file
42
Upsilon/BoundTypes/BoundTypeHandler.cs
Normal 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; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user