virtual protected void OnAfterStep(CompilerContext context, ICompilerStep step) { if (null != AfterStep) { AfterStep(this, new CompilerStepEventArgs(context, step)); } }
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); } }
public CompilerPipeline Add(ICompilerStep step) { if (null == step) { throw new ArgumentNullException("step"); } _steps.Add(step); return(this); }
public CompilerPipeline Insert(int index, ICompilerStep step) { if (null == step) { throw new ArgumentNullException("step"); } _items.Insert(index, step); return(this); }
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)); }
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); }
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); }
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); } }
public CompilerPipeline InsertBefore(Type stepExactType, ICompilerStep step) { return(Insert(Find(stepExactType) - 1, step)); }
public CompilerPipeline InsertAfter(Type stepExactType, ICompilerStep step) { return(Insert(Find(stepExactType) + 1, step)); }
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)); } }
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; }
public CompilerStepEventArgs(CompilerContext context, ICompilerStep step) : base(context) { this.Step = step; }
public CompilerStepEventArgs(CompilerContext context, ICompilerStep step) { this.Context = context; this.Step = step; }
#region Constructors public CompilerStepEventArgs(CompilerContext context, ICompilerStep step) : base(context) {
protected virtual void OnBeforeStep(CompilerContext context, ICompilerStep step) { if (null != BeforeStep) { BeforeStep(this, new CompilerStepEventArgs(context, step)); } }
public CompilerPipeline Add(ICompilerStep step) { Steps.Add(step); return(this); }
public static CompilerError StepExecutionError(Exception error, ICompilerStep step) { return new CompilerError("BCE0011", error, step, error.Message); }
public void StepExecution(ICompilerStep step, Exception cause) { string msg = Format("StepExecution", step.GetType(), cause.Message); Add(new Error(LexicalInfo.Empty, msg, cause)); }
public CompilerPipeline Add(ICompilerStep step) { if (null == step) { throw new ArgumentNullException("step"); } _items.Add(step); return this; }
public BooEval(ICompilerStep parser){ this.parser = parser; }
private void RunCompilerStepAfterExpressionResolution(ICompilerStep step) { RunCompilerStepAfterExpressionResolutionOn(new CompileUnit(new Module()), step); }
public CompilerPipeline Insert(int index, ICompilerStep step) { if (null == step) { throw new ArgumentNullException("step"); } _items.Insert(index, step); return this; }
public CompilerPipeline InsertAfter(Type stepExactType, ICompilerStep step) { return Insert(Find(stepExactType)+1, step); }
public static CompilerError StepExecutionError(Exception error, ICompilerStep step) { return(new CompilerError("BCE0011", error, step, error.Message)); }
public CompilerPipeline InsertBefore(Type stepExactType, ICompilerStep step) { return Insert(Find(stepExactType)-1, step); }
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); } }