コード例 #1
0
        public void HandleToggleChoicepoints()
        {
            Console.Write("Available choicepoint positions:\n  ");

            PrintSequenceContext contextCp = new PrintSequenceContext();

            contextCp.cpPosCounter = 0;
            SequencePrinter.PrintSequence(debugSequences.Peek(), contextCp, debugSequences.Count);
            Console.WriteLine();

            if (contextCp.cpPosCounter == 0)
            {
                Console.WriteLine("No choicepoint positions available!");
                return;
            }

            int pos = HandleTogglePoint("choicepoint", contextCp.cpPosCounter);

            if (pos == -1)
            {
                return;
            }

            TogglePointInAllInstances(pos, true);
        }
コード例 #2
0
        public void HandleToggleBreakpoints()
        {
            Console.Write("Available breakpoint positions:\n  ");

            PrintSequenceContext contextBp = new PrintSequenceContext();

            contextBp.bpPosCounter = 0;
            SequencePrinter.PrintSequence(debugSequences.Peek(), contextBp, debugSequences.Count);
            Console.WriteLine();

            if (contextBp.bpPosCounter == 0)
            {
                Console.WriteLine("No breakpoint positions available!");
                return;
            }

            int pos = HandleTogglePoint("breakpoint", contextBp.bpPosCounter);

            if (pos == -1)
            {
                return;
            }

            TogglePointInAllInstances(pos, false);
        }
コード例 #3
0
        public void ApplyRewriteSequence(Sequence seq, bool debug)
        {
            bool installedDumpHandlers = false;

            if (!impl.ActionsExists())
            {
                return;
            }

            if (debug || CheckDebuggerAlive())
            {
                debugger.NotifyOnConnectionLost = true;
                debugger.InitNewRewriteSequence(seq, debug);
            }

            if (!InDebugMode && ContainsSpecial(seq))
            {
                impl.curShellProcEnv.ProcEnv.OnEntereringSequence += DumpOnEntereringSequence;
                impl.curShellProcEnv.ProcEnv.OnExitingSequence    += DumpOnExitingSequence;
                installedDumpHandlers = true;
            }
            else
            {
                impl.curShellProcEnv.ProcEnv.OnEntereringSequence += NormalEnteringSequenceHandler;
            }

            curGRS  = seq;
            curRule = null;

            impl.debugOut.WriteLine("Executing Graph Rewrite Sequence (CTRL+C for abort) ...");
            cancelSequence = false;
            WorkaroundManager.Workaround.PreventComputerGoingIntoSleepMode(true);
            impl.curShellProcEnv.ProcEnv.PerformanceInfo.Reset();
            StatisticsSource statisticsSource = new StatisticsSource(impl.curShellProcEnv.ProcEnv.NamedGraph, impl.curShellProcEnv.ProcEnv);
            Timer            timer            = null;

            if (!debug && !silenceExec)
            {
                timer = new Timer(new TimerCallback(PrintStatistics), statisticsSource, 1000, 1000);
            }

            try
            {
                bool result = impl.curShellProcEnv.ProcEnv.ApplyGraphRewriteSequence(seq);
                if (timer != null)
                {
                    timer.Dispose();
                }

                seq.ResetExecutionState();
                impl.debugOut.WriteLine("Executing Graph Rewrite Sequence done after {0} ms with result: {1}",
                                        (impl.curShellProcEnv.ProcEnv.PerformanceInfo.TimeNeeded * 1000).ToString("F1", System.Globalization.CultureInfo.InvariantCulture),
                                        result);
                if (impl.newGraphOptions.Profile)
                {
                    impl.debugOut.WriteLine(" - {0} search steps executed", impl.curShellProcEnv.ProcEnv.PerformanceInfo.SearchSteps);
                }
#if DEBUGACTIONS || MATCHREWRITEDETAIL // spread over multiple files now, search for the corresponding defines to reactivate
                impl.debugOut.WriteLine(" - {0} matches found in {1} ms", perfInfo.MatchesFound, perfInfo.TotalMatchTimeMS);
                impl.debugOut.WriteLine(" - {0} rewrites performed in {1} ms", perfInfo.RewritesPerformed, perfInfo.TotalRewriteTimeMS);
#if DEBUGACTIONS
                impl.debugOut.WriteLine("\nDetails:");
                ShowSequenceDetails(seq, perfInfo);
#endif
#else
                impl.debugOut.WriteLine(" - {0} matches found", impl.curShellProcEnv.ProcEnv.PerformanceInfo.MatchesFound);
                impl.debugOut.WriteLine(" - {0} rewrites performed", impl.curShellProcEnv.ProcEnv.PerformanceInfo.RewritesPerformed);
#endif
            }
            catch (OperationCanceledException)
            {
                cancelSequence = true;      // make sure cancelSequence is set to true
                if (timer != null)
                {
                    timer.Dispose();
                }
                if (curRule == null)
                {
                    impl.errOut.WriteLine("Rewrite sequence aborted!");
                }
                else
                {
                    impl.errOut.WriteLine("Rewrite sequence aborted after position:");
                    SequencePrinter.PrintSequence(curGRS, curRule);
                    impl.errOut.WriteLine();
                }
            }
            WorkaroundManager.Workaround.PreventComputerGoingIntoSleepMode(false);
            curRule = null;
            curGRS  = null;

            if (InDebugMode)
            {
                debugger.NotifyOnConnectionLost = false;
                debugger.FinishRewriteSequence();
            }

            StreamWriter emitWriter = impl.curShellProcEnv.ProcEnv.EmitWriter as StreamWriter;
            if (emitWriter != null)
            {
                emitWriter.Flush();
            }

            if (installedDumpHandlers)
            {
                impl.curShellProcEnv.ProcEnv.OnEntereringSequence -= DumpOnEntereringSequence;
                impl.curShellProcEnv.ProcEnv.OnExitingSequence    -= DumpOnExitingSequence;
            }
            else
            {
                impl.curShellProcEnv.ProcEnv.OnEntereringSequence -= NormalEnteringSequenceHandler;
            }
        }