Exemplo n.º 1
0
        public void TestAdd()
        {
            DummyStep p = new DummyStep();

            _pipeline.Add(p);
            Assert.AreEqual(1, _pipeline.Count);
        }
Exemplo n.º 2
0
        public void CurrentStep()
        {
            var pipeline = new CompilerPipeline();

            var step1 = new ActionStep(delegate {});

            pipeline.Add(step1);

            ActionStep step2 = null;

            step2 = new ActionStep(() => Assert.AreSame(step2, pipeline.CurrentStep));
            pipeline.Add(step2);

            var currentSteps = new Boo.Lang.List();

            pipeline.Before     += (sender, args) => currentSteps.Add(pipeline.CurrentStep);
            pipeline.BeforeStep += (sender, args) => currentSteps.Add(pipeline.CurrentStep);
            pipeline.AfterStep  += (sender, args) => currentSteps.Add(pipeline.CurrentStep);
            pipeline.After      += (sender, args) => currentSteps.Add(pipeline.CurrentStep);

            pipeline.Run(new CompilerContext());

            Assert.AreEqual(
                new object[] { null, step1, step1, step2, step2, null },
                currentSteps.ToArray());
        }
            public static CompilerPipeline RawParsing()
            {
                CompilerPipeline pipeline;
                CompilerPipeline pipeline1 = pipeline = new CompilerPipeline();

                pipeline.Add(new PreProcess());
                pipeline.Add(new UnityScript.Steps.Parse());
                return(pipeline);
            }
Exemplo n.º 4
0
        /// <summary>
        /// Extends the pre-compiler pipeline with x86 compiler stages.
        /// </summary>
        /// <param name="compilerPipeline">The pipeline to extend.</param>
        public override void ExtendCompilerPipeline(CompilerPipeline compilerPipeline)
        {
            compilerPipeline.Add(
                new StartUpStage()
                );

            compilerPipeline.Add(
                new InterruptVectorStage()
                );

            compilerPipeline.Add(
                new SSEInitStage()
                );
        }
Exemplo n.º 5
0
        /// <summary>
        /// Override in derived classes to use a different pipeline.
        /// </summary>
        protected virtual CompilerPipeline SetUpCompilerPipeline()
        {
            CompilerPipeline pipeline = VerifyGeneratedAssemblies
                                ? new CompileToFileAndVerify()
                                : new CompileToMemory();

            pipeline.Add(new RunAssembly());
            return(pipeline);
        }
Exemplo n.º 6
0
 protected override void SetUpCompilerPipeline(CompilerPipeline pipeline)
 {
     pipeline.
     Add(new Boo.Antlr.BooParsingStep()).
     Add(new UsingResolutionStep()).
     Add(new AstAttributesStep()).
     Add(new AstNormalizationStep()).
     Add(new SemanticStep()).
     Add(new BooPrinterStep());
 }
Exemplo n.º 7
0
 protected override void SetUpCompilerPipeline(CompilerPipeline pipeline)
 {
     pipeline.
     Add(new Boo.Antlr.BooParsingStep()).
     Add(new UsingResolutionStep()).
     Add(new AstAttributesStep()).
     Add(new AstNormalizationStep()).
     Add(new SemanticStep()).
     Add(new EmitAssemblyStep()).
     Add(new SaveAssemblyStep()).
     Add(new PEVerifyStep()).
     Add(new RunAssemblyStep());
 }
Exemplo n.º 8
0
        void SetupCompiler(CompilerPipeline pipeline)
        {
            _compiler = new BooCompiler();
            _compiler.Parameters.Input.Add(new FileInput(_file));
            _compiler.Parameters.OutputType     = CompilerOutputType.Library;
            _compiler.Parameters.OutputAssembly = _outfile;
            _compiler.Parameters.References.Add(typeof(ScriptCompiler <>).Assembly);
            _compiler.Parameters.References.Add(typeof(Mono.Cecil.AssemblyFactory).Assembly);
            _compiler.Parameters.References.Add(typeof(NUnit.Framework.Assert).Assembly);

            _compiler.Parameters.Pipeline = pipeline;
            pipeline.Insert(1, new PrepareScript <TScript> ());
            _instantiater = new InstantiateScript <TScript> ();
            pipeline.Add(_instantiater);
        }
Exemplo n.º 9
0
        public void EventSequence()
        {
            var calls    = new List <string>();
            var pipeline = new CompilerPipeline();

            pipeline.Before     += delegate { calls.Add("before"); };
            pipeline.BeforeStep += delegate { calls.Add("before step"); };
            pipeline.Add(new ActionStep(() => calls.Add("step")));
            pipeline.AfterStep += delegate { calls.Add("after step"); };
            pipeline.After     += delegate { calls.Add("after"); };
            pipeline.Run(new CompilerContext());
            Assert.AreEqual(
                new string[] { "before", "before step", "step", "after step", "after" },
                calls.ToArray());
        }
Exemplo n.º 10
0
        Module parse(StringInput input)
        {
            CompilerPipeline pipeline = new CompilerPipeline();

            pipeline.Add(new WSABooParsingStep());

            BooCompiler compiler = new BooCompiler();

            compiler.Parameters.Pipeline = pipeline;
            compiler.Parameters.Input.Add(input);
            CompilerContext result = compiler.Run();

            Assert.AreEqual(0, result.Errors.Count, result.Errors.ToString());
            Assert.AreEqual(1, result.CompileUnit.Modules.Count);
            return(result.CompileUnit.Modules[0]);
        }
Exemplo n.º 11
0
        public UnityScriptConverter()
        {
            _compiler = new UnityScriptCompiler();
            CompilerPipeline compilerPipeline = UnityScriptCompiler.Pipelines.RawParsing();

            compilerPipeline.Add(new ResolveMonoBehaviourType());
            compilerPipeline.Add(new ApplySemantics());
            compilerPipeline.Add(new ApplyDefaultVisibility());
            compilerPipeline.Add(new TypeInference());
            compilerPipeline.Add(new FixScriptClass());
            compilerPipeline.Add(new RemoveEmptyMethods());
            compilerPipeline.Add(new AddImports());
            compilerPipeline.Add(new RenameArrayDeclaration());
            compilerPipeline.Add(new RenameIEnumerator());
            compilerPipeline.Add(new TransformKnownCalls());
            compilerPipeline.Add(new GenericTransformer());
            _compiler.Parameters.ScriptMainMethod = "Example";
            _compiler.Parameters.Pipeline         = compilerPipeline;
            var imports = _compiler.Parameters.Imports;

            imports.Add("UnityEngine");
            imports.Add("System.Collections");
        }
Exemplo n.º 12
0
        /// <summary>
        /// Extends the pre-compiler pipeline with x86 compiler stages.
        /// </summary>
        /// <param name="compilerPipeline">The pipeline to extend.</param>
        public override void ExtendCompilerPipeline(CompilerPipeline compilerPipeline)
        {
            compilerPipeline.Add(
                new StartUpStage()
            );

            compilerPipeline.Add(
                new InterruptVectorStage()
            );

            compilerPipeline.Add(
                new SSEInitStage()
            );
        }