private List <Platform.LibraryForExport> GetLibrariesForExport( Platform.AbstractPlatform platform, Dictionary <string, Library> librariesByName, Dictionary <string, object> constantFlags, Pastel.PastelCompiler vm) { using (new PerformanceSection("VmGenerator.GetLibrariesForExport")) { Dictionary <string, Pastel.PastelCompiler> libraryCompilation = this.GenerateLibraryParseTree( platform, constantFlags, new InlineImportCodeLoader(), librariesByName.Values, vm); List <Platform.LibraryForExport> libraries = new List <Platform.LibraryForExport>(); Dictionary <string, Library> libraryByName = new Dictionary <string, Library>(); foreach (string libraryName in libraryCompilation.Keys.OrderBy(s => s)) { Library library = librariesByName[libraryName]; libraryByName[library.Name] = library; Platform.LibraryForExport libraryForExport = this.CreateLibraryForExport( library.Name, library.Version, libraryCompilation[library.Name], library.Resources); libraries.Add(libraryForExport); } // Now that all libraries are read and initialized, go through and resolve all deferred DLL's that required all libraries to be loaded. foreach (Platform.LibraryForExport lfe in libraries) { foreach (Platform.ExportEntity ee in lfe.ExportEntities.GetValueEnumerator()) { if (ee.DeferredFileOutputBytesLibraryName != null) { Library sourceLibrary; if (!libraryByName.TryGetValue(ee.DeferredFileOutputBytesLibraryName, out sourceLibrary)) { throw new InvalidOperationException("The library '" + lfe.Name + "' makes reference to another library '" + ee.DeferredFileOutputBytesLibraryName + "' which could not be found."); } string resourcePath = "resources/" + ee.DeferredFileOutputBytesLibraryPath; byte[] dllFile = sourceLibrary.ReadFileBytes(resourcePath); if (dllFile == null) { throw new InvalidOperationException("Could not find file: '" + resourcePath + "' in library '" + sourceLibrary.Name + "'"); } ee.FileOutput = new FileOutput() { Type = FileOutputType.Binary, BinaryContent = dllFile }; } } } return(libraries); } }
public override void TranslateRegisterLibraryFunction(StringBuilder sb, Expression libRegObj, Expression functionName, Expression functionArgCount) { Platform.LibraryForExport lfe = this.CurrentLibraryFunctionTranslator.Library; string functionNameString = ((InlineConstant)functionName).Value.ToString(); string className = "FP_lib_" + lfe.Name.ToLower() + "_function_" + functionNameString; sb.Append("TranslationHelper.registerLibraryFunction(LibraryWrapper.class, "); this.TranslateExpression(sb, libRegObj); sb.Append(", new "); sb.Append(className); sb.Append("(), "); this.TranslateExpression(sb, functionName); sb.Append(", "); this.TranslateExpression(sb, functionArgCount); sb.Append(')'); }
private List <Platform.LibraryForExport> GetLibrariesForExportPastelFree( Platform.AbstractPlatform platform, Dictionary <string, AssemblyMetadata> librariesById) { List <Platform.LibraryForExport> output = new List <Platform.LibraryForExport>(); foreach (string libraryId in librariesById.Keys.OrderBy(k => k)) { AssemblyMetadata libraryMetadata = librariesById[libraryId]; LibraryExporter library = LibraryExporter.Get(libraryMetadata, platform); Platform.LibraryForExport libraryForExport = this.CreateLibraryForExport( libraryMetadata.ID, libraryMetadata.Version, libraryMetadata.Directory, library.Resources); output.Add(libraryForExport); } return(output); }