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

53
LINES

< > BotCompany Repo | #1017057 // Experiment with code fragments [Dyn Module, dev.]

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

Libraryless. Click here for Pure Java version (17095L/124K).

1  
!7
2  
3  
sclass Experiment > DynCalculatedList {
4  
  LinkedHashMap<S, T3<Long>> results = new LinkedHashMap; // code -> true count, false count, error count
5  
  S code;
6  
  
7  
  transient int timeout = 10000;
8  
  transient JTextField tfCode;
9  
  
10  
  visualize {
11  
    ret northAndCenterWithMargins(
12  
      centerAndEastWithMarginInbetween(
13  
        tfCode = onEnter(jLiveValueTextField_bothWays(dm_fieldLiveValue('code)), rThread evalIt),
14  
        hstackWithSpacing(
15  
          jbutton("Fresh", rThread { refresh(); evalIt() }),
16  
          jbutton("Eval", rThread evalIt))),
17  
      super.visualize());
18  
  }
19  
  
20  
  start {
21  
    thread "Test Code" { testCode("1 == 2"); }
22  
  }
23  
  
24  
  void refresh {
25  
    veryQuickJava_refresh();
26  
    print("Refreshed translator.");
27  
  }
28  
  
29  
  void evalIt { testCode(code); }
30  
  
31  
  void testCode(fS code) {
32  
    fO o = evalJava_prep2(evalJava_prep(code));
33  
    setOpt(o, 'creator_class := weakRef(creator())); // Report to OS directly
34  
    O result = null;
35  
    pcall {
36  
      result = evalWithTimeoutOrNull(timeout, func { evalJava_main2(o) });
37  
    }
38  
    cleanUp(o);
39  
    temp enter();
40  
    T3<Long> t = results.get(code);
41  
    if (t == null) results.put(code, t = new T3(0L, 0L, 0L));
42  
    if (isTrueOpt(result)) t.a++;
43  
    else if (isFalseOpt(result)) t.b++;
44  
    else t.c++;
45  
    changeAndUpdate();
46  
  }
47  
  
48  
  L<S> calc() {
49  
    ret reversed(map(results, func(S key, T3<Long> value) -> S {
50  
      value.a + "/" + value.b + "/" + value.c + ": " + shorten(key, 100)
51  
    }));
52  
  }
53  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1017057
Snippet name: Experiment with code fragments [Dyn Module, dev.]
Eternal ID of this version: #1017057/23
Text MD5: 21fe95c0514916490612c3180d5d92c6
Transpilation MD5: d5b4598fb6240f0ea69df9764d5e8c34
Author: stefan
Category: javax / a.i.
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-07-11 22:56:41
Source code size: 1512 bytes / 53 lines
Pitched / IR pitched: No / No
Views / Downloads: 312 / 639
Version history: 22 change(s)
Referenced in: [show references]