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

61
LINES

< > BotCompany Repo | #1020090 // Multi-Line Java Eval w/baby symbols [Evaluate Java Code, Dyn Module, one baby per submodule made :)]

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

Uses 108K of libraries. Compilation Failed (20060L/148K).

!7

set flag DynModule. // for transpilation
set flag NoSwitchableFields.

sclass JavaEval extends DynPrintLog {
  S expression;
  bool realEval = true;
  transient bool calculating;
  transient O value;
  transient JTextArea taInput;
  transient Throwable error;
  transient JPanel babiesPanel;

  start {
    loadImage2(#1101447);
    makeDependent_postProcess = r updateBabySymbols;
    dm_vmBus_onMessage('gcDone, r updateBabySymbols);
    doEvery(300.0, r updateBabySymbols); // just to be sure to updat eit sometimes
  }

  visualize {
    ret centerAndSouthWithMargins(
      jvsplit( 
        centerAndEastWithMarginInbetween(
          onCtrlEnter(taInput = jEnableUndoRedo(typeWriterTextArea(expression)), rThread evalIt),
          vstackWithSpacing(
            jbutton("Fresh", rThread { refresh(); evalIt() }),
            jbutton("Eval", rThread evalIt),
            withToolTip("Don't interpret", dm_fieldCheckBox("Real", 'realEval)))),
        super.visualize()),
        jScrollWithoutBorder(babiesPanel = leftAlignedLine()));
  }
  
  void refresh {
    call(dm_transpiler(), 'refresh);
    loadFunctions_clearCache();
    print("Refreshed translator.");
  }
  
  void evalIt {
    if (calculating) ret;
    calculating = true;
    temp afterwards(r { calculating = false });
    dm_javaEvalModule_doIt(gtt(taInput), realEval);
  }
  
  void updateBabySymbols enter {
    dm_q().add(r {
      final int n = l(dependentClasses());
      final BufferedImage img = scaleImageToWidth(loadImage2(#1101447), 24);
      swing {
        removeAllComponents(babiesPanel);
        repeat n {
          babiesPanel.add(toolTip("You have made one cute little subprocess!", jimage(img)));
        }
        revalidate(babiesPanel);
      }
    });
  }
}

Author comment

Began life as a copy of #1017551

download  show line numbers  debug dex  old transpilations   

Travelled to 8 computer(s): bhatertpkbcr, cfunsshuasjs, gwrvuhgaqvyk, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1020090
Snippet name: Multi-Line Java Eval w/baby symbols [Evaluate Java Code, Dyn Module, one baby per submodule made :)]
Eternal ID of this version: #1020090/18
Text MD5: 2a07f6216b26f0897deac86272d92bca
Transpilation MD5: 6d9dfe2d61957f2fcc9e25e82474df76
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: 2018-12-14 01:05:45
Source code size: 1819 bytes / 61 lines
Pitched / IR pitched: No / No
Views / Downloads: 259 / 1294
Version history: 17 change(s)
Referenced in: [show references]