コード例 #1
0
        private void ConfigurePipeline()
        {
            var pipeline = _pipelineName != null?CompilerPipeline.GetPipeline(_pipelineName) : new CompileToFile();

            _options.Pipeline = pipeline;
            if (_debugSteps)
            {
                var stepDebugger = new StepDebugger();
                pipeline.BeforeStep += stepDebugger.BeforeStep;
                pipeline.AfterStep  += stepDebugger.AfterStep;
            }
        }
コード例 #2
0
ファイル: CompilerManager.cs プロジェクト: watsug/Boo-Plugin
        public static void Compile(int tabSize, IEnumerable <Assembly> assemblies, IEnumerable <CompileResults> codeFiles)
        {
            var pipeline = CompilerPipeline.GetPipeline("checkforerrors");

            pipeline.BreakOnErrors = false;
            pipeline.Replace(typeof(IntroduceGlobalNamespaces), new Steps.IntroduceGlobalNamespaces_Plugin());
            var compiler = new BooCompiler(new CompilerParameters(true)
            {
                Pipeline = pipeline
            });

            compiler.Parameters.Environment =
                new ClosedEnvironment(
                    new ParserSettings
            {
                TabSize = tabSize
            });

            compiler.Parameters.Input.Clear();
            //compiler.Parameters.References.Clear();

            foreach (var assembly in assemblies)
            {
                compiler.Parameters.References.Add(assembly);
            }

            var results = new Dictionary <string, CompileResults>();

            foreach (var codeFile in codeFiles)
            {
                results.Add(codeFile.Url, codeFile);
                codeFile.SetupForCompilation(compiler.Parameters);
            }

            compiler.Parameters.Pipeline.AfterStep +=
                (sender, args) =>
            {
                if (args.Step == pipeline[0])
                {
                    MapParsedNodes(results, args.Context);
                }
                if (args.Step == pipeline[pipeline.Count - 1])
                {
                    MapCompleted(results, args.Context);
                }
            };

            // as a part of compilation process compiler might request assembly load which triggers an assembly
            // resolve event to be processed by type resolver. Such processing has to happen on the same thread the
            // resolver has been created on
            compiler.Run();
        }
コード例 #3
0
 private void ConfigurePipeline()
 {
     if (null != _pipelineName)
     {
         _options.Pipeline = CompilerPipeline.GetPipeline(_pipelineName);
     }
     else
     {
         _options.Pipeline = new CompileToFile();
     }
     if (_whiteSpaceAgnostic)
     {
         _options.Pipeline[0] = new Boo.Lang.Parser.WSABooParsingStep();
     }
     if (_debugSteps)
     {
         _options.Pipeline.AfterStep += new CompilerStepEventHandler(new StepDebugger().AfterStep);
     }
 }
コード例 #4
0
        void ParseOptions(string[] args, CompilerParameters _options)
        {
            bool      debugSteps = false;
            ArrayList arglist    = new ArrayList(args);

            ExpandResponseFiles(ref arglist);
            AddDefaultResponseFile(ref arglist);
            foreach (string arg in arglist)
            {
                if ("-" == arg)
                {
                    _options.Input.Add(new StringInput("<stdin>", Consume(Console.In)));
                }
                else
                {
                    if (IsFlag(arg))
                    {
                        if ("-utf8" == arg)
                        {
                            continue;
                        }
                        switch (arg[1])
                        {
                        case 'v':
                        {
                            _options.TraceSwitch.Level = TraceLevel.Warning;
                            Trace.Listeners.Add(new TextWriterTraceListener(Console.Error));
                            if (arg.Length > 2)
                            {
                                switch (arg.Substring(1))
                                {
                                case "vv":
                                {
                                    _options.TraceSwitch.Level = TraceLevel.Info;
                                    break;
                                }

                                case "vvv":
                                {
                                    _options.TraceSwitch.Level = TraceLevel.Verbose;
                                    break;
                                }
                                }
                            }
                            else
                            {
                                _options.TraceSwitch.Level = TraceLevel.Warning;
                            }
                            break;
                        }

                        case 'r':
                        {
                            if (arg.IndexOf(":") > 2)
                            {
                                switch (arg.Substring(1, 8))
                                {
                                case "resource":
                                {
                                    string resourceFile;
                                    int    start = arg.IndexOf(":") + 1;
                                    int    comma = arg.LastIndexOf(',');
                                    if (comma >= 0)
                                    {
                                        resourceFile = arg.Substring(start, comma - start);
                                        string resourceName = arg.Substring(comma + 1);
                                        _options.Resources.Add(new NamedFileResource(resourceFile, resourceName));
                                    }
                                    else
                                    {
                                        resourceFile = arg.Substring(start);
                                        _options.Resources.Add(new FileResource(resourceFile));
                                    }
                                    break;
                                }

                                default:
                                {
                                    InvalidOption(arg);
                                    break;
                                }
                                }
                            }
                            else
                            {
                                string assemblyName = arg.Substring(3);
                                _options.References.Add(LoadAssembly(assemblyName));
                            }
                            break;
                        }

                        case 'o':
                        {
                            _options.OutputAssembly = arg.Substring(arg.IndexOf(":") + 1);
                            break;
                        }

                        case 't':
                        {
                            string targetType = arg.Substring(arg.IndexOf(":") + 1);
                            switch (targetType)
                            {
                            case "library":
                            {
                                _options.OutputType = CompilerOutputType.Library;
                                break;
                            }

                            case "exe":
                            {
                                _options.OutputType = CompilerOutputType.ConsoleApplication;
                                break;
                            }

                            case "winexe":
                            {
                                _options.OutputType = CompilerOutputType.WindowsApplication;
                                break;
                            }

                            default:
                            {
                                InvalidOption(arg);
                                break;
                            }
                            }
                            break;
                        }

                        case 'p':
                        {
                            string pipelineName = arg.Substring(3);
                            _options.Pipeline = CompilerPipeline.GetPipeline(pipelineName);
                            break;
                        }

                        case 'c':
                        {
                            string culture = arg.Substring(3);
                            Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture(culture);
                            break;
                        }

                        case 's':
                        {
                            switch (arg.Substring(1, 6))
                            {
                            case "srcdir":
                            {
                                string path = arg.Substring(8);
                                AddFilesForPath(path, _options);
                                break;
                            }

                            default:
                            {
                                InvalidOption(arg);
                                break;
                            }
                            }
                            break;
                        }

                        case 'd':
                        {
                            switch (arg.Substring(1))
                            {
                            case "debug":
                            case "debug+":
                            {
                                _options.Debug = true;
                                break;
                            }

                            case "debug-":
                            {
                                _options.Debug = false;
                                break;
                            }

                            case "ducky":
                            {
                                _options.Ducky = true;
                                break;
                            }

                            case "debug-steps":
                            {
                                debugSteps = true;
                                break;
                            }

                            default:
                            {
                                InvalidOption(arg);
                                break;
                            }
                            }
                            break;
                        }

                        case 'e':
                        {
                            switch (arg.Substring(1, 8))
                            {
                            case "embedres":
                            {
                                // TODO: Add check for runtime support for "mono resources"
                                string resourceFile;
                                int    start = arg.IndexOf(":") + 1;
                                int    comma = arg.LastIndexOf(',');
                                if (comma >= 0)
                                {
                                    resourceFile = arg.Substring(start, comma - start);
                                    string resourceName = arg.Substring(comma + 1);
                                    _options.Resources.Add(new NamedEmbeddedFileResource(resourceFile, resourceName));
                                }
                                else
                                {
                                    resourceFile = arg.Substring(start);
                                    _options.Resources.Add(new EmbeddedFileResource(resourceFile));
                                }
                                break;
                            }

                            default:
                            {
                                InvalidOption(arg);
                                break;
                            }
                            }
                            break;
                        }

                        default:
                        {
                            InvalidOption(arg);
                            break;
                        }
                        }
                    }
                    else
                    {
                        _options.Input.Add(new FileInput(arg));
                    }
                }
            }

            if (null == _options.Pipeline)
            {
                _options.Pipeline = new CompileToFile();
            }
            if (debugSteps)
            {
                _options.Pipeline.AfterStep += new CompilerStepEventHandler(DebugModuleAfterStep);
            }
        }