Example #1
0
 virtual protected void OnAfterStep(CompilerContext context, ICompilerStep step)
 {
     if (null != AfterStep)
     {
         AfterStep(this, new CompilerStepEventArgs(context, step));
     }
 }
Example #2
0
		public void Dispose()
		{
			if (_parser != null)
			{
				_parser.Dispose();
				_parser = null;
			}
		}
Example #3
0
 public void Dispose()
 {
     if (_parser != null)
     {
         _parser.Dispose();
         _parser = null;
     }
 }
 public static void ReplaceOptional(CompilerPipeline pipeline, Type optionalPipelineStepType, ICompilerStep step)
 {
     int num = pipeline.Find(optionalPipelineStepType);
     if (num >= 0)
     {
         pipeline.RemoveAt(num);
         pipeline.Insert(num - 1, step);
     }
 }
Example #5
0
 public CompilerPipeline Add(ICompilerStep step)
 {
     if (null == step)
     {
         throw new ArgumentNullException("step");
     }
     _steps.Add(step);
     return(this);
 }
Example #6
0
        public CompilerPipeline Insert(int index, ICompilerStep step)
        {
            if (null == step)
            {
                throw new ArgumentNullException("step");
            }

            _items.Insert(index, step);
            return(this);
        }
Example #7
0
		private void RunCompilerStepAfterExpressionResolutionOn(CompileUnit compileUnit, ICompilerStep step)
		{
			var pipeline = new Boo.Lang.Compiler.Pipelines.ResolveExpressions { step };

			var compiler = new Boo.Lang.Compiler.BooCompiler(new CompilerParameters { Pipeline = pipeline });
			var result = compiler.Run(compileUnit);

			if (result.Errors.Count > 0)
				Assert.Fail(result.Errors.ToString(true));
		}
Example #8
0
        public CompilerPipeline Replace(Type stepExactType, ICompilerStep step)
        {
            if (null == step)
            {
                throw new ArgumentNullException("step");
            }

            int index = Find(stepExactType);

            if (-1 == index)
            {
                throw new ArgumentException("stepExactType");
            }
            _items[index] = step;
            return(this);
        }
Example #9
0
        private static AbstractConfigurationRunner GetConfigurationInstance(
            string name, string environment, ICompilerInput input,
            GenerationOptions generationOptions, ICompilerStep autoReferenceStep,
            params string[] namespaces)
        {
            BooCompiler compiler = new BooCompiler();

            compiler.Parameters.Ducky = true;
            if (generationOptions == GenerationOptions.Memory)
            {
                compiler.Parameters.Pipeline = new CompileToMemory();
            }
            else
            {
                compiler.Parameters.Pipeline = new CompileToFile();
            }

            compiler.Parameters.Pipeline.Insert(1, autoReferenceStep);
            compiler.Parameters.Pipeline.Insert(2, new BinsorCompilerStep(environment, namespaces));
            compiler.Parameters.Pipeline.Replace(
                typeof(ProcessMethodBodiesWithDuckTyping),
                new TransformUnknownReferences());
            compiler.Parameters.Pipeline.InsertAfter(typeof(TransformUnknownReferences),
                                                     new RegisterComponentAndFacilitiesAfterCreation());

            compiler.Parameters.OutputType = CompilerOutputType.Library;
            compiler.Parameters.Input.Add(input);
            compiler.Parameters.References.Add(typeof(BooReader).Assembly);
            compiler.Parameters.References.Add(typeof(MacroMacro).Assembly);

            TryAddAssembliesReferences(compiler.Parameters, "Rhino.Commons.NHibernate", "Rhino.Commons.ActiveRecord");

            CompilerContext run = compiler.Run();

            if (run.Errors.Count != 0)
            {
                throw new CompilerError(string.Format("Could not compile configuration! {0}", run.Errors.ToString(true)));
            }
            Type type = run.GeneratedAssembly.GetType(name.Replace('.', '_'));

            return(Activator.CreateInstance(type) as AbstractConfigurationRunner);
        }
Example #10
0
        protected void RunStep(CompilerContext context, ICompilerStep step)
        {
            OnBeforeStep(context, step);

            step.Initialize(context);
            try
            {
                step.Run();
            }
            catch (Boo.Lang.Compiler.CompilerError error)
            {
                context.Errors.Add(error);
            }
            catch (System.Exception x)
            {
                context.Errors.Add(CompilerErrorFactory.StepExecutionError(x, step));
            }
            finally
            {
                OnAfterStep(context, step);
            }
        }
Example #11
0
 public CompilerPipeline InsertBefore(Type stepExactType, ICompilerStep step)
 {
     return(Insert(Find(stepExactType) - 1, step));
 }
Example #12
0
 public CompilerPipeline InsertAfter(Type stepExactType, ICompilerStep step)
 {
     return(Insert(Find(stepExactType) + 1, step));
 }
Example #13
0
        private void RunCompilerStepAfterExpressionResolutionOn(CompileUnit compileUnit, ICompilerStep step)
        {
            var pipeline = new Boo.Lang.Compiler.Pipelines.ResolveExpressions {
                step
            };

            var compiler = new Boo.Lang.Compiler.BooCompiler(new CompilerParameters {
                Pipeline = pipeline
            });
            var result = compiler.Run(compileUnit);

            if (result.Errors.Count > 0)
            {
                Assert.Fail(result.Errors.ToString(true));
            }
        }
Example #14
0
        private static AbstractConfigurationRunner GetConfigurationInstance(
			string name, string environment, ICompilerInput input,
			GenerationOptions generationOptions, ICompilerStep autoReferenceStep,
			params string[] namespaces)
        {
            BooCompiler compiler = new BooCompiler();
            compiler.Parameters.Ducky = true;
            if (generationOptions == GenerationOptions.Memory)
                compiler.Parameters.Pipeline = new CompileToMemory();
            else
                compiler.Parameters.Pipeline = new CompileToFile();

            compiler.Parameters.Pipeline.Insert(1, autoReferenceStep);
            compiler.Parameters.Pipeline.Insert(2, new BinsorCompilerStep(environment, namespaces));
            compiler.Parameters.Pipeline.Replace(
                typeof (ProcessMethodBodiesWithDuckTyping),
                new TransformUnknownReferences());
            compiler.Parameters.Pipeline.InsertAfter(typeof (TransformUnknownReferences),
                                                     new RegisterComponentAndFacilitiesAfterCreation());

            compiler.Parameters.OutputType = CompilerOutputType.Library;
            compiler.Parameters.Input.Add(input);
            compiler.Parameters.References.Add(typeof (BooReader).Assembly);
            compiler.Parameters.References.Add(typeof (MacroMacro).Assembly);

            TryAddAssembliesReferences(compiler.Parameters, "Rhino.Commons.NHibernate", "Rhino.Commons.ActiveRecord");

            CompilerContext run = compiler.Run();
            if (run.Errors.Count != 0)
            {
                throw new CompilerError(string.Format("Could not compile configuration! {0}", run.Errors.ToString(true)));
            }
            Type type = run.GeneratedAssembly.GetType(name.Replace('.', '_'));
            return Activator.CreateInstance(type) as AbstractConfigurationRunner;
        }
Example #15
0
 public CompilerStepEventArgs(CompilerContext context, ICompilerStep step) : base(context)
 {
     this.Step = step;
 }
Example #16
0
 public CompilerStepEventArgs(CompilerContext context, ICompilerStep step)
 {
     this.Context = context;
     this.Step = step;
 }
Example #17
0
        #region Constructors

        public CompilerStepEventArgs(CompilerContext context, ICompilerStep step)
            : base(context)
        {
Example #18
0
 protected virtual void OnBeforeStep(CompilerContext context, ICompilerStep step)
 {
     if (null != BeforeStep)
     {
         BeforeStep(this, new CompilerStepEventArgs(context, step));
     }
 }
Example #19
0
 public CompilerPipeline Add(ICompilerStep step)
 {
     Steps.Add(step);
     return(this);
 }
Example #20
0
 public static CompilerError StepExecutionError(Exception error, ICompilerStep step)
 {
     return new CompilerError("BCE0011", error, step, error.Message);
 }
Example #21
0
        public void StepExecution(ICompilerStep step, Exception cause)
        {
            string msg = Format("StepExecution", step.GetType(), cause.Message);

            Add(new Error(LexicalInfo.Empty, msg, cause));
        }
Example #22
0
        public CompilerPipeline Add(ICompilerStep step)
        {
            if (null == step)
            {
                throw new ArgumentNullException("step");
            }

            _items.Add(step);
            return this;
        }
Example #23
0
 public BooEval(ICompilerStep parser){
     this.parser = parser;
 }
Example #24
0
 private void RunCompilerStepAfterExpressionResolution(ICompilerStep step)
 {
     RunCompilerStepAfterExpressionResolutionOn(new CompileUnit(new Module()), step);
 }
Example #25
0
        protected void RunStep(CompilerContext context, ICompilerStep step)
        {
            OnBeforeStep(context, step);

            step.Initialize(context);
            try
            {
                step.Run();
            }
            catch (Boo.Lang.Compiler.CompilerError error)
            {
                context.Errors.Add(error);
            }
            catch (System.Exception x)
            {
                context.Errors.Add(CompilerErrorFactory.StepExecutionError(x, step));
            }
            finally
            {
                OnAfterStep(context, step);
            }
        }
Example #26
0
        public CompilerPipeline Insert(int index, ICompilerStep step)
        {
            if (null == step)
            {
                throw new ArgumentNullException("step");
            }

            _items.Insert(index, step);
            return this;
        }
Example #27
0
		private void RunCompilerStepAfterExpressionResolution(ICompilerStep step)
		{
			RunCompilerStepAfterExpressionResolutionOn(new CompileUnit(new Module()), step);
		}
Example #28
0
 public CompilerStepEventArgs(CompilerContext context, ICompilerStep step)
 {
     this.Context = context;
     this.Step    = step;
 }
Example #29
0
 public CompilerPipeline InsertAfter(Type stepExactType, ICompilerStep step)
 {
     return Insert(Find(stepExactType)+1, step);
 }
Example #30
0
 public static CompilerError StepExecutionError(Exception error, ICompilerStep step)
 {
     return(new CompilerError("BCE0011", error, step, error.Message));
 }
Example #31
0
 public CompilerPipeline InsertBefore(Type stepExactType, ICompilerStep step)
 {
     return Insert(Find(stepExactType)-1, step);
 }
Example #32
0
        public CompilerPipeline Replace(Type stepExactType, ICompilerStep step)
        {
            if (null == step)
            {
                throw new ArgumentNullException("step");
            }

            int index = Find(stepExactType);
            if (-1 == index)
            {
                throw new ArgumentException("stepExactType");
            }
            _items[index] = step;
            return this;
        }
        public static void ReplaceOptional(this CompilerPipeline pipeline, Type optionalPipelineStepType, ICompilerStep step)
        {
            int index = pipeline.Find(optionalPipelineStepType);

            if (index >= 0)
            {
                pipeline.RemoveAt(index);
                pipeline.Insert(index - 1, step);
            }
        }