Esempio n. 1
0
 /// <summary>
 /// 处理调试结束
 /// </summary>
 private void CmmDebugerDebugFinish()
 {
     Dispatcher.Invoke(() => {
         isDebug = false;
         debugPanel.InDebugMode = false;
         textEditor.ClearDebugMarker();
         cmmDebuger = null;
     });
 }
Esempio n. 2
0
        /// <summary>
        /// 调试代码
        /// </summary>
        private void btnDebug_Click(object sender, RoutedEventArgs e)
        {
            IParseTree     tree    = prepareForCodeGen();
            CompileVisitor visitor = prepareForRunning(tree);

            if (visitor == null)
            {
                return;
            }

            prepareForDebug();

            // 断点列表
            List <int> breakpoints = textEditor.GetBreakPoints();

            // 初始化调试器
            cmmDebuger = new CMMDebuger(visitor.codes, breakpoints);
            cmmDebuger.LoadDebugInformation(visitor.GetGlobalSymbolTable(), visitor.GetFunctionInformations());
            cmmDebuger.setListener(this);
            cmmDebuger.OutputStream = this;
            cmmDebuger.NeedDebug   += HandlerDebug;
            cmmDebuger.DebugFinish += CmmDebugerDebugFinish;

            debugThread = new Thread(() => {
                try {
                    //Print("\n调试模式\n");
                    isDebug = true;
                    cmmDebuger.Run();
                    Print("\nprogram exit\n");
                    isDebug = false;
                }
                catch (RuntimeException e1) {
                    Print("Line:" + e1.line.ToString() + " " + e1.Message);
                }
                catch (Exception e2) {
                    Print(e2.Message);
                }
            });

            debugThread.Name = "Debug";
            debugThread.Start();
        }