General fixes tweaks and things

This commit is contained in:
2018-12-03 18:32:27 +01:00
parent 6ba3860e84
commit 5b0ce2e52c
20 changed files with 240 additions and 28 deletions

View File

@@ -15,6 +15,6 @@ namespace Upsilon.BaseTypes.ScriptFunction
return null;
}
public abstract ScriptType Run(Diagnostics diagnostics, ScriptType[] variables, Script script);
public abstract ScriptType Run(Diagnostics diagnostics, ScriptType[] variables, Script script, EvaluationScope scope);
}
}

View File

@@ -9,12 +9,15 @@ namespace Upsilon.BaseTypes.ScriptFunction
{
internal class ScriptMethodInfoFunction : ScriptFunction
{
public ScriptMethodInfoFunction(UserDataMethod method, object o, bool directTypeManipulation, bool passScriptReference = false)
public ScriptMethodInfoFunction(UserDataMethod method, object o, bool directTypeManipulation,
bool passScriptReference = false, bool passScopeReference = false)
{
_method = method;
_object = o;
_directTypeManipulation = directTypeManipulation;
_passScriptReference = passScriptReference;
_passScopeReference = passScopeReference;
ReturnType = _method.ReturnType;
}
@@ -22,6 +25,7 @@ namespace Upsilon.BaseTypes.ScriptFunction
private readonly object _object;
private readonly bool _directTypeManipulation;
private readonly bool _passScriptReference;
private readonly bool _passScopeReference;
public System.Type ReturnType { get; }
public IEnumerable<UserDataMethod.UserDataMethodParameter> GetParameterInfo()
@@ -29,7 +33,7 @@ namespace Upsilon.BaseTypes.ScriptFunction
return _method.GetMethods().First().Parameters;
}
public override ScriptType Run(Diagnostics diagnostics, ScriptType[] variables, Script script)
public override ScriptType Run(Diagnostics diagnostics, ScriptType[] variables, Script script, EvaluationScope scope)
{
var types = _directTypeManipulation
? variables.Select(x => x.GetType()).ToArray()
@@ -44,6 +48,8 @@ namespace Upsilon.BaseTypes.ScriptFunction
var objects = new List<object>();
if (_passScriptReference)
objects.Add(script);
if (_passScopeReference)
objects.Add(scope);
objects.AddRange(_directTypeManipulation
? variables.Select(x => (object) x).ToList()
: variables.Select(x => x.ToCSharpObject()).ToList());

View File

@@ -19,7 +19,7 @@ namespace Upsilon.BaseTypes.ScriptFunction
EvaluationScope = evaluationScope;
}
public override ScriptType Run(Diagnostics diagnostics, ScriptType[] variables, Script script)
public override ScriptType Run(Diagnostics diagnostics, ScriptType[] variables, Script script, EvaluationScope scope)
{
var innerEvaluator = new Evaluator.Evaluator(diagnostics, EvaluationScope, script);
for (var i = 0; i < Parameters.Length; i++)