private StringInput RunPreProcessorOn(ICompilerInput input) { PreProcessor processor; TextReader reader; StringInput input2; PreProcessor processor1 = processor = new PreProcessor(this.Parameters.Defines.Keys); int num1 = (int)(processor.PreserveLines = true); PreProcessor processor2 = processor; IDisposable disposable = (reader = input.Open()) as IDisposable; try { StringWriter writer = new StringWriter(); processor2.Process(reader, writer); input2 = new StringInput(input.Name, writer.ToString()); } finally { if (disposable != null) { disposable.Dispose(); disposable = null; } } return(input2); }
//[DebuggerStepThrough] public CompilerOutput Compile( ICompilerInput input, ICompilerPolicies policies, ICompilerNotificationMessageBuilder messageBuilder) { try { var output = new CompilerOutput(); this.m_input = new CompilerInput(input); this.m_input.Validate(policies, messageBuilder, output); throw new NotImplementedException(); //this.m_outputBuilder = new CompilerOutputBuilder(); //m_outputBuilder.AddError(this.m_input.Errors); //m_outputBuilder.AddWarning(this.m_input.Warnings); //if (false == this.m_input.Errors.Any()) // this.Compile(); //return this.m_outputBuilder.Build(); } finally { this.m_input = null; this.m_outputBuilder = null; } }
public static CompileUnit[] Convert(ICompilerInput input) { var converter = new UnityScriptConverter(); converter.Input.Add(input); converter.References.Add(typeof (UnityEngine.MonoBehaviour).Assembly); converter.References.Add(typeof (ExampleScript).Assembly); return converter.Run(); }
public void Add(ICompilerInput input) { if (null == input) { throw new ArgumentNullException("input"); } InnerList.Add(input); }
public static CompileUnit[] Convert(ICompilerInput input) { var converter = new UnityScriptConverter(); converter.Input.Add(input); converter.References.Add(typeof(UnityEngine.MonoBehaviour).Assembly); converter.References.Add(typeof(ExampleScript).Assembly); return(converter.Run()); }
private void AddInputs(BooCompiler compiler, IEnumerable <string> urls) { foreach (string url in urls) { ICompilerInput input = Storage.CreateInput(url); if (input == null) { throw new InvalidOperationException("Got a null input for url: " + url); } compiler.Parameters.Input.Add(input); } }
private void ParseInput(ICompilerInput input) { TextReader reader; IDisposable disposable = (reader = input.Open()) as IDisposable; try { UnityScriptParser.ParseReader(reader, input.get_Name(), this.get_Context(), this.get_CompileUnit()); } finally { if (disposable != null) { disposable.Dispose(); disposable = null; } } }
private void ParseInput(ICompilerInput input) { TextReader reader; IDisposable disposable = (reader = input.Open()) as IDisposable; try { UnityScriptParser.ParseReader(reader, input.Name, this.Context, this.CompileUnit); } finally { if (disposable != null) { disposable.Dispose(); disposable = null; } } }
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); }
// If batch compilation is set to true, this would return all the view scripts // in the director (not recursive!) // Otherwise, it would return just the single file private IDictionary <ICompilerInput, string> GetInput(string filename, bool batch) { var input2FileName = new Dictionary <ICompilerInput, string>(); if (batch == false) { input2FileName.Add(CreateInput(filename), filename); return(input2FileName); } // use the System.IO.Path to get the folder name even though // we are using the ViewSourceLoader to load the actual file string directory = Path.GetDirectoryName(filename); foreach (var file in ViewSourceLoader.ListViews(directory)) { ICompilerInput input = CreateInput(file); input2FileName.Add(input, file); } return(input2FileName); }
CompileUnit RunCompiler(ICompilerInput input) { BooCompiler compiler = new BooCompiler(); CompilerParameters options = compiler.Parameters; options.Input.Add(input); options.Pipeline.Add(new BooParsingStep()); options.Pipeline.Add(new UsingResolutionStep()); options.Pipeline.Add(new AstAttributesStep()); options.References.Add(GetType().Assembly); CompilerContext context = compiler.Run(); if (context.Errors.Count > 0) { Fail(context.Errors[0].ToString()); } return(context.CompileUnit); }
// common setup for the compiler private BooCompiler SetupCompiler(ICompilerInput[] files) { BooCompiler 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 (ICompilerInput 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; }
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 void InputError(ICompilerInput input, Exception error) { Add(new Error(LexicalInfo.Empty, error.Message, error)); }
public string GetInputCode(ICompilerInput input) { return (string) inputToCode[input]; }
internal CompilerInput(ICompilerInput other, int ordinal = 0) { this.Ordinal = ordinal; Debug.Assert(!ReferenceEquals(other, null), "other is null"); if(!ReferenceEquals(other.Contracts, null)) { foreach(var item in other.Contracts) { if(!ReferenceEquals(item, null)) { var clone = new CompilerInputContract(item, this.Contracts.Count ); this.Contracts.Add( clone ); } } } if(!ReferenceEquals(other.TableTypes, null)) { foreach(var item in other.TableTypes) { if(!ReferenceEquals(item, null)) { var clone = new CompilerInputTableTypeSelector(item, this.TableTypes.Count ); this.TableTypes.Add( clone ); } } } if(!ReferenceEquals(other.QueryStoredProcedures, null)) { foreach(var item in other.QueryStoredProcedures) { if(!ReferenceEquals(item, null)) { var clone = new CompilerInputQueryStoredProcedureSelector(item, this.QueryStoredProcedures.Count ); this.QueryStoredProcedures.Add( clone ); } } } OnCreated(); }
public string GetInputCode(ICompilerInput input) { return((string)inputToCode[input]); }