Libraryless. Click here for Pure Java version (11552L/72K/231K).
!7 sbool verbose = true; p { makeAndroid("Compiler bot with caching!"); } static synchronized S answer(S s) { new Matches m; if (match3("Please compile this JavaX snippet: *", s, m)) { S snippetID = unquote(m.m[0]); S transpiledSrc = getServerTranspiled(snippetID); int i = transpiledSrc.indexOf('\n'); String libs = transpiledSrc.substring(0, Math.max(0, i)); print("Compiling snippet: " + snippetID + ". Libs: " + libs); transpiledSrc = transpiledSrc.substring(i+1); return compile(transpiledSrc, libs); } if "Please compile this Java text: *" ret compile($1, ""); if "Please compile this Java text: * with libraries *" ret compile($1, $2); if (match3("Please compile this Java text: * for java version *", s, m)) { String src = unquote(m.m[0]); String target = unquote(m.m[1]); return compile(src, "", target); } return null; } static synchronized S compile(S src, S libs) { return compile(src, libs, null); } static synchronized S compile(S src, S dehlibs, S javaTarget) { if (verbose) print("Compiling " + l(src) + " chars"); S md5 = md5(src); File jar = getJarFile(md5); if (jar == null || jar.length() <= 22) { // have to compile try { javaCompileToJar(src, dehlibs, jar); } catch e { ret e.getMessage(); } } else { print("Getting classes from cache (" + jar.getAbsolutePath() + ", " + jar.length() + " bytes)"); touchFile(jar); // so we can find the unused ones easier } return "ok, " + quote(jar.getAbsolutePath()); } static File getJarFile(S md5) { assertTrue(isMD5(md5)); ret new File(getCacheProgramDir(), md5 + ".jar"); }
Began life as a copy of #1001155
download show line numbers debug dex old transpilations
Travelled to 22 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gmoysmmjifsf, gwrvuhgaqvyk, hpgrupgrauku, irmadwmeruwu, ishqpsrjomds, jtubtzbbkimh, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, sawdedvomwva, teubizvjbppd, tslmcundralx, tvejysmllsmz, vouqrxazstgt, xprdwmaupziu
No comments. add comment
Snippet ID: | #1002203 |
Snippet name: | Compiler Bot with dedicated .jar cache (LIVE at bots.tinybrain.de) |
Eternal ID of this version: | #1002203/2 |
Text MD5: | bfcbe726b1e3f56ea6d46dd582562b48 |
Transpilation MD5: | 287d0841d6c54627893590e25f0e5b4c |
Author: | stefan |
Category: | javax |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-10-24 13:17:40 |
Source code size: | 1743 bytes / 64 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 703 / 3242 |
Version history: | 1 change(s) |
Referenced in: | [show references] |