Download Jar. Libraryless. Click here for Pure Java version (10135L/71K).
1 | !759 |
2 | |
3 | static S vmArgs = "-server"; |
4 | |
5 | static O trans; |
6 | static O onClear; |
7 | |
8 | static Lock lock = lock(); |
9 | |
10 | p { |
11 | //makeBot("The 759 Bot."); |
12 | |
13 | Android3 a = new Android3("The 759 Bot."); |
14 | a.useMultiPort = false; |
15 | a.startPort = 4898; |
16 | makeAndroid(a); |
17 | // run(#1007916); // Compiler Bot |
18 | } |
19 | |
20 | answer { |
21 | print("# " + s); |
22 | lock lock; |
23 | print("go"); |
24 | |
25 | if "please translate *" |
26 | ret transpile(m.unq(0), null); |
27 | |
28 | if "please translate snippet *" time { |
29 | ret transpile(loadSnippet(m.unq(0)), fsI(m.unq(0))); |
30 | } |
31 | |
32 | if "clear 759" { |
33 | cleanUp(trans); |
34 | trans = null; |
35 | setOpt(getJavaX(), "preferCached", false); |
36 | loadTranslator(); |
37 | pcallF(onClear); |
38 | ret "OK, cleared & reloaded."; |
39 | } |
40 | |
41 | if (startsWith(s, "ecj ", m)) try { |
42 | ret "OK " + quote(invokeEcj($1)); |
43 | } catch e { |
44 | ret str(getInnerException(e)); |
45 | } |
46 | |
47 | if "reboot" { |
48 | restartVM(); |
49 | ret "OK"; |
50 | } |
51 | } |
52 | |
53 | static S transpile(S mainJava, S snippetID) { |
54 | mainJava = mainJava.replace("\r\n", "\n").replace("\r", ""); |
55 | |
56 | assertTrue("default translator", mainJava.contains("!752") || mainJava.contains("!759") || containsRegexp(mainJava, "!7\\s")); |
57 | |
58 | mainJava = ("\n" + mainJava).replace("\n!752", "\n").replace("\n!759", "\n").replaceAll("\n!7\\s", "\n\n").substring(1); |
59 | |
60 | S transpiled = transpileRaw(mainJava, snippetID); |
61 | |
62 | // remaining translator invocations are libraries. move to top |
63 | new L<S> libs; |
64 | transpiled = findTranslators2(transpiled, libs); |
65 | if (nempty(libs)) |
66 | transpiled = "LIBS: " + join(" ", libs) + "\n" + transpiled; |
67 | |
68 | ret "OK " + bytesToHex(toUtf8(transpiled)); |
69 | } |
70 | |
71 | // assumes translator invocation has been removed |
72 | static S transpileRaw(S mainJava, S snippetID) { |
73 | if (trans == null) |
74 | loadTranslator(); |
75 | |
76 | set(trans, "mainJava", mainJava); |
77 | setOpt(trans, transpilingSnippetID := snippetID); |
78 | |
79 | callMain(trans); |
80 | ret (S) get(trans, "mainJava"); |
81 | } |
82 | |
83 | static void loadTranslator() { |
84 | trans = hotwire("#759"); |
85 | } |
Began life as a copy of #1002422
download show line numbers debug dex old transpilations
Travelled to 16 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1002424 |
Snippet name: | 759 Bot (for PHP, but not only); can also run ecj (Java compiler) |
Eternal ID of this version: | #1002424/14 |
Text MD5: | 3e0f5ff9bd3bc1dbd1d3e85ba8f5d413 |
Transpilation MD5: | 175fdd0391a96794c10aa9f1fe81c1fc |
Author: | stefan |
Category: | javax |
Type: | JavaX source code (desktop) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-12-15 20:00:12 |
Source code size: | 2020 bytes / 85 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 1009 / 54786 |
Version history: | 13 change(s) |
Referenced in: | [show references] |