Transpiled version (12814L) is out of date.
1 | sbool transpileRaw_silent = true; |
2 | sbool transpileRaw_useDiskCache; |
3 | |
4 | ifdef DynModule |
5 | sS transpileRaw(S mainJava) { |
6 | ret (S) call(dm_transpiler(), 'transpileRaw, mainJava, false, transpileRaw_useDiskCache); |
7 | } |
8 | endifdef |
9 | |
10 | ifndef DynModule |
11 | static Class transpileRaw_trans; |
12 | sbool transpileRaw_mine = true; |
13 | static bool transpileRaw_verySilent; |
14 | sbool transpileRaw_dontCopyFromCreator; |
15 | static Lock transpileRaw_lock = lock(); |
16 | |
17 | static new ThreadLocal<Bool> transpileRaw_asInclude; |
18 | static new ThreadLocal<S> transpileRaw_progID; |
19 | |
20 | static S transpileRaw(S mainJava) { |
21 | ret transpileRaw(mainJava, false, transpileRaw_useDiskCache); |
22 | } |
23 | |
24 | static S transpileRaw(S mainJava, bool fragment) { |
25 | ret transpileRaw(mainJava, fragment, transpileRaw_useDiskCache); |
26 | } |
27 | |
28 | static S transpileRaw(S mainJava, bool fragment, bool useDiskCache) { |
29 | mainJava = dropTranslators(mainJava); |
30 | if (!transpileRaw_dontCopyFromCreator) |
31 | transpileRaw_copyFromCreator(); |
32 | lock transpileRaw_lock; |
33 | |
34 | File cacheFile = null; |
35 | if (useDiskCache) { |
36 | cacheFile = new File(javaxCodeDir(), "Transpilations/" + uniqueFileNameUsingMD5_80_v2(mainJava) + ".java"); |
37 | try answer loadTextFile(cacheFile); |
38 | } |
39 | |
40 | temp transpileRaw_verySilent ? null : tempLoadingAnim("Transpiling..."); |
41 | |
42 | transpileRaw_translator(); |
43 | |
44 | //setOpt(transpileRaw_trans, dontPrintSource := true); |
45 | setOpt(transpileRaw_trans, localStuffOnly := fragment); |
46 | setOpt(transpileRaw_trans, asInclude := isTrue(transpileRaw_asInclude!)); |
47 | setOpt(transpileRaw_trans, mainSnippetID := transpileRaw_progID!); |
48 | set(transpileRaw_trans, +mainJava); |
49 | // TODO: setOpt(transpileRaw_trans, transpilingSnippetID := ); |
50 | set(transpileRaw_trans, +print_byThread); |
51 | if (!transpileRaw_verySilent) |
52 | print("Running translator " + getOpt(transpileRaw_trans, 'programID)); |
53 | callMain(transpileRaw_trans); |
54 | //print("Ran translator " + identityHashCode(transpileRaw_trans)); |
55 | S main = cast get(transpileRaw_trans, "mainJava"); |
56 | if (useDiskCache) { |
57 | saveTextFile(new File(cacheFile.getPath() + "x"), mainJava); |
58 | saveTextFile(cacheFile, main); |
59 | } |
60 | ret main; |
61 | } |
62 | |
63 | static swappable Class transpileRaw_translator() { |
64 | if (transpileRaw_trans == null) { |
65 | //print("Loading translator."); |
66 | transpileRaw_trans = transpileRaw_makeTranslator(); |
67 | transpileRaw_mine = true; |
68 | makeDependent(transpileRaw_trans); |
69 | //print("Loaded translator: " + identityHashCode(transpileRaw_trans)); |
70 | } |
71 | setOpt(transpileRaw_trans, "print_silent", transpileRaw_silent); |
72 | ret transpileRaw_trans; |
73 | } |
74 | |
75 | static swappable Class transpileRaw_makeTranslator() { |
76 | ret hotwireSharingLibraries_silently(defaultJavaXTranslatorID()); |
77 | } |
78 | |
79 | svoid transpileRaw_copyFromCreator { |
80 | lock transpileRaw_lock; |
81 | if (transpileRaw_trans != null) ret; |
82 | O c = creator(); |
83 | if (c == null) ret; |
84 | Class trans = cast getOpt(c, 'transpileRaw_trans); |
85 | Lock lock = cast getOpt(c, 'transpileRaw_lock); |
86 | if (trans != null && lock != null) { |
87 | print("Using creator's transpiler: " + getProgramID(c) + " => " + programID()); |
88 | transpileRaw_lock = lock; |
89 | transpileRaw_trans = trans; |
90 | transpileRaw_mine = false; |
91 | } |
92 | } |
93 | |
94 | svoid cleanMeUp_transpileRaw { |
95 | if (transpileRaw_mine) |
96 | cleanUp(transpileRaw_trans); |
97 | transpileRaw_trans = null; // release proactively (it's big) |
98 | } |
99 | endifndef |
download show line numbers debug dex old transpilations
Travelled to 17 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mowyntqkapby, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1003847 |
Snippet name: | transpileRaw - reuse creator class's (or OS's) transpiler if possible |
Eternal ID of this version: | #1003847/54 |
Text MD5: | 7c1643b640aa463c1e883044ffc6153c |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-03-01 20:29:05 |
Source code size: | 3362 bytes / 99 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 891 / 1124 |
Version history: | 53 change(s) |
Referenced in: | [show references] |