private CommandLineParser(IEnumerable <string> args, CompilerParameters options) { _options = options; _options.GenerateCollectible = false; _options.GenerateInMemory = false; var tempLibPaths = _options.LibPaths.ToArray(); _options.LibPaths.Clear(); Parse(args); //move standard libpaths below any new ones: _options.LibPaths.Extend(tempLibPaths); if (_options.StdLib) { _options.LoadDefaultReferences(); } else if (!_noConfig) { _references.Insert(0, "mscorlib"); } LoadReferences(); ConfigurePipeline(); if (_options.TraceInfo) { _options.Pipeline.BeforeStep += OnBeforeStep; _options.Pipeline.AfterStep += OnAfterStep; } }
public int Run(string[] args) { int resultCode = -1; AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(AssemblyResolve); CheckBooCompiler(); try { DateTime start = DateTime.Now; _options = new CompilerParameters(false); //false means no stdlib loading yet _options.GenerateInMemory = false; BooCompiler compiler = new BooCompiler(_options); ParseOptions(args); if (0 == _options.Input.Count) { throw new ApplicationException(Boo.Lang.ResourceManager.GetString("BooC.NoInputSpecified")); } //move standard libpaths below any new ones: _options.LibPaths.Add(_options.LibPaths[0]); _options.LibPaths.Add(_options.LibPaths[1]); _options.LibPaths.RemoveAt(0); _options.LibPaths.RemoveAt(0); if (_options.StdLib) { _options.LoadDefaultReferences(); } else if (!_noConfig) { _references.Insert(0, "mscorlib"); } LoadReferences(); ConfigurePipeline(); if (_options.TraceSwitch.TraceInfo) { compiler.Parameters.Pipeline.BeforeStep += new CompilerStepEventHandler(OnBeforeStep); compiler.Parameters.Pipeline.AfterStep += new CompilerStepEventHandler(OnAfterStep); } TimeSpan setupTime = DateTime.Now - start; start = DateTime.Now; CompilerContext context = compiler.Run(); TimeSpan processingTime = DateTime.Now - start; if (context.Warnings.Count > 0) { Console.Error.WriteLine(context.Warnings); Console.Error.WriteLine(Boo.Lang.ResourceManager.Format("BooC.Warnings", context.Warnings.Count)); } if (context.Errors.Count > 0) { foreach (CompilerError error in context.Errors) { Console.Error.WriteLine(error.ToString(_options.TraceSwitch.TraceInfo)); } Console.Error.WriteLine(Boo.Lang.ResourceManager.Format("BooC.Errors", context.Errors.Count)); } else { resultCode = 0; } if (_options.TraceSwitch.TraceWarning) { Console.Error.WriteLine(Boo.Lang.ResourceManager.Format("BooC.ProcessingTime", _options.Input.Count, processingTime.TotalMilliseconds, setupTime.TotalMilliseconds)); } } catch (Exception x) { object message = _options.TraceSwitch.TraceWarning ? (object)x : (object)x.Message; Console.Error.WriteLine(Boo.Lang.ResourceManager.Format("BooC.FatalError", message)); } return(resultCode); }