Transpiled version (10712L) is out of date.
static class CompilerBot { static bool verbose; static File compileSnippet(S snippetID) { ret compileSnippet(snippetID, ""); } static Pair<File, S> compileSnippet2(S snippetID) { ret compileSnippet2(snippetID, ""); } // returns jar path static File compileSnippet(S snippetID, S javaTarget) { ret compileSnippet2(snippetID, javaTarget).a; } // returns jar path, Java source static Pair<File, S> compileSnippet2(S snippetID, S javaTarget) { S transpiledSrc = getServerTranspiled2(snippetID); if (transpiledSrc == null) fail("Snippet not found or not public: " + snippetID); int i = transpiledSrc.indexOf('\n'); String libs = transpiledSrc.substring(0, Math.max(0, i)); if (verbose) print("Compiling snippet: " + snippetID + ". Libs: " + libs); transpiledSrc = transpiledSrc.substring(i+1); return pair(compile(transpiledSrc, libs, javaTarget, snippetID), transpiledSrc); } static File compile(S src) { ret compile(src, ""); } static File compile(S src, S libs) { ret compile(src, libs, null); } static File compile(S src, S dehlibs, S javaTarget) { ret compile(src, dehlibs, javaTarget, null); } static File compile(S src, S dehlibs, S javaTarget, S progID) { if (verbose) print("Compiling " + l(src) + " chars"); // Note: This is different from the calculation in x30 // (might lead to programs being compiled twice) S md5 = md5(dehlibs + "\n" + src + "\n" + fsIOpt(progID)); File jar = getJarFile(md5); if (jar == null || jar.length() <= 22) { // have to compile //print("Have to compile: " + progID + " / " + md5); LS tok = javaTok(src); LS mainClass = findMainClass(tok); bool canRename = mainClass != null && useDummyMainClasses() && isSnippetID(progID) && !tok_classHasModifier(mainClass, "public"); if (verbose) print("useRenaming: " + useDummyMainClasses() + ", canRename: " + canRename + ", progID: " + progID); S mainClassName = joinNemptiesWithDot(tok_packageName(tok), or(getClassDeclarationName(mainClass), "main")); temp tempSetTL(javaCompileToJar_addMoreFiles, dir -> { if (!eq(mainClassName, "main")) saveTextFile(newFile(dir, "main-class"), mainClassName); saveTextFile(newFile(dir, manifestPathInJar()), manifestTextForMainClass(mainClassName); }); javaCompileToJar_optionalRename(src, dehlibs, jar, canRename ? progID : null, progID); } else { if (verbose) print("Getting classes from cache (" + jar.getAbsolutePath() + ", " + jar.length() + " bytes)"); touchFile(jar); // so we can find the unused ones easier } ret jar; } // look in non-virtual JavaX-Caches first (important for packaged programs) // Edit: Huh? This is strange. static File getJarFile(S md5) { assertTrue(isMD5(md5)); S fileName = md5 + ".jar"; File f = newFile(destDir(), fileName); ret fileExists(f) ? f : userDir(appendSlash(compilerBotDestDirSubName()) + fileName); } /*swappable*/ static File destDir() { ret compilerBotDestDir(); } }
Began life as a copy of #1002203
download show line numbers debug dex old transpilations
Travelled to 19 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, jtubtzbbkimh, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, sawdedvomwva, tslmcundralx, tvejysmllsmz, vouqrxazstgt, xprdwmaupziu
No comments. add comment