/// <summary> /// 开始调试 /// </summary> public void Run() { // 初始化栈 stack = new Stack <StackFrame>(); entryStacks = new Stack <int>(); stacks.Add(stack); // 当前栈帧 currentStackFrame = new StackFrame(0); globalStackFrame = currentStackFrame; stack.Push(currentStackFrame); // 代码区长度 int length = codesArray.Count; // 初始化程序计数器 pc = 0; isStop = false; // 设置当前符号表 currentSymbolTable = globalSymbolTable; // 执行中间代码 while (pc < length && !isStop) { IntermediateCode code = codesArray[pc]; InterpretSingleInstruction(code); pc++; } // 停止运行 // 运行结束销毁 stacks.Remove(stack); RunFinish?.Invoke(); }