diff --git a/DeedyDesigner/Deedy.Testing/App.xaml.cs b/DeedyDesigner/Deedy.Testing/App.xaml.cs
index cc36506..29ab6e5 100644
--- a/DeedyDesigner/Deedy.Testing/App.xaml.cs
+++ b/DeedyDesigner/Deedy.Testing/App.xaml.cs
@@ -1,6 +1,7 @@
using System.Configuration;
using System.Data;
using System.Windows;
+using Deedy.Testing;
namespace Deedy
{
@@ -9,6 +10,25 @@ namespace Deedy
///
public partial class App : Application
{
+ public App()
+ {
+ string script =
+@"
+VarP var1 111
+VarP var2 222
+Func Add var1 var2
+ LetP AddResult -1
+ math AddResult var1 var2 +
+ retu AddResult
+EndF
+
+Call Add var1 var2
+PopV result
+";
+ Todo todo = new Todo();
+ todo.Init(script);
+ todo.Redo();
+ }
}
}
diff --git a/DeedyDesigner/Deedy.Testing/Dodo.cs b/DeedyDesigner/Deedy.Testing/Dodo.cs
new file mode 100644
index 0000000..8a77aa4
--- /dev/null
+++ b/DeedyDesigner/Deedy.Testing/Dodo.cs
@@ -0,0 +1,1102 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Deedy.Testing
+{
+ ///
+ /// 解释执行「DodoScript」脚本的引擎
+ /// 仿照「C」语言执行逻辑实现
+ ///
+ public class Todo
+ {
+ ///
+ /// 运行模式
+ ///
+ public enum Mode
+ {
+ ///
+ /// 暂停运行状态
+ ///
+ Waiting,
+ ///
+ /// 正常运行状态
+ ///
+ Running,
+ ///
+ /// 当「Continue」或「Reentry」操作执行后的状态
+ ///
+ Reentry,
+ ///
+ /// 当「Break」或「Return」操作执行后的状态
+ ///
+ JumpOut,
+ }
+ ///
+ /// 脚本内部的方法定义
+ ///
+ public struct Def_FuncDefine(string name, int line)
+ {
+ public string Name = name;
+ public int Line = line;
+ }
+ ///
+ /// 外部方法的引用记录
+ ///
+ public struct Def_FuncImport(string name, Action> action)
+ {
+ public string Name = name;
+ public Action> Action = action;
+ }
+ ///
+ /// 脚本内方法调用记录
+ ///
+ public struct Def_FuncInvoke(int returnLine)
+ {
+ public int ReturnLine = returnLine;
+ public Dictionary LocalParams = [];
+ }
+ ///
+ /// 外部参数的引用记录
+ ///
+ public struct Def_ParamRefer(string name, object param)
+ {
+ public string Name = name;
+ public object Param = param;
+ }
+ ///
+ /// 当前要执行的脚本行号
+ ///
+ private int Control_CurrentLine = 0;
+ ///
+ /// 脚本调度周期,等待指令每次的等待时间
+ ///
+ private int Control_WakeupCycle = 10;
+ ///
+ /// 每条指令在开始执行时的时间,由脚本主解释逻辑负责记录
+ ///
+ private DateTime Control_CurrentTime = DateTime.Now;
+ ///
+ /// 脚本运行模式,用于外部控制正在执行的脚本的行为
+ ///
+ public Mode RunningMode { get; set; } = Mode.Waiting;
+ ///
+ /// 脚本内容
+ ///
+ private readonly List Script = [];
+
+ ///
+ /// 脚本内部的自定义方法映射表
+ ///
+ private List FuncDefines = [];
+ ///
+ /// 外部引用的可执行方法映射表
+ ///
+ private readonly List FuncImports = [];
+
+ ///
+ /// 脚本内方法调用栈
+ ///
+ private Stack Invoke_FuncStack = [];
+ ///
+ /// 调用外部方法时使用的参数栈
+ ///
+ private Stack