|
@@ -3,9 +3,11 @@ using System.Collections.Generic;
|
|
|
using System.Drawing;
|
|
|
using System.Linq;
|
|
|
using System.Runtime.CompilerServices;
|
|
|
+using System.Threading;
|
|
|
using NTERA.Core;
|
|
|
using NTERA.EmuEra.Game.EraEmu.Content;
|
|
|
using NTERA.Engine.Compiler;
|
|
|
+using NTERA.Engine.Runtime.Base;
|
|
|
|
|
|
namespace NTERA.Engine.Runtime
|
|
|
{
|
|
@@ -18,7 +20,9 @@ namespace NTERA.Engine.Runtime
|
|
|
|
|
|
public List<FunctionDefinition> TotalProcedureDefinitions { get; set; } = new List<FunctionDefinition>(BaseDefinitions.DefaultGlobalFunctions);
|
|
|
public Dictionary<string, Variable> GlobalVariables { get; set; } = new Dictionary<string, Variable>();
|
|
|
- public Dictionary<string, Variable> SemiGlobalVariables { get; set; } = new Dictionary<string, Variable>();
|
|
|
+
|
|
|
+ public Value LastInputValue { get; set; }
|
|
|
+ public AutoResetEvent InputResetEvent { get; } = new AutoResetEvent(false);
|
|
|
|
|
|
public EraRuntime(IExecutionProvider executionProvider)
|
|
|
{
|
|
@@ -62,7 +66,7 @@ namespace NTERA.Engine.Runtime
|
|
|
throw;
|
|
|
}
|
|
|
|
|
|
- System.Threading.Thread.Sleep(-1);
|
|
|
+ Thread.Sleep(-1);
|
|
|
}
|
|
|
|
|
|
public ExecutionResult Call(FunctionDefinition function, IList<Parameter> parameters = null)
|
|
@@ -71,8 +75,10 @@ namespace NTERA.Engine.Runtime
|
|
|
|
|
|
foreach (var variable in function.Variables)
|
|
|
{
|
|
|
- var localVariable = new Variable(variable.Name, variable.ValueType);
|
|
|
- localVariable[0] = variable.CalculatedValue;
|
|
|
+ var localVariable = new Variable(variable.Name, variable.ValueType)
|
|
|
+ {
|
|
|
+ [0] = variable.CalculatedValue
|
|
|
+ };
|
|
|
|
|
|
localVariables.Add(variable.Name, localVariable);
|
|
|
}
|
|
@@ -94,7 +100,7 @@ namespace NTERA.Engine.Runtime
|
|
|
|
|
|
if (function.Filename == "__GLOBAL")
|
|
|
{
|
|
|
- var resultValue = Base.Functions.StaticFunctions[function.Name].Invoke(this, newContext, parameters);
|
|
|
+ var resultValue = Functions.StaticFunctions[function.Name].Invoke(this, newContext, parameters);
|
|
|
|
|
|
result = new ExecutionResult(ExecutionResultType.FunctionReturn, resultValue);
|
|
|
}
|
|
@@ -183,7 +189,7 @@ namespace NTERA.Engine.Runtime
|
|
|
case "statement":
|
|
|
string statement = node["name"];
|
|
|
|
|
|
- if (!Base.Keywords.StaticKeywords.TryGetValue(statement, out var keywordAction))
|
|
|
+ if (!Keywords.StaticKeywords.TryGetValue(statement, out var keywordAction))
|
|
|
throw new EraRuntimeException($"Unknown statement: '{statement}'");
|
|
|
|
|
|
keywordAction(this, context, node);
|
|
@@ -326,19 +332,16 @@ namespace NTERA.Engine.Runtime
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public void InputString(string input)
|
|
|
- {
|
|
|
- throw new NotImplementedException();
|
|
|
- }
|
|
|
+ public void InputString(string input) => Input(input);
|
|
|
|
|
|
- public void InputInteger(long input)
|
|
|
- {
|
|
|
- throw new NotImplementedException();
|
|
|
- }
|
|
|
+ public void InputInteger(long input) => Input(input);
|
|
|
+
|
|
|
+ public void InputSystemInteger(long input) => Input(input);
|
|
|
|
|
|
- public void InputSystemInteger(long input)
|
|
|
+ public void Input(Value value)
|
|
|
{
|
|
|
- throw new NotImplementedException();
|
|
|
+ LastInputValue = value;
|
|
|
+ InputResetEvent.Set();
|
|
|
}
|
|
|
|
|
|
public CroppedImage GetImage(string name)
|