Пример #1
0
        public static void Run(string[] source, string[] args)
        {
            var compiler          = new Compiler(source);
            var generatedAssembly = compiler.ToAssembly();

            if (compiler.Errors.Any())
            {
                ListErrors(compiler.Errors.Select(x => x.Message).ToArray());
            }

            if (!compiler.Errors.Any())
            {
                var runable = new Runable(generatedAssembly, args);
                runable.Select   += OnSelectResults;
                runable.Progress += OnProgress;

                try
                {
                    PrintRunning();
                    runable.Run();
                    runable.Select   -= OnSelectResults;
                    runable.Progress -= OnProgress;
                    System.Console.WriteLine("");
                }
                catch (ThreadAbortException)
                {
                    System.Console.WriteLine("Program aborted");
                }
                catch (Exception e)
                {
                    System.Console.WriteLine("Unexpected Exception: {0}", e);
                }
            }
        }
Пример #2
0
 public static void RunOnMainThread(Runable runable)
 {
     lock (locker)
     {
         Current.ListQueue.Enqueue(runable);
     }
 }
Пример #3
0
 static void doRun(Runable runnnable)
 {
     // ポリモーフィズムを使えばswitch文のように
     // 列挙しなくてもいい
     // mode変数なんか用意しなくてもいい -> 管理コストの低減
     // 大きなプロジェクトになると管理コストの増大で工数も増える…
     runnnable.Run();
 }
Пример #4
0
        public static Runable Compile(string code, IHttpRequestFactory requestFactory)
        {
            var compiler = new Compiler(code);
            var assembly = compiler.ToAssembly();

            Assert.IsTrue(compiler.Errors.Count == 0);
            var runable = new Runable(assembly);

            if (requestFactory != null)
            {
                runable.SetRequestFactory(requestFactory);
            }
            return(runable);
        }
Пример #5
0
        private void Compile(string source)
        {
            ThreadContext.Properties[Config.LogKey] = _logValue;
            ThreadedDownloadTable.LogValue          = _logValue;

            DoInvoke(new Action(() =>
            {
                messagesTextBox.Clear();
                statusLabel.Text = "Running...";

                //var highlightingStrategy = textEditorControl1.Document.HighlightingStrategy as DefaultHighlightingStrategy;
                //highlightingStrategy.SetColorFor("Selection", _executionHighlight);
            }));

            var compiler          = new Compiler(source);
            var generatedAssembly = compiler.ToAssembly();

            if (compiler.Errors.Any())
            {
                ListErrors(compiler.Errors.Select(x => x.Message).ToArray());
            }

            if (!compiler.Errors.Any())
            {
                _runable            = new Runable(generatedAssembly);
                _runable.Select    += OnSelectResults;
                _runable.Progress  += OnProgress;
                _runable.Highlight += OnHighlight;

                try
                {
                    _runable.Run();
                }
                catch (ThreadAbortException)
                {
                    Log.Info("Program aborted");
                    ProgramFinished();
                }
                catch (Exception e)
                {
                    Log.Fatal("Unexpected Exception", e);
                }
            }

            ProgramFinished();
        }
Пример #6
0
        private void Update()
        {
            Runable runable = null;

            lock (locker)
            {
                if (Current.ListQueue.Count > 0)
                {
                    runable = Current.ListQueue.Dequeue();
                }
            }
            if (runable != null)
            {
                runable.run();
            }
            runable = null;
        }
Пример #7
0
        private static void Compile(string[] source, string[] args)
        {
            ConsoleAppender.PlatConsole.StartLine = ConsoleAppender.PlatConsole.CurrentLine + 1;
            ConsoleAppender.PlatConsole.MoveCursor(ConsoleAppender.PlatConsole.StartLine);

            var watch = new Stopwatch();

            watch.Start();

            var compiler          = new Compiler(source);
            var generatedAssembly = compiler.ToAssembly();

            if (compiler.Errors.Any())
            {
                ListErrors(compiler.Errors.Select(x => x.Message).ToArray());
            }

            if (!compiler.Errors.Any())
            {
                var runable = new Runable(generatedAssembly, args);
                runable.Select   += OnSelectResults;
                runable.Progress += OnProgress;

                try
                {
                    PrintRunning();
                    runable.Run();
                }
                catch (ThreadAbortException)
                {
                    Log.Info("Program aborted");
                }
                catch (Exception e)
                {
                    Log.Fatal("Unexpected Exception", e);
                }
            }

            watch.Stop();
            ConsoleAppender.PlatConsole.Print("");
            ConsoleAppender.PlatConsole.Print(string.Format("Finished in {0} seconds", watch.Elapsed.TotalSeconds));
        }
Пример #8
0
        private static void Compile(string[] source, string[] args)
        {
            ConsoleAppender.StartCursorTop = Console.CursorTop + 1;
            ConsoleAppender.SetCursor(ConsoleAppender.StartCursorTop);

            var compiler          = new Compiler(source);
            var generatedAssembly = compiler.ToAssembly();

            if (compiler.Errors.Any())
            {
                ListErrors(compiler.Errors.Select(x => x.Message).ToArray());
            }

            if (!compiler.Errors.Any())
            {
                var runable = new Runable(generatedAssembly, args);
                runable.Select   += OnSelectResults;
                runable.Progress += OnProgress;

                try
                {
                    PrintRunning();
                    runable.Run();
                    Console.WriteLine("Finished.");
                    ConsoleAppender.StartCursorTop = Console.CursorTop;
                }
                catch (ThreadAbortException)
                {
                    Log.Info("Program aborted");
                }
                catch (Exception e)
                {
                    Log.Fatal("Unexpected Exception", e);
                }
            }
        }