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

51
LINES

< > BotCompany Repo | #1017551 // Multi-Line Java Eval [Evaluate Java Code]

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

Uses 1113K of libraries. Click here for Pure Java version (21791L/116K).

!7

set flag DynModule. // for transpilation

cm JavaEval > 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(dm_typeWriterTextArea expression()), rThread { mediumRefresh(); evalIt() }),
      withTopMargin(3, vstackWithSpacing(5,
        withBottomMargin(fontSizePlus(4, makeBold(toolTip("Evaluate the code (always medium-refreshes)", jbutton("EVAL", rThread { mediumRefresh(); evalIt() }))))),
        toolTip("Evaluate in latest language version", jbutton("Fresh", rThread { refresh(); evalIt() })),
        centerAndEastWithMargin(
          withToolTip("Use the real Java compiler, don't use shortcuts - just leave checked if in doubt",
            dm_fieldCheckBox("Real", 'realEval)),
          jPopDownButton_noText(
            "Show Java Transpilation", rThread showJavaTranspilation,
          ))))),
    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;
    dm_action_printHere(shorten80(getText(taInput)), r {
      calculating = true;
      temp afterwards(r { calculating = false });
      dm_javaEvalModule_doIt(getText(taInput), realEval);
    }, printName := false);
  }
  
  void showJavaTranspilation enter {
    dm_showText("Java Transpilation", loadProgramTextFile("main.java"));
  }
}

Author comment

Began life as a copy of #1016755

download  show line numbers  debug dex  old transpilations   

Travelled to 17 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mowyntqkapby, mqqgnosmbjvj, nazvggbglmsf, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1017551
Snippet name: Multi-Line Java Eval [Evaluate Java Code]
Eternal ID of this version: #1017551/36
Text MD5: 599bd8cb9fbfc08d5ab62debd531c8ea
Transpilation MD5: 03b91be360fa73fd707e5a2248d7f077
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: 2021-09-20 23:09:09
Source code size: 1765 bytes / 51 lines
Pitched / IR pitched: No / No
Views / Downloads: 734 / 567703
Version history: 35 change(s)
Referenced in: [show references]