Libraryless. Click here for Pure Java version (923L/8K/23K).
1 | !747 |
2 | |
3 | m { |
4 | static S v = "x27"; |
5 | static S javaTarget = "1.6"; // compile JavaX for everyone |
6 | |
7 | static int compressionLevel = 9; // Zip compression - highest level |
8 | |
9 | p { |
10 | S s = loadPage("http://tinybrain.de:8080/tb-int/get-transpiled.php?id=1001148&raw=1"); |
11 | L<S> tok = javaTok(s); |
12 | renameToken(tok, "StringFunc", "StrF"); |
13 | for (L<S> c : allClasses(tok)) { |
14 | S name = getClassDeclarationName(c); |
15 | if (name.equals("main")) |
16 | clearAllTokens(c); |
17 | else if (name.equals(v) && !c.get(1).equals("public")) |
18 | c.set(1, "public " + c.get(1)); |
19 | } |
20 | S javaFile = v + ".java"; |
21 | saveTextFile(javaFile, join(tok)); |
22 | print("ok, made " + javaFile); |
23 | |
24 | print("Now compiling. Making a compiler bot just for the occasion."); |
25 | S botQuestion = "Please compile this Java text: " + quote(join(tok)) + " for java version " + quote(javaTarget); |
26 | print("Question to bot: " + shorten(botQuestion, 200)); |
27 | //print("Parses? " + match3("Please compile this Java text: *", botQuestion)); |
28 | |
29 | Class compilerBot = hotwire("#1001155"); |
30 | // We should initialize it or so... we're being lazy here. Works for now. |
31 | S answer = cast call(compilerBot, "answer", botQuestion); |
32 | print("Bot said: " + answer); |
33 | if (answer == null) fail(); |
34 | new Matches m; |
35 | if (!match3("ok, *", answer, m)) |
36 | fail("I don't understand the bot, exiting"); |
37 | |
38 | S classesDir = unquote(m.m[0]); |
39 | print("I think the classes dir is: " + classesDir); |
40 | if (!new File(classesDir).isDirectory()) fail("huh?"); |
41 | |
42 | print("Now making jar."); |
43 | S jarFile = v + ".jar"; |
44 | File ecj = loadLibrary("#1001164"); // ecj.zip |
45 | |
46 | FileOutputStream fout = new FileOutputStream(jarFile); |
47 | ZipOutputStream zout = new ZipOutputStream(fout); |
48 | zout.setLevel(compressionLevel); |
49 | |
50 | makeManifest(zout); |
51 | dir2zip(classesDir, zout); |
52 | zip2zip(ecj, zout); |
53 | zout.close(); |
54 | fout.close(); |
55 | |
56 | print("ok, made " + jarFile + " (" + new File(jarFile).length() + " bytes)"); |
57 | } |
58 | |
59 | static void makeManifest(ZipOutputStream outZip) ctex { |
60 | outZip.putNextEntry(new ZipEntry("META-INF/MANIFEST.MF")); |
61 | outZip.write(toUtf8("Manifest-Version: 1.0\n" + |
62 | "Main-Class: " + v + "\n\n")); |
63 | } |
64 | } |
download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, teubizvjbppd, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1001163 |
Snippet name: | x27.jar maker module (from #1001148) |
Eternal ID of this version: | #1001163/1 |
Text MD5: | b7ae5722da55e69e55127c57dc8afd38 |
Transpilation MD5: | b9089ed5f7b9b222ac6d15d3501a8687 |
Author: | stefan |
Category: | javax |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2015-09-25 21:35:13 |
Source code size: | 2303 bytes / 64 lines |
Pitched / IR pitched: | No / Yes |
Views / Downloads: | 806 / 862 |
Referenced in: | [show references] |