void Parse(ModuleContainer module) { bool tokenize_only = module.Compiler.Settings.TokenizeOnly; var sources = module.Compiler.SourceFiles; Location.Initialize(sources); var session = new ParserSession() { UseJayGlobalArrays = true, LocatedTokens = new Tokenizer.LocatedToken[15000] }; for (int i = 0; i < sources.Count; ++i) { if (tokenize_only) { tokenize_file(sources[i], module, session); } else { Parse(sources[i], module, session, Report); } } }
void Reset() { CompilerCallableEntryPoint.PartialReset(); Location.Reset(); Location.Initialize(ctx.SourceFiles); }
static void Reset() { CompilerCallableEntryPoint.PartialReset(); // Workaround for API limitation where full message printer cannot be passed ReportPrinter printer = MessageOutput == Console.Out || MessageOutput == Console.Error ? new ConsoleReportPrinter(MessageOutput) : new StreamReportPrinter(MessageOutput); ctx = new CompilerContext(new Report(printer)); RootContext.ToplevelTypes = new ModuleContainer(ctx, true); // // PartialReset should not reset the core types, this is very redundant. // if (!TypeManager.InitCoreTypes(ctx)) { throw new Exception("Failed to InitCoreTypes"); } TypeManager.InitOptionalCoreTypes(ctx); Location.AddFile(null, "{interactive}"); Location.Initialize(); current_debug_name = "interactive" + (count++) + ".dll"; if (Environment.GetEnvironmentVariable("SAVE") != null) { CodeGen.Init(current_debug_name, current_debug_name, false, ctx); } else { CodeGen.InitDynamic(ctx, current_debug_name); } }
static void Reset() { CompilerCallableEntryPoint.PartialReset(); // // PartialReset should not reset the core types, this is very redundant. // if (!TypeManager.InitCoreTypes()) { throw new Exception("Failed to InitCoreTypes"); } TypeManager.InitOptionalCoreTypes(); Location.AddFile("{interactive}"); Location.Initialize(); current_debug_name = "interactive" + (count++) + ".dll"; if (Environment.GetEnvironmentVariable("SAVE") != null) { CodeGen.Init(current_debug_name, current_debug_name, false); } else { CodeGen.InitDynamic(current_debug_name); } }
static void Reset() { CompilerCallableEntryPoint.PartialReset(); Location.AddFile(null, "{interactive}"); Location.Initialize(); }
void Parse(ModuleContainer module, bool returnAtSignInVerbatimIdentifiers) { bool tokenize_only = module.Compiler.Settings.TokenizeOnly; var sources = module.Compiler.SourceFiles; Location.Initialize(sources); var session = new ParserSession { UseJayGlobalArrays = true, LocatedTokens = new LocatedToken[15000], LocationsBag = new LocationsBag() }; for (int i = 0; i < sources.Count; ++i) { if (tokenize_only) { tokenize_file(sources[i], module, session, returnAtSignInVerbatimIdentifiers); } else { Parse(sources[i], module, session, Report, returnAtSignInVerbatimIdentifiers); } } }
static void Reset() { CompilerCallableEntryPoint.PartialReset(); Location.AddFile(null, "{interactive}"); Location.Initialize(); current_debug_name = "interactive" + (count++) + ".dll"; }
void ParseStartupFiles () { Driver d = new Driver (ctx); Location.Initialize (ctx.SourceFiles); var parser_session = new ParserSession (); for (int i = 0; i < startup_files; ++i) { var sf = ctx.SourceFiles [i]; d.Parse (sf, module, parser_session, ctx.Report); } }
void ParseStartupFiles() { Driver d = new Driver(ctx); Location.Initialize(ctx.SourceFiles); for (int i = 0; i < startup_files; ++i) { var sf = ctx.Settings.SourceFiles [i]; d.Parse(sf, module); } }
public static CompilerCompilationUnit ParseFile(string[] args, Stream input, string inputFile, ReportPrinter reportPrinter) { lock (parseLock) { try { // Driver d = Driver.Create (args, false, null, reportPrinter); // if (d == null) // return null; var r = new Report(reportPrinter); CommandLineParser cmd = new CommandLineParser(r, Console.Out); var setting = cmd.ParseArguments(args); if (setting == null || r.Errors > 0) { return(null); } setting.Version = LanguageVersion.V_5; CompilerContext ctx = new CompilerContext(setting, r); var files = new List <CompilationSourceFile> (); var unit = new CompilationSourceFile(inputFile, inputFile, 0); var module = new ModuleContainer(ctx); unit.NamespaceContainer = new NamespaceContainer(null, module, null, unit); files.Add(unit); Location.Initialize(files); // TODO: encoding from driver SeekableStreamReader reader = new SeekableStreamReader(input, Encoding.UTF8); RootContext.ToplevelTypes = module; CSharpParser parser = new CSharpParser(reader, unit); parser.Lexer.TabSize = 1; parser.Lexer.sbag = new SpecialsBag(); parser.LocationsBag = new LocationsBag(); parser.UsingsBag = new UsingsBag(); parser.parse(); return(new CompilerCompilationUnit() { ModuleCompiled = RootContext.ToplevelTypes, LocationsBag = parser.LocationsBag, UsingsBag = parser.UsingsBag, SpecialsBag = parser.Lexer.sbag, LastYYValue = parser.LastYYVal }); } finally { Reset(); } } }
void Parse(ModuleContainer module) { Location.Initialize(module.Compiler.SourceFiles); bool tokenize_only = module.Compiler.Settings.TokenizeOnly; var sources = module.Compiler.SourceFiles; for (int i = 0; i < sources.Count; ++i) { if (tokenize_only) { tokenize_file(sources[i]); } else { Parse(sources[i], module); } } }
void Parse(ModuleContainer module) { Location.Initialize(); bool tokenize_only = ctx.Settings.TokenizeOnly; var cu = Location.SourceFiles; for (int i = 0; i < cu.Count; ++i) { if (tokenize_only) { tokenize_file(cu[i]); } else { Parse(cu[i], module); } } }
void Parse(ModuleContainer module) { bool tokenize_only = module.Compiler.Settings.TokenizeOnly; var sources = module.Compiler.SourceFiles; Location.Initialize(sources); var session = new ParserSession() { UseJayGlobalArrays = true, LocatedTokens = new Tokenizer.LocatedToken[15000], AsLocatedTokens = new Mono.PlayScript.Tokenizer.LocatedToken[15000] }; bool has_playscript_files = false; for (int i = 0; i < sources.Count; ++i) { if (tokenize_only) { tokenize_file(sources[i], module, session); } else { Parse(sources[i], module, session, Report); } if (sources[i].FileType == SourceFileType.PlayScript) { has_playscript_files = true; } } // PlayScript needs to add generated code after parsing. if (has_playscript_files) { Mono.PlayScript.CodeGenerator.GenerateCode(module, session, Report); } }
void ParseParallel(ModuleContainer module) { var sources = module.Compiler.SourceFiles; Location.Initialize(sources); var pcount = Environment.ProcessorCount; var threads = new Thread[System.Math.Max(2, pcount - 1)]; for (int i = 0; i < threads.Length; ++i) { var t = new Thread(l => { var session = new ParserSession() { //UseJayGlobalArrays = true, }; var report = new Report(ctx, Report.Printer); // TODO: Implement flush at once printer for (int ii = (int)l; ii < sources.Count; ii += threads.Length) { Parse(sources[ii], module, session, report); } // TODO: Merge warning regions }); t.Start(i); threads[i] = t; } for (int t = 0; t < threads.Length; ++t) { threads[t].Join(); } }
void Reset() { Location.Reset(); Location.Initialize(ctx.SourceFiles); }