Example #1
0
        /// <summary>
        /// Try re-compiling specified urls
        /// </summary>
        /// <param name="urls"></param>
        /// <param name="checkSyntaxOnly">Don't compile, check syntax only.</param>
        /// <returns></returns>
        protected virtual CompilerContext TryCompile(string[] urls, bool checkSyntaxOnly = false)
        {
            //Console.WriteLine("TryCompile {0}, syntaxcheck={1}", string.Join(",", urls), checkSyntaxOnly);
            BooCompiler compiler = new BooCompiler();

            compiler.Parameters.OutputType         = CompilerOutputType.Library;
            compiler.Parameters.GenerateInMemory   = true;
            compiler.Parameters.Pipeline           = checkSyntaxOnly ? (CompilerPipeline) new Boo.Lang.Compiler.Pipelines.CheckForErrors() : new Boo.Lang.Compiler.Pipelines.CompileToMemory();
            compiler.Parameters.WhiteSpaceAgnostic = this.WhitespaceAgnostic;
            CustomizeCompiler(compiler, compiler.Parameters.Pipeline, urls);
            foreach (string url in urls)
            {
                compiler.Parameters.Input.Add(_storage.CreateCompilerInput(url));
            }
            CompilerContext compilerContext = compiler.Run();

            if (_compilationCallback != null)
            {
                _compilationCallback(compilerContext, urls);
            }

            if (compilerContext.Errors.Count != 0)
            {
                throw CreateCompilerException(compilerContext);
            }
            HandleWarnings(compilerContext.Warnings);

            return(compilerContext);
        }
Example #2
0
 protected override void CustomizeCompiler(BooCompiler compiler, CompilerPipeline pipeline, string[] urls)
 {
     compiler.Parameters.AddAssembly(typeof(BooCompiler).Assembly);
     compiler.Parameters.Ducky = true;
     pipeline.Insert(1, new ImplicitBaseClassCompilerStep(typeof(M), "Prepare"));
     base.CustomizeCompiler(compiler, pipeline, urls);
 }
        public BooScriptCompiler()
        {
            compiler = BooHelpers.CreateBooCompiler();
            var parameters = compiler.Parameters;

            //parameters.Environment =

            parameters.GenerateInMemory   = true;
            parameters.Ducky              = true;
            parameters.WhiteSpaceAgnostic = false;
            parameters.References.Clear();
            //parameters.LoadDefaultReferences();//do not use! This will cause failures on future calls, within the context of a TShockPlugin(unknown reason).
            //parameters.StdLib = false;

            parameters.DisabledWarnings.Add("BCW0016");            //dont warn about unused namespaces...
            parameters.OutputType          = CompilerOutputType.Library;
            parameters.OutputAssembly      = "scripts.dll";
            parameters.GenerateCollectible = true;           //dont leak assemblies...
            var pipeline = new CompileToMemory();            //...when we compile them to memory.

            //parameters.Pipeline = new CompileToFile();
            //parameters.Pipeline = new Parse();

            injectImportsStep = new InjectImportsStep();
            pipeline.Insert(1, injectImportsStep);

            ensureMethodSignaturesStep = new EnsureMethodSignaturesStep();

            pipeline.Insert(2, ensureMethodSignaturesStep);

            parameters.Pipeline = pipeline;
        }
Example #4
0
        public int Run(string[] args)
        {
            int resultCode = 127;

            AppDomain.CurrentDomain.AssemblyResolve += AssemblyResolve;

            CheckBooCompiler();

            var parameters = new CompilerParameters(false);

            try
            {
                var setupTime = Stopwatch.StartNew();

                CommandLineParser.ParseInto(parameters, args);

                if (0 == parameters.Input.Count)
                {
                    throw new ApplicationException(StringResources.BooC_NoInputSpecified);
                }

                var compiler = new BooCompiler(parameters);
                setupTime.Stop();

                var processingTime = Stopwatch.StartNew();
                var context        = compiler.Run();
                processingTime.Stop();

                if (context.Warnings.Count > 0)
                {
                    Console.Error.WriteLine(context.Warnings);
                    Console.Error.WriteLine(StringResources.BooC_Warnings, context.Warnings.Count);
                }

                if (context.Errors.Count == 0)
                {
                    resultCode = 0;
                }
                else
                {
                    foreach (CompilerError error in context.Errors)
                    {
                        Console.Error.WriteLine(error.ToString(parameters.TraceInfo));
                    }
                    Console.Error.WriteLine(StringResources.BooC_Errors, context.Errors.Count);
                }

                if (parameters.TraceWarning)
                {
                    Console.Error.WriteLine(StringResources.BooC_ProcessingTime, parameters.Input.Count,
                                            processingTime.ElapsedMilliseconds, setupTime.ElapsedMilliseconds);
                }
            }
            catch (Exception x)
            {
                var message = (parameters.TraceWarning) ? x : (object)x.Message;
                Console.Error.WriteLine(string.Format(Boo.Lang.Resources.StringResources.BooC_FatalError, message));
            }
            return(resultCode);
        }
Example #5
0
        /// <summary>
        /// "Safe" means of creating a BooCompiler within a TShock plugin.
        /// </summary>
        /// <remarks>This creates compiler without calling LoadDefaultReferences(), which causes exceptions under TShock.</remarks>
        /// <returns>BooCompiler.</returns>
        public static BooCompiler CreateBooCompiler()
        {
            var parameters = new CompilerParameters(false);            //we must supply our own parameters object to the compiler, to avoid call to LoadDefautlReferences()
            var compiler   = new BooCompiler(parameters);

            return(compiler);
        }
Example #6
0
 private void AddInputs(string[] urls, BooCompiler compiler)
 {
     foreach (var url in urls)
     {
         compiler.Parameters.Input.Add(Storage.CreateInput(url));
     }
 }
Example #7
0
        public Assembly Compile(Assembly[] references, params string[] definitionFiles)
        {
            var parameters = new CompilerParameters
            {
                OutputType     = CompilerOutputType.Library,
                Pipeline       = new CompileToFile(),
                OutputAssembly = appSettings.DefinitionsAssemblyPath
            };

            parameters.References.Add(Assembly.GetExecutingAssembly());
            if (references != null)
            {
                references.ForEach(reference => parameters.References.Add(reference));
            }

            foreach (var definitionFile in definitionFiles)
            {
                parameters.Input.Add(Input(definitionFile));
            }

            parameters.Pipeline.Insert(1, new DefinitionClassCompilerStep());

            var compiler = new BooCompiler(parameters);
            var context  = compiler.Run();

            if (context.Errors.Count > 0)
            {
                throw new CompilationException(context.Errors);
            }

            return(context.GeneratedAssembly);
        }
Example #8
0
        /// <summary>
        /// Perform the actual compilation of the scripts
        /// Things to note here:
        /// * The generated assembly reference the Castle.MonoRail.MonoRailBrail and Castle.MonoRail.Framework assemblies
        /// * If a common scripts assembly exist, it is also referenced
        /// * The AddBrailBaseClassStep compiler step is added - to create a class from the view's code
        /// * The ProcessMethodBodiesWithDuckTyping is replaced with ReplaceUknownWithParameters
        ///   this allows to use naked parameters such as (output context.IsLocal) without using
        ///   any special syntax
        /// * The FixTryGetParameterConditionalChecks is run afterward, to transform "if ?Error" to "if not ?Error isa IgnoreNull"
        /// * The ExpandDuckTypedExpressions is replace with a derived step that allows the use of Dynamic Proxy assemblies
        /// * The IntroduceGlobalNamespaces step is removed, to allow to use common variables such as
        ///   date and list without accidently using the Boo.Lang.BuiltIn versions
        /// </summary>
        /// <param name="files"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        private CompilationResult DoCompile(IEnumerable <ICompilerInput> files, string name)
        {
            ICompilerInput[] filesAsArray = new List <ICompilerInput>(files).ToArray();
            BooCompiler      compiler     = SetupCompiler(filesAsArray);
            string           filename     = Path.Combine(baseSavePath, name);

            compiler.Parameters.OutputAssembly = filename;
            // this is here and not in SetupCompiler since CompileCommon is also
            // using SetupCompiler, and we don't want reference to the old common from the new one
            if (common != null)
            {
                compiler.Parameters.References.Add(common);
            }
            // pre procsssor needs to run before the parser
            var processor = new BrailPreProcessor(this);

            compiler.Parameters.Pipeline.Insert(0, processor);
            // inserting the add class step after the parser
            compiler.Parameters.Pipeline.Insert(2, new TransformToBrailStep(options));
            compiler.Parameters.Pipeline.Replace(typeof(ProcessMethodBodiesWithDuckTyping),
                                                 new ReplaceUknownWithParameters());
            //compiler.Parameters.Pipeline.Replace(typeof(ExpandDuckTypedExpressions),
            //                                     new ExpandDuckTypedExpressions_WorkaroundForDuplicateVirtualMethods());
            compiler.Parameters.Pipeline.Replace(typeof(InitializeTypeSystemServices),
                                                 new InitializeCustomTypeSystem());
            compiler.Parameters.Pipeline.InsertBefore(typeof(ReplaceUknownWithParameters),
                                                      new FixTryGetParameterConditionalChecks());
            compiler.Parameters.Pipeline.RemoveAt(compiler.Parameters.Pipeline.Find(typeof(IntroduceGlobalNamespaces)));

            return(new CompilationResult(compiler.Run(), processor));
        }
Example #9
0
        // common setup for the compiler
        private BooCompiler SetupCompiler(IEnumerable <ICompilerInput> files)
        {
            var compiler = new BooCompiler();

            compiler.Parameters.Ducky = true;
            compiler.Parameters.Debug = options.Debug;
            if (options.SaveToDisk)
            {
                compiler.Parameters.Pipeline = new CompileToFile();
            }
            else
            {
                compiler.Parameters.Pipeline = new CompileToMemory();
            }
            // replace the normal parser with white space agnostic one.
            compiler.Parameters.Pipeline.RemoveAt(0);
            compiler.Parameters.Pipeline.Insert(0, new WSABooParsingStep());
            foreach (var file in files)
            {
                compiler.Parameters.Input.Add(file);
            }
            foreach (Assembly assembly in options.AssembliesToReference)
            {
                compiler.Parameters.References.Add(assembly);
            }
            compiler.Parameters.OutputType = CompilerOutputType.Library;
            return(compiler);
        }
Example #10
0
        private static BooCompiler NewCompilerWithReferences(IEnumerable <ICompileUnit> references)
        {
            BooCompiler compiler = NewCompiler(false);

            compiler.Parameters.References.AddAll(references);
            return(compiler);
        }
Example #11
0
File: Boo.cs Project: pafh99/Kaliya
        public static void Run(string source, string guid, string url)
        {
#if DEBUG
            Console.WriteLine("\n[*] Compiling Stage Code");
#endif
            var compiler = new BooCompiler();
            compiler.Parameters.Input.Add(new StringInput("Stage.boo", source));
            compiler.Parameters.Pipeline = new CompileToMemory();
            compiler.Parameters.Ducky    = true;
            compiler.Parameters.References.Add(compiler.Parameters.LoadAssembly("System.Web.Extensions", true));

            var context = compiler.Run();

            if (context.GeneratedAssembly == null)
            {
#if DEBUG
                Console.WriteLine("[-] Error(s) compiling script, this probably means your Boo script has bugs\n");
                foreach (var error in context.Errors)
                {
                    Console.WriteLine(error);
                }
#endif
                return;
            }
#if DEBUG
            Console.WriteLine("[+] Compilation Successful!");
            Console.WriteLine("[*] Executing");
#endif
            context.GeneratedAssembly.EntryPoint.Invoke(null, new object[] { new[] { guid, url } });
        }
Example #12
0
        /// <summary>
        /// check script syntax
        /// </summary>
        /// <param name="script"></param>
        /// <param name="errors">provide a list for adding errors</param>
        /// <param name="warnings">provide a list for adding warnings</param>
        /// <returns></returns>
        public virtual bool CheckSyntax(string script, IList <string> errors, IList <string> warnings)
        {
            //Console.WriteLine("CheckSyntax {0}", script);
            BooCompiler compiler = new BooCompiler();

            compiler.Parameters.OutputType         = CompilerOutputType.Library;
            compiler.Parameters.GenerateInMemory   = true;
            compiler.Parameters.Pipeline           = new Boo.Lang.Compiler.Pipelines.CheckForErrors();
            compiler.Parameters.WhiteSpaceAgnostic = this.WhitespaceAgnostic;

            CustomizeCompiler(compiler, compiler.Parameters.Pipeline, new string[] { });
            compiler.Parameters.Input.Add(new Boo.Lang.Compiler.IO.StringInput("the_script", script));
            CompilerContext compilerContext = compiler.Run();

            if (warnings != null)
            {
                foreach (var w in compilerContext.Warnings)
                {
                    warnings.Add(w.ToString());
                }
            }
            if (errors != null)
            {
                foreach (var e in compilerContext.Errors)
                {
                    errors.Add(e.ToString(true));
                }
            }
            return(compilerContext.Errors.Count == 0);
        }
Example #13
0
 protected override void CustomizeCompiler(BooCompiler compiler, CompilerPipeline pipeline, string[] urls)
 {
     pipeline.Insert(1, new ImplicitBaseClassCompilerStep(typeof(BooConfigReader), "Prepare", "Horn.Core.Dsl"));
     pipeline.InsertBefore(typeof(ProcessMethodBodiesWithDuckTyping), new RightShiftToMethodCompilerStep());
     pipeline.Insert(2, new UnderscorNamingConventionsToPascalCaseCompilerStep());
     pipeline.Insert(3, new UseSymbolsStep());
 }
Example #14
0
        public static void Method(string write)
        {
            BooCompiler compiler = new BooCompiler();

            compiler.Parameters.Input.Add(new FileInput(@"..\..\script.boo"));

            compiler.Parameters.Pipeline         = new CompileToMemory();
            compiler.Parameters.Ducky            = true;
            compiler.Parameters.GenerateInMemory = true;

            CompilerContext context = compiler.Run();

            //Note that the following code might throw an error if the Boo script had bugs.
            //Poke context.Errors to make sure.
            if (context.GeneratedAssembly != null)
            {
                Type       scriptModule = context.GeneratedAssembly.GetType("ScriptModule");
                MethodInfo stringManip  = scriptModule.GetMethod("stringManip");
                string     output       = (string)stringManip.Invoke(null, new object[] { write });
                Console.WriteLine(output);
            }
            else
            {
                foreach (CompilerError error in context.Errors)
                {
                    Console.WriteLine(error);
                }
            }
            Console.ReadLine();
        }
Example #15
0
        protected override void CustomizeCompiler(BooCompiler compiler, CompilerPipeline pipeline, string[] urls)
        {
            var steps = new List <ICompilerStep>();

            steps.Add(new IncludeSupportStep(new PhantomDslEngine(importBuilders)
            {
                InIncludeMode = true
            }));
            if (!InIncludeMode)
            {
                steps.Add(new UnescapeNamesStep());
                steps.Add(new ExpressionToTargetNameStep());
                steps.Add(new ExpressionToDependencyNamesStep());
                steps.Add(new ExpressionToCleanupNameStep());
                steps.Add(new ExpressionToCallTargetNameStep());
                steps.Add(new AutoReferenceFilesCompilerStep());
                steps.Add(new TaskImportStep(importBuilders.ToArray()));

                steps.Add(new ImplicitBaseClassCompilerStep(typeof(PhantomBase), "Execute", typeof(UtilityFunctions).Namespace));
            }

            steps.Reverse();
            foreach (var step in steps)
            {
                pipeline.Insert(1, step);
            }

            if (!InIncludeMode)
            {
                pipeline.InsertBefore(typeof(ProcessMethodBodiesWithDuckTyping), new AutoRunAllRunnablesStep());
            }

            compiler.Parameters.References.Add(typeof(UtilityFunctions).Assembly);
        }
Example #16
0
        protected override Type CompileMigration(MigrationReference migrationReference)
        {
            BooCompiler compiler = new BooCompiler();

            compiler.Parameters.Input.Add(new FileInput(migrationReference.Path));
            compiler.Parameters.References.Add(typeof(IDatabaseMigration).Assembly);
            foreach (string reference in _configuration.References)
            {
                _log.Debug("Referencing: " + reference);
                compiler.Parameters.References.Add(Assembly.LoadFrom(reference));
            }
            compiler.Parameters.OutputType       = CompilerOutputType.Library;
            compiler.Parameters.GenerateInMemory = true;
            compiler.Parameters.OutputAssembly   = Path.Combine(_workingDirectoryManager.WorkingDirectory, Path.GetFileNameWithoutExtension(migrationReference.Path) + ".dll");
            compiler.Parameters.Ducky            = true;
            compiler.Parameters.Pipeline         = new CompileToFile();
            CompilerContext cc = compiler.Run();

            if (cc.Errors.Count > 0)
            {
                foreach (CompilerError error in cc.Errors)
                {
                    _log.ErrorFormat("{0}", error);
                }
                throw new InvalidOperationException();
            }
            if (cc.GeneratedAssembly == null)
            {
                throw new InvalidOperationException();
            }
            return(MigrationHelpers.LookupMigration(cc.GeneratedAssembly, migrationReference));
        }
Example #17
0
File: St.cs Project: glides/Naga
        public static void RunBooEngine(string source)
        {
            Console.WriteLine("\n[*] Compiling Stage Code");

            BooCompiler compiler = new BooCompiler();

            compiler.Parameters.Input.Add(new StringInput("Stage.boo", source));
            compiler.Parameters.Pipeline = new CompileToMemory();
            compiler.Parameters.Ducky    = true;
            compiler.Parameters.References.Add(compiler.Parameters.LoadAssembly("System.Web.Extensions", true));
            //Console.WriteLine(compiler.Parameters.LibPaths);
            //compiler.Parameters.LoadAssembly("System");

            CompilerContext context = compiler.Run();

            //Note that the following code might throw an error if the Boo script had bugs.
            //Poke context.Errors to make sure.
            if (context.GeneratedAssembly != null)
            {
                Console.WriteLine("[+] Compilation Successful!");
                Console.WriteLine("[*] Executing");

                //AppDomain.CurrentDomain.AssemblyResolve -= ResolveEventHandler;
                context.GeneratedAssembly.EntryPoint.Invoke(null, new object[] { new string[] { GUID.ToString(), HEXPSK, string.Join(",", URLS) } });
            }
            else
            {
                Console.WriteLine("[-] Error(s) compiling script, this probably means your Boo script has bugs\n");
                foreach (CompilerError error in context.Errors)
                {
                    Console.WriteLine(error);
                }
            }
        }
Example #18
0
        public static void RunScript(string s)
        {
            CompileToMemory ctm      = new CompileToMemory();
            BooCompiler     compiler = new BooCompiler();

            compiler.Parameters.Input.Add(new StringInput("BooFile_Module", s));
            compiler.Parameters.Pipeline    = ctm;
            compiler.Parameters.Environment = new ClosedEnvironment(ctm);
            compiler.Parameters.Ducky       = true;
            compiler.Parameters.AddAssembly(typeof(GameModel).Assembly);

            foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
            {
                compiler.Parameters.References.Add(assembly);
            }

            CompilerContext context = compiler.Run();

            if (context.GeneratedAssembly == null)
            {
                foreach (CompilerError error in context.Errors)
                {
                    MelonLogger.LogError(error.ToString());
                }
                return;
            }

            Type[]     types        = context.GeneratedAssembly.GetTypes();
            Type       scriptModule = types[types.Length - 1];
            MethodInfo mainEntry    = scriptModule.Assembly.EntryPoint;

            mainEntry.Invoke(null, new object[mainEntry.GetParameters().Length]);
        }
Example #19
0
        // Compile all the common scripts to a common assemblies
        // an error in the common scripts would raise an exception.
        public bool CompileCommonScripts()
        {
            if (options.CommonScriptsDirectory == null)
            {
                return(false);
            }

            // the demi.boo is stripped, but GetInput require it.
            string demiFile = Path.Combine(options.CommonScriptsDirectory, "demi.brail");
            IDictionary <ICompilerInput, string> inputs = GetInput(demiFile, true);

            ICompilerInput[] inputsAsArray = new List <ICompilerInput>(inputs.Keys).ToArray();
            BooCompiler      compiler      = SetupCompiler(inputsAsArray);
            string           outputFile    = Path.Combine(baseSavePath, "CommonScripts.dll");

            compiler.Parameters.OutputAssembly = outputFile;
            CompilerContext result = compiler.Run();

            if (result.Errors.Count > 0)
            {
                throw new Exception(result.Errors.ToString(true));
            }
            common = result.GeneratedAssembly;
            compilations.Clear();
            return(true);
        }
Example #20
0
		public override bool Execute()
		{
			BooCompiler compiler = new BooCompiler();
			if (OutputAssembly == null)
			{
				compiler.Parameters.Pipeline = new CompileToMemory();
			}
			else
			{
				compiler.Parameters.Pipeline = new CompileToFile();
				compiler.Parameters.OutputAssembly = OutputAssembly.ItemSpec;
			}
			compiler.Parameters.OutputType = CompilerOutputType.ConsoleApplication;

			if (files == null || files.Length == 0)
			{
				Log.LogError("Must specify at least one file for the book task");
				return false;
			}

			foreach (ITaskItem taskItem in files)
			{
				FileInput input = new FileInput(taskItem.ItemSpec);
				compiler.Parameters.Input.Add(input);
			}

			foreach (ITaskItem reference in references)
			{
				Assembly assembly = Assembly.LoadFrom(reference.ItemSpec);
				compiler.Parameters.References.Add(assembly);
			}

			CompilerContext run = compiler.Run();

			if (run.Errors.Count > 0)
			{
				string s = run.Errors.ToString(true);
				Log.LogError("Failed to compile code: " + s);
				return false;
			}

			MethodInfo methodInfo = run.GeneratedAssembly.EntryPoint;
			if (methodInfo == null)
			{
				Log.LogError("Could not find entry point for the files");
				return false;
			}
			try
			{
				methodInfo.Invoke(null, new object[] { new string[0] });
			}
			catch (TargetInvocationException e)
			{
				Log.LogError("Scripts failed to run!");
				Log.LogError(e.InnerException.ToString());
			}

			return true;
		}
Example #21
0
        private static BooCompiler NewCompiler(bool loadDefaultReferences)
        {
            BooCompiler compiler = new BooCompiler(new CompilerParameters(loadDefaultReferences));

            compiler.Parameters.OutputType = CompilerOutputType.Auto;
            compiler.Parameters.Pipeline   = new Boo.Lang.Compiler.Pipelines.CompileToMemory();
            return(compiler);
        }
Example #22
0
 protected override void CustomizeCompiler(BooCompiler compiler, CompilerPipeline pipeline, string[] urls)
 {
     pipeline.Insert(1,
                     new ImplicitBaseClassCompilerStep(typeof(WithAction), "Execute",
                                                       //default namespaces
                                                       "Rhino.DSL.Tests.FeaturesDSL"));
     pipeline.Insert(2, new UseSymbolsStep());
 }
 protected override void AddCompilerSteps(BooCompiler compiler, string filename, CompilerPipeline pipeline)
 {
     compiler.Parameters.AddAssembly(typeof(Boo.Lang.Compiler.Ast.DepthFirstTransformer).Assembly);
     compiler.Parameters.Pipeline.Insert(1,
                                         new MethodSubstitutionBaseClassCompilerStep(typeof(MyMethodSubstitutionBaseClass),
                                                                                     "System",
                                                                                     "Boo.Lang.Compiler.Ast.DepthFirstTransformer"));
 }
Example #24
0
 private static BooCompiler CompilerFor(CompileUnit unit, Assembly[] references)
 {
     BooCompiler compiler = new BooCompiler();
     compiler.Parameters.OutputType = IsApplication(unit) ? CompilerOutputType.ConsoleApplication : CompilerOutputType.Library;
     compiler.Parameters.Pipeline = new Boo.Lang.Compiler.Pipelines.CompileToMemory();
     compiler.Parameters.References.Extend(references);
     return compiler;
 }
 public UnityScriptCompiler(UnityScriptCompilerParameters parameters)
 {
     if (parameters == null)
     {
         throw new ArgumentNullException("parameters");
     }
     this._parameters = parameters;
     this._compiler   = new BooCompiler(this._parameters);
 }
Example #26
0
        public static CompilerContext CompileCode(string script)
        {
            var compiler = new BooCompiler();

            compiler.Parameters.Input.Add(new StringInput("<script>", script));
            compiler.Parameters.Pipeline = new Run();

            return(compiler.Run());
        }
Example #27
0
 protected override void CustomizeCompiler(BooCompiler compiler, CompilerPipeline pipeline, string[] urls)
 {
     pipeline.Insert(1,
                     new ImplicitBaseClassCompilerStep(typeof(BaseOrderActionsDSL), "Prepare",
                                                       //default namespaces
                                                       "Rhino.DSL.Tests.SchedulingDSL"));
     pipeline.InsertBefore(typeof(ProcessMethodBodiesWithDuckTyping),
                           new UnderscoreNamingConventionsToPascalCaseCompilerStep());
 }
Example #28
0
        public static IEnumerable <IConfigurationRunner> GetConfigurationRunners(
            IEnumerable <ICompilerInput> compilerInputs)
        {
            BooCompiler compiler = SetupBooCompiler(compilerInputs);

            CompilerContext run = Compile(compiler);

            return(GetConfigurationRunners(compilerInputs, run));
        }
Example #29
0
        private static BooCompiler CompilerFor(CompileUnit unit, Assembly[] references)
        {
            BooCompiler compiler = new BooCompiler();

            compiler.Parameters.OutputType = IsApplication(unit) ? CompilerOutputType.ConsoleApplication : CompilerOutputType.Library;
            compiler.Parameters.Pipeline   = new Boo.Lang.Compiler.Pipelines.CompileToMemory();
            compiler.Parameters.References.Extend(references);
            return(compiler);
        }
Example #30
0
        public static CompilerContext compile_(CompileUnit unit, Assembly[] references)
        {
            BooCompiler compiler = NewCompiler();

            foreach (Assembly reference in references)
            {
                compiler.Parameters.References.Add(reference);
            }
            return(compiler.Run(unit));
        }
Example #31
0
        private CompilerContext Compile(string url)
        {
            TextReader         input      = urlResolver(url, baseDirectory ?? Path.GetDirectoryName(url));
            CompilerParameters parameters = SafeCloneParameters(Parameters);

            parameters.Input.Add(new ReaderInput(url, input));
            BooCompiler compiler = new BooCompiler(parameters);

            return(compiler.Run());
        }
Example #32
0
        public BooTemplateTypeBuilder(TemplateOptions options)
        {
            _booCompiler    = new BooCompiler();
            CompilerResults = new CompilerResults(new TempFileCollection());
            this.options    = options;

            _booCompiler.Parameters.GenerateInMemory = true;
            _booCompiler.Parameters.Debug            = true;
            _booCompiler.Parameters.OutputType       = CompilerOutputType.Library;
        }
Example #33
0
		private static BooCompiler NewCompiler(bool loadDefaultReferences)
		{
			BooCompiler compiler = new BooCompiler(new CompilerParameters(loadDefaultReferences));
			compiler.Parameters.OutputType = CompilerOutputType.Auto;
			compiler.Parameters.Pipeline = new Boo.Lang.Compiler.Pipelines.CompileToMemory();
			return compiler;
		}