Exemple #1
0
        public void GenerateVmSourceCodeForPlatform(
            Dictionary <string, FileOutput> output,
            Platform.AbstractPlatform platform,
            ExportBundle nullableExportBundle,
            ResourceDatabase resourceDatabase,
            ICollection <AssemblyMetadata> relevantLibraries,
            string verifiedAbsoluteOutputPath,
            VmGenerationMode mode)
        {
            using (new PerformanceSection("VmGenerator.GenerateVmSourceCodeForPlatform"))
            {
                bool isStandaloneVm = mode == VmGenerationMode.EXPORT_VM_AND_LIBRARIES;
                Dictionary <string, object> constantFlags = platform.GetFlattenedConstantFlags(isStandaloneVm) ?? new Dictionary <string, object>();

                Dictionary <string, AssemblyMetadata> librariesByID = relevantLibraries.ToDictionary(lib => lib.ID);
                List <Platform.LibraryForExport>      libraries     = this.GetLibrariesForExportPastelFree(platform, librariesByID);

                if (mode == VmGenerationMode.EXPORT_SELF_CONTAINED_PROJECT_SOURCE)
                {
                    Options options = new Options();
                    options
                    .SetOption(ExportOptionKey.PROJECT_ID, nullableExportBundle.ProjectID)
                    .SetOption(ExportOptionKey.DESCRIPTION, nullableExportBundle.Description)
                    .SetOption(ExportOptionKey.VERSION, nullableExportBundle.Version)
                    .SetOption(ExportOptionKey.EMBED_BYTE_CODE, nullableExportBundle.GuidSeed)
                    .SetOption(ExportOptionKey.EMBED_BYTE_CODE, true)
                    .SetOption(ExportOptionKey.PROJECT_TITLE, nullableExportBundle.ProjectTitle)
                    .SetOption(ExportOptionKey.LIBRARIES_USED, libraries.Cast <object>().ToArray())
                    .SetOption(ExportOptionKey.HAS_ICON, nullableExportBundle.IconPaths.Length > 0)
                    .SetOption(ExportOptionKey.HAS_LAUNCHSCREEN, nullableExportBundle.LaunchScreenPath != null)
                    .SetOption(ExportOptionKey.IOS_BUNDLE_PREFIX, nullableExportBundle.IosBundlePrefix)
                    .SetOption(ExportOptionKey.JAVA_PACKAGE, nullableExportBundle.JavaPackage)
                    .SetOption(ExportOptionKey.JS_FILE_PREFIX, nullableExportBundle.JsFilePrefix)
                    .SetOption(ExportOptionKey.JS_FULL_PAGE, nullableExportBundle.JsFullPage)
                    .SetOption(ExportOptionKey.SUPPORTED_ORIENTATION, nullableExportBundle.Orientations);

                    if (options.GetBool(ExportOptionKey.HAS_ICON))
                    {
                        options.SetOption(ExportOptionKey.ICON_PATH, nullableExportBundle.IconPaths);
                    }
                    if (options.GetBool(ExportOptionKey.HAS_LAUNCHSCREEN))
                    {
                        options.SetOption(ExportOptionKey.LAUNCHSCREEN_PATH, nullableExportBundle.LaunchScreenPath);
                    }

                    platform.GleanInformationFromPreviouslyExportedProject(options, verifiedAbsoluteOutputPath);

                    platform.ExportProject(
                        output,
                        libraries,
                        resourceDatabase,
                        options);
                }
                else
                {
                    platform.ExportStandaloneVm(
                        output,
                        libraries);
                }
            }
        }
Exemple #2
0
        public Dictionary <string, FileOutput> GenerateVmSourceCodeForPlatform(
            Platform.AbstractPlatform platform,
            CompilationBundle nullableCompilationBundle,
            ResourceDatabase resourceDatabase,
            ICollection <Library> relevantLibraries,
            VmGenerationMode mode)
        {
            using (new PerformanceSection("VmGenerator.GenerateVmSourceCodeForPlatform"))
            {
                Options options = new Options();
                Dictionary <string, object> constantFlags = platform.GetFlattenedConstantFlags() ?? new Dictionary <string, object>();
                this.mode = mode;

                this.AddTypeEnumsToConstants(constantFlags);
                Pastel.PastelCompiler vm = this.GenerateCoreVmParseTree(platform, constantFlags);

                Dictionary <string, Library>     librariesByName = relevantLibraries.ToDictionary(lib => lib.Name);
                List <Platform.LibraryForExport> libraries       = this.GetLibrariesForExport(platform, librariesByName, constantFlags, vm);

                LibraryNativeInvocationTranslatorProvider libTranslationProvider =
                    new LibraryNativeInvocationTranslatorProvider(
                        relevantLibraries.ToDictionary(lib => lib.Name),
                        platform);

                if (mode == VmGenerationMode.EXPORT_SELF_CONTAINED_PROJECT_SOURCE)
                {
                    options
                    .SetOption(ExportOptionKey.PROJECT_ID, nullableCompilationBundle.ProjectID)
                    .SetOption(ExportOptionKey.DESCRIPTION, nullableCompilationBundle.Description)
                    .SetOption(ExportOptionKey.VERSION, nullableCompilationBundle.Version)
                    .SetOption(ExportOptionKey.EMBED_BYTE_CODE, nullableCompilationBundle.GuidSeed)
                    .SetOption(ExportOptionKey.EMBED_BYTE_CODE, true)
                    .SetOption(ExportOptionKey.DEFAULT_TITLE, nullableCompilationBundle.DefaultTitle)
                    .SetOption(ExportOptionKey.LIBRARIES_USED, libraries.Cast <object>().ToArray())
                    .SetOption(ExportOptionKey.HAS_ICON, nullableCompilationBundle.IconPath != null)
                    .SetOption(ExportOptionKey.IOS_BUNDLE_PREFIX, nullableCompilationBundle.IosBundlePrefix)
                    .SetOption(ExportOptionKey.JS_FILE_PREFIX, nullableCompilationBundle.JsFilePrefix);

                    if (options.GetBool(ExportOptionKey.HAS_ICON))
                    {
                        options.SetOption(ExportOptionKey.ICON_PATH, nullableCompilationBundle.IconPath);
                    }

                    return(platform.ExportProject(
                               vm.Globals.Values.OrderBy(v => v.VariableNameToken.Value).ToArray(),
                               vm.StructDefinitions.Values.OrderBy(s => s.NameToken.Value).ToArray(),
                               vm.FunctionDefinitions.Values.OrderBy(f => f.NameToken.Value).ToArray(),
                               libraries,
                               resourceDatabase,
                               options,
                               libTranslationProvider));
                }
                else
                {
                    return(platform.ExportStandaloneVm(
                               vm.Globals.Values.OrderBy(v => v.VariableNameToken.Value).ToArray(),
                               vm.StructDefinitions.Values.OrderBy(s => s.NameToken.Value).ToArray(),
                               vm.FunctionDefinitions.Values.OrderBy(f => f.NameToken.Value).ToArray(),
                               libraries,
                               libTranslationProvider));
                }
            }
        }
Exemple #3
0
        public void GenerateVmSourceCodeForPlatform(
            Dictionary <string, FileOutput> output,
            Platform.AbstractPlatform platform,
            CompilationBundle nullableCompilationBundle,
            ResourceDatabase resourceDatabase,
            ICollection <LibraryMetadata> relevantLibraries,
            string verifiedAbsoluteOutputPath,
            IInlineImportCodeLoader codeLoader,
            VmGenerationMode mode)
        {
            using (new PerformanceSection("VmGenerator.GenerateVmSourceCodeForPlatform"))
            {
                Options options = new Options();
                Dictionary <string, object> constantFlags = platform.GetFlattenedConstantFlags() ?? new Dictionary <string, object>();

                this.AddTypeEnumsToConstants(constantFlags);
                Pastel.PastelCompiler vm = this.GenerateCoreVmParseTree(platform, codeLoader, constantFlags);

                Dictionary <string, LibraryMetadata> librariesByID = relevantLibraries.ToDictionary(lib => lib.ID);
                List <Platform.LibraryForExport>     libraries     = this.GetLibrariesForExport(platform, librariesByID, constantFlags, codeLoader, vm);

                LibraryNativeInvocationTranslatorProvider libTranslationProvider =
                    new LibraryNativeInvocationTranslatorProvider(
                        relevantLibraries.ToDictionary(lib => lib.ID),
                        libraries,
                        platform);

                if (mode == VmGenerationMode.EXPORT_SELF_CONTAINED_PROJECT_SOURCE)
                {
                    options
                    .SetOption(ExportOptionKey.PROJECT_ID, nullableCompilationBundle.ProjectID)
                    .SetOption(ExportOptionKey.DESCRIPTION, nullableCompilationBundle.Description)
                    .SetOption(ExportOptionKey.VERSION, nullableCompilationBundle.Version)
                    .SetOption(ExportOptionKey.EMBED_BYTE_CODE, nullableCompilationBundle.GuidSeed)
                    .SetOption(ExportOptionKey.EMBED_BYTE_CODE, true)
                    .SetOption(ExportOptionKey.DEFAULT_TITLE, nullableCompilationBundle.DefaultTitle)
                    .SetOption(ExportOptionKey.LIBRARIES_USED, libraries.Cast <object>().ToArray())
                    .SetOption(ExportOptionKey.HAS_ICON, nullableCompilationBundle.IconPath != null)
                    .SetOption(ExportOptionKey.HAS_LAUNCHSCREEN, nullableCompilationBundle.LaunchScreenPath != null)
                    .SetOption(ExportOptionKey.IOS_BUNDLE_PREFIX, nullableCompilationBundle.IosBundlePrefix)
                    .SetOption(ExportOptionKey.JAVA_PACKAGE, nullableCompilationBundle.JavaPackage)
                    .SetOption(ExportOptionKey.JS_FILE_PREFIX, nullableCompilationBundle.JsFilePrefix)
                    .SetOption(ExportOptionKey.JS_FULL_PAGE, nullableCompilationBundle.JsFullPage)
                    .SetOption(ExportOptionKey.SUPPORTED_ORIENTATION, nullableCompilationBundle.Orientations);

                    if (options.GetBool(ExportOptionKey.HAS_ICON))
                    {
                        options.SetOption(ExportOptionKey.ICON_PATH, nullableCompilationBundle.IconPath);
                    }
                    if (options.GetBool(ExportOptionKey.HAS_LAUNCHSCREEN))
                    {
                        options.SetOption(ExportOptionKey.LAUNCHSCREEN_PATH, nullableCompilationBundle.LaunchScreenPath);
                    }

                    platform.GleanInformationFromPreviouslyExportedProject(options, verifiedAbsoluteOutputPath);

                    platform.ExportProject(
                        output,
                        vm.Globals.Values.OrderBy(v => v.VariableNameToken.Value).ToArray(),
                        vm.StructDefinitions.Values.OrderBy(s => s.NameToken.Value).ToArray(),
                        vm.FunctionDefinitions.Values.OrderBy(f => f.NameToken.Value).ToArray(),
                        libraries,
                        resourceDatabase,
                        options,
                        libTranslationProvider);
                }
                else
                {
                    platform.ExportStandaloneVm(
                        output,
                        vm.Globals.Values.OrderBy(v => v.VariableNameToken.Value).ToArray(),
                        vm.StructDefinitions.Values.OrderBy(s => s.NameToken.Value).ToArray(),
                        vm.FunctionDefinitions.Values.OrderBy(f => f.NameToken.Value).ToArray(),
                        libraries,
                        libTranslationProvider);
                }
            }
        }