예제 #1
0
 virtual protected void OnAfterStep(CompilerContext context, ICompilerStep step)
 {
     if (null != AfterStep)
     {
         AfterStep(this, new CompilerStepEventArgs(context, step));
     }
 }
예제 #2
0
파일: Parsing.cs 프로젝트: 0xb1dd1e/boo
		public void Dispose()
		{
			if (_parser != null)
			{
				_parser.Dispose();
				_parser = null;
			}
		}
예제 #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);
     }
 }
예제 #5
0
 public CompilerPipeline Add(ICompilerStep step)
 {
     if (null == step)
     {
         throw new ArgumentNullException("step");
     }
     _steps.Add(step);
     return(this);
 }
예제 #6
0
        public CompilerPipeline Insert(int index, ICompilerStep step)
        {
            if (null == step)
            {
                throw new ArgumentNullException("step");
            }

            _items.Insert(index, step);
            return(this);
        }
예제 #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));
		}
예제 #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);
        }
예제 #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);
        }
예제 #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);
            }
        }
예제 #11
0
 public CompilerPipeline InsertBefore(Type stepExactType, ICompilerStep step)
 {
     return(Insert(Find(stepExactType) - 1, step));
 }
예제 #12
0
 public CompilerPipeline InsertAfter(Type stepExactType, ICompilerStep step)
 {
     return(Insert(Find(stepExactType) + 1, step));
 }
예제 #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));
            }
        }
예제 #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;
        }
예제 #15
0
 public CompilerStepEventArgs(CompilerContext context, ICompilerStep step) : base(context)
 {
     this.Step = step;
 }
예제 #16
0
 public CompilerStepEventArgs(CompilerContext context, ICompilerStep step)
 {
     this.Context = context;
     this.Step = step;
 }
예제 #17
0
        #region Constructors

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

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

            _items.Add(step);
            return this;
        }
예제 #23
0
 public BooEval(ICompilerStep parser){
     this.parser = parser;
 }
예제 #24
0
 private void RunCompilerStepAfterExpressionResolution(ICompilerStep step)
 {
     RunCompilerStepAfterExpressionResolutionOn(new CompileUnit(new Module()), step);
 }
예제 #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);
            }
        }
예제 #26
0
        public CompilerPipeline Insert(int index, ICompilerStep step)
        {
            if (null == step)
            {
                throw new ArgumentNullException("step");
            }

            _items.Insert(index, step);
            return this;
        }
예제 #27
0
		private void RunCompilerStepAfterExpressionResolution(ICompilerStep step)
		{
			RunCompilerStepAfterExpressionResolutionOn(new CompileUnit(new Module()), step);
		}
예제 #28
0
 public CompilerStepEventArgs(CompilerContext context, ICompilerStep step)
 {
     this.Context = context;
     this.Step    = step;
 }
예제 #29
0
 public CompilerPipeline InsertAfter(Type stepExactType, ICompilerStep step)
 {
     return Insert(Find(stepExactType)+1, step);
 }
예제 #30
0
 public static CompilerError StepExecutionError(Exception error, ICompilerStep step)
 {
     return(new CompilerError("BCE0011", error, step, error.Message));
 }
예제 #31
0
 public CompilerPipeline InsertBefore(Type stepExactType, ICompilerStep step)
 {
     return Insert(Find(stepExactType)-1, step);
 }
예제 #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);
            }
        }