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

50
LINES

< > BotCompany Repo | #1001363 // Multi-program VM

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Libraryless. Click here for Pure Java version (1134L/8K/27K).

!747

!1001362 // named thread

m {
  static boolean free = true;
  static new L<PaA> programsStarted;
  
  static class PaA {
    S progID;
    S[] arguments;
    
    *(S *progID, S[] *arguments) {}
    *() {}
  }
  
  p {
    makeAndroid3("A multi-program VM. PID: " + getPID());
    sleep();
  }
  
  static synchronized S answer(S s, L<S> history) {
    new Matches m;
    
    if (match3("please start program *", s, m)) {
      if (!free) ret "Sorry, not free.";
      
      final S progID = formatSnippetID(unquote(m.m[0]));
      final S[] arguments = new S[0];
      programsStarted.add(new PaA(progID, arguments));
      
      // better call JavaX for translation in a single thread.
      final Class theClass = hotwire(progID);
      
      // program may run in its own thread.
      thread progID {
        callMain(theClass, arguments);
      }
      
      ret "OK.";
    }
    
    if (match3("are you free to start a program?", s))
      ret free ? "Yes." : "No."; // free is usually true, but may be set to false by someone to stop this VM from starting more programs.
      
    if (match3("list programs started", s))
      ret structure(programsStarted);
  
    ret null;
  }
}

Author comment

Began life as a copy of #1001361

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1001363
Snippet name: Multi-program VM
Eternal ID of this version: #1001363/1
Text MD5: 99f55c3b323155ca78d6429fb2e4cedb
Transpilation MD5: 37fe4fd000eafee2d10f9f025c87d8e1
Author: stefan
Category: javax
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-10-12 20:49:40
Source code size: 1250 bytes / 50 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 517 / 518
Referenced in: [show references]