Example #1
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;
 }
Example #2
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");
                }
                catch (Exception e)
                {
                    Log.Fatal("Unexpected Exception", e);
                }
            }

            ProgramFinished();
        }
Example #3
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));
        }