Uses 911K of libraries. Click here for Pure Java version (13764L/76K).
1 | !7 |
2 | |
3 | set flag DynModule. // for transpilation |
4 | |
5 | cmodule JavaEval extends DynPrintLog { |
6 | S expression; |
7 | bool realEval = true; |
8 | transient bool calculating; |
9 | transient O value; |
10 | transient JTextArea taInput; |
11 | transient Throwable error; |
12 | |
13 | visual withMargin(jvsplit( |
14 | centerAndEastWithMarginInbetween( |
15 | onCtrlEnter(taInput = jEnableUndoRedo(typeWriterTextArea(expression)), rThread evalIt), |
16 | withTopMargin(3, vstackWithSpacing(5, |
17 | withBottomMargin(fontSizePlus(4, makeBold(toolTip("Evaluate the code", jbutton("EVAL", rThread evalIt))))), |
18 | toolTip("Evaluate with latest standard functions", jbutton("Medium", rThread { mediumRefresh(); evalIt() })), |
19 | toolTip("Evaluate in latest language version", jbutton("Fresh", rThread { refresh(); evalIt() })), |
20 | withToolTip("Use the real Java compiler, don't use shortcuts - just leave checked if in doubt", dm_fieldCheckBox("Real", 'realEval))))), |
21 | super)); |
22 | |
23 | void mediumRefresh enter { |
24 | dm_mediumRefreshTranspiler(); |
25 | loadFunctions_clearCache(); |
26 | print("Medium-refreshed translator."); |
27 | } |
28 | |
29 | void refresh enter { |
30 | dm_refreshTranspiler(); |
31 | loadFunctions_clearCache(); |
32 | print("Refreshed translator."); |
33 | } |
34 | |
35 | void evalIt enter { |
36 | if (calculating) ret; |
37 | calculating = true; |
38 | temp afterwards(r { calculating = false }); |
39 | dm_javaEvalModule_doIt(gtt(taInput), realEval); |
40 | } |
41 | } |
Began life as a copy of #1017551
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1026426 |
Snippet name: | Multi-Line Java Eval [Evaluate Java Code, old version with eval + medium] |
Eternal ID of this version: | #1026426/1 |
Text MD5: | 7a22a1d2eea9adb304268fe5f090ea94 |
Transpilation MD5: | cc726fb10a2a8eec312019aff1b56237 |
Author: | stefan |
Category: | javax / stefan's os |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-01-03 18:02:04 |
Source code size: | 1432 bytes / 41 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 179 / 247 |
Referenced in: | [show references] |