private Dictionary <string, Pastel.PastelCompiler> GenerateLibraryParseTree( Platform.AbstractPlatform platform, Dictionary <string, object> constantFlags, InlineImportCodeLoader codeLoader, ICollection <Library> relevantLibraries, Pastel.PastelCompiler sharedScope) { using (new PerformanceSection("VmGenerator.GenerateLibraryParseTree")) { Dictionary <string, Pastel.PastelCompiler> libraries = new Dictionary <string, Pastel.PastelCompiler>(); foreach (Library library in relevantLibraries) { string libName = library.Name; Dictionary <string, object> constantsLookup = Util.MergeDictionaries <string, object>(constantFlags, library.CompileTimeConstants); Pastel.PastelCompiler compiler = new Pastel.PastelCompiler( true, sharedScope, constantsLookup, codeLoader, library.GetReturnTypesForNativeMethods(), library.GetArgumentTypesForNativeMethods()); libraries[libName] = compiler; Dictionary <string, string> supplementalCode = library.GetSupplementalTranslatedCode(false); Dictionary <string, string> pastelSupplementalCode = library.GetSupplementalTranslatedCode(true); Dictionary <string, string> translatedCode = library.GetNativeCode(); // need to load from the actual Library instance, which could have come from either CRAYON_HOME or source string registryCode = library.GetRegistryCode(); if (registryCode == null) { if (supplementalCode.Count > 0 || translatedCode.Count > 0) { throw new InvalidOperationException("The library '" + libName + "' has translated code but no function_registry.pst file."); } } else { compiler.CompileBlobOfCode("LIB:" + libName + "/function_registry.pst", registryCode); foreach (string supplementalFile in supplementalCode.Keys) { string code = supplementalCode[supplementalFile]; compiler.CompileBlobOfCode("LIB:" + libName + "/supplemental/" + supplementalFile, code); } foreach (string translatedFile in translatedCode.Keys) { string code = translatedCode[translatedFile]; compiler.CompileBlobOfCode("LIB:" + libName + "/translate/" + translatedFile, code); } compiler.Resolve(); } } return(libraries); } }
private Pastel.PastelCompiler GenerateCoreVmParseTree( Platform.AbstractPlatform platform, IInlineImportCodeLoader codeLoader, Dictionary <string, object> constantFlags) { using (new PerformanceSection("VmGenerator.GenerateCoreVmParseTree")) { Pastel.PastelCompiler compiler = new Pastel.PastelCompiler( false, null, constantFlags, codeLoader, null, null); foreach (string file in INTERPRETER_BASE_FILES) { string code = codeLoader.LoadCode(file); compiler.CompileBlobOfCode(file, code); } compiler.Resolve(); return(compiler); } }