示例#1
0
        public static CompilationBundle Compile(BuildContext buildContext)
        {
            using (new PerformanceSection("CompilationBundle.Compile"))
            {
                Parser parser = new Parser(buildContext, null);
                Crayon.ParseTree.Executable[] resolvedParseTree = parser.ParseAllTheThings();

                ByteCodeCompiler bcc    = new ByteCodeCompiler();
                ByteBuffer       buffer = bcc.GenerateByteCode(parser, resolvedParseTree);

                string jsFilePrefix = buildContext.JsFilePrefix == null
                    ? ""
                    : ("/" + buildContext.JsFilePrefix.Trim('/') + "/");

                return(new CompilationBundle()
                {
                    ByteCode = buffer,
                    LibrariesUsed = parser.LibraryManager.LibrariesUsed,
                    ProjectID = buildContext.ProjectID,
                    Version = buildContext.Version,
                    Description = buildContext.Description,
                    GuidSeed = buildContext.GuidSeed,
                    DefaultTitle = buildContext.DefaultTitle,
                    JsFilePrefix = jsFilePrefix,
                    IosBundlePrefix = buildContext.IosBundlePrefix,
                    IconPath = buildContext.IconFilePath,
                    WindowWidth = buildContext.WindowWidth,
                    WindowHeight = buildContext.WindowHeight,
                });
            }
        }
示例#2
0
        private ByteBuffer GenerateByteCode(BuildContext buildContext, string inputFolder)
        {
            Parser userCodeParser = new Parser(null, buildContext, null);

            ParseTree.Executable[] userCode = userCodeParser.ParseAllTheThings(inputFolder);

            ByteCodeCompiler bcc    = new ByteCodeCompiler();
            ByteBuffer       buffer = bcc.GenerateByteCode(userCodeParser, userCode);

            this.LibraryManager            = userCodeParser.SystemLibraryManager;
            this.LibraryBigSwitchStatement = this.LibraryManager.GetLibrarySwitchStatement(this);
            this.InterpreterCompiler       = new InterpreterCompiler(this, userCodeParser.SystemLibraryManager);
            return(buffer);
        }
示例#3
0
        private static async Task <InternalCompilationBundle> CompileImpl(CompileRequest compileRequest, Wax.WaxHub waxHub)
        {
            ParserContext parserContext = new ParserContext(compileRequest, waxHub);

            TopLevelEntity[] resolvedParseTree = await parserContext.ParseAllTheThings();

            ByteCodeCompiler bcc    = new ByteCodeCompiler();
            ByteBuffer       buffer = bcc.GenerateByteCode(parserContext, resolvedParseTree);

            return(new InternalCompilationBundle()
            {
                ByteCode = ByteCodeEncoder.Encode(buffer),
                RootScope = parserContext.RootScope,
                AllScopes = parserContext.ScopeManager.ImportedAssemblyScopes.ToArray(),
            });
        }
示例#4
0
        public static ExportBundle Compile(BuildContext buildContext)
        {
            using (new PerformanceSection("ExportBundle.Compile"))
            {
                ParserContext parserContext = new ParserContext(buildContext);
                Parser.ParseTree.TopLevelEntity[] resolvedParseTree = parserContext.ParseAllTheThings();

                ByteCodeCompiler bcc    = new ByteCodeCompiler();
                ByteBuffer       buffer = bcc.GenerateByteCode(parserContext, resolvedParseTree);

                string jsFilePrefix = buildContext.JsFilePrefix;
                jsFilePrefix = (jsFilePrefix == null || jsFilePrefix == "" || jsFilePrefix == "/")
                    ? ""
                    : ("/" + buildContext.JsFilePrefix.Trim('/') + "/");

                return(new ExportBundle()
                {
                    ByteCode = buffer,
                    UserCodeScope = parserContext.RootScope,
                    LibraryScopesUsed = parserContext.ScopeManager.ImportedAssemblyScopes.ToArray(),
                    ProjectID = buildContext.ProjectID,
                    Version = buildContext.TopLevelAssembly.Version,
                    Description = buildContext.TopLevelAssembly.Description,
                    GuidSeed = buildContext.GuidSeed,
                    ProjectTitle = buildContext.ProjectTitle,
                    JsFilePrefix = jsFilePrefix,
                    JsFullPage = buildContext.JsFullPage,
                    IosBundlePrefix = buildContext.IosBundlePrefix,
                    JavaPackage = buildContext.JavaPackage,
                    IconPaths = buildContext.IconFilePaths,
                    LaunchScreenPath = buildContext.LaunchScreenPath,
                    WindowWidth = buildContext.WindowWidth,
                    WindowHeight = buildContext.WindowHeight,
                    Orientations = buildContext.Orientation,
                });
            }
        }