Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

41
LINES

< > BotCompany Repo | #1026426 // Multi-Line Java Eval [Evaluate Java Code, old version with eval + medium]

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Uses 911K of libraries. Click here for Pure Java version (13764L/76K).

!7

set flag DynModule. // for transpilation

cmodule JavaEval extends DynPrintLog {
  S expression;
  bool realEval = true;
  transient bool calculating;
  transient O value;
  transient JTextArea taInput;
  transient Throwable error;
  
  visual withMargin(jvsplit(
    centerAndEastWithMarginInbetween(
      onCtrlEnter(taInput = jEnableUndoRedo(typeWriterTextArea(expression)), rThread evalIt),
      withTopMargin(3, vstackWithSpacing(5,
        withBottomMargin(fontSizePlus(4, makeBold(toolTip("Evaluate the code", jbutton("EVAL", rThread evalIt))))),
        toolTip("Evaluate with latest standard functions", jbutton("Medium", rThread { mediumRefresh(); evalIt() })),
        toolTip("Evaluate in latest language version", jbutton("Fresh", rThread { refresh(); evalIt() })),
        withToolTip("Use the real Java compiler, don't use shortcuts - just leave checked if in doubt", dm_fieldCheckBox("Real", 'realEval))))),
    super));

  void mediumRefresh enter {
    dm_mediumRefreshTranspiler();
    loadFunctions_clearCache();
    print("Medium-refreshed translator.");
  }
  
  void refresh enter {
    dm_refreshTranspiler();
    loadFunctions_clearCache();
    print("Refreshed translator.");
  }
  
  void evalIt enter {
    if (calculating) ret;
    calculating = true;
    temp afterwards(r { calculating = false });
    dm_javaEvalModule_doIt(gtt(taInput), realEval);
  }
}

Author comment

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: 178 / 246
Referenced in: [show references]