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, }); } }
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); }
private ByteBuffer GenerateByteCode(BuildContext buildContext, string inputFolder, List<string> spriteSheetOpsStringArgs, List<int[]> spriteSheetOpsIntArgs) { Parser userCodeParser = new Parser(null, buildContext, null); ParseTree.Executable[] userCode = userCodeParser.ParseAllTheThings(inputFolder); foreach (Executable ex in userCode) { ex.GenerateGlobalNameIdManifest(userCodeParser.VariableIds); } ByteCodeCompiler bcc = new ByteCodeCompiler(); ByteBuffer buffer = bcc.GenerateByteCode(userCodeParser, userCode, spriteSheetOpsStringArgs, spriteSheetOpsIntArgs); this.LibraryBigSwitchStatement = userCodeParser.SystemLibraryManager.GetLibrarySwitchStatement(this.LanguageId, this.PlatformId); this.InterpreterCompiler = new InterpreterCompiler(this, userCodeParser.SystemLibraryManager); return buffer; }