Reworked script function attribute, added initial math library

This commit is contained in:
2018-12-07 16:11:52 +01:00
parent 9bd82174f2
commit ac05647d71
15 changed files with 95 additions and 29 deletions

View File

@@ -3,7 +3,7 @@ using Upsilon.Text;
namespace Upsilon.BaseTypes.UserData
{
internal class GenericUserData : ScriptType, IUserData
internal sealed class GenericUserData : ScriptType, IUserData
{
public GenericUserData(object dictionary)
{
@@ -12,7 +12,7 @@ namespace Upsilon.BaseTypes.UserData
}
public override Type Type => Type.UserData;
protected virtual object Value { get; }
private object Value { get; }
private readonly UserDataType _typeInfo;
public override object ToCSharpObject()
@@ -25,7 +25,7 @@ namespace Upsilon.BaseTypes.UserData
return Value.GetType();
}
public virtual ScriptType Get(Diagnostics diagnostics, TextSpan span, ScriptType index, EvaluationScope scope)
public ScriptType Get(Diagnostics diagnostics, TextSpan span, ScriptType index, EvaluationScope scope)
{
var s = index.ToCSharpObject().ToString();
var (type, failed, error) = _typeInfo.Get(Value, s);
@@ -36,7 +36,7 @@ namespace Upsilon.BaseTypes.UserData
return type;
}
public virtual void Set(Diagnostics diagnostics, TextSpan span, ScriptType index, ScriptType value)
public void Set(Diagnostics diagnostics, TextSpan span, ScriptType index, ScriptType value)
{
var s = index.ToCSharpObject().ToString();
var (failed, error) = _typeInfo.Set(Value, s, value);