private Dictionary <string, Pastel.PastelCompiler> GenerateLibraryParseTree( Platform.AbstractPlatform platform, Dictionary <string, object> constantFlags, IInlineImportCodeLoader codeLoader, ICollection <LibraryMetadata> relevantLibraries, Pastel.PastelCompiler sharedScope) { using (new PerformanceSection("VmGenerator.GenerateLibraryParseTree")) { Dictionary <string, Pastel.PastelCompiler> libraries = new Dictionary <string, Pastel.PastelCompiler>(); foreach (LibraryMetadata libraryMetadata in relevantLibraries) { LibraryExporter library = LibraryExporter.Get(libraryMetadata, platform); 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[library.Metadata.ID] = compiler; Dictionary <string, string> supplementalCode = library.Metadata.GetSupplementalTranslatedCode(); Dictionary <string, string> translatedCode = library.GetNativeCode(); Dictionary <string, string> structCode = library.Metadata.GetStructFilesCode(); // need to load from the actual Library instance, which could have come from either CRAYON_HOME or source string registryCode = library.Metadata.GetRegistryCode(); if (registryCode == null) { if (supplementalCode.Count > 0 || translatedCode.Count > 0) { throw new InvalidOperationException("The library '" + library.Metadata.ID + "' has translated code but no function_registry.pst file."); } } else { compiler.CompileBlobOfCode("LIB:" + library.Metadata.ID + "/function_registry.pst", registryCode); foreach (string structFile in structCode.Keys) { string code = structCode[structFile]; compiler.CompileBlobOfCode("LIB:" + library.Metadata.ID + "/structs/" + structFile, code); } foreach (string supplementalFile in supplementalCode.Keys) { string code = supplementalCode[supplementalFile]; compiler.CompileBlobOfCode("LIB:" + library.Metadata.ID + "/supplemental/" + supplementalFile, code); } foreach (string translatedFile in translatedCode.Keys) { string code = translatedCode[translatedFile]; compiler.CompileBlobOfCode("LIB:" + library.Metadata.ID + "/translate/" + translatedFile, code); } compiler.Resolve(); } } return(libraries); } }