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

42
LINES

< > BotCompany Repo | #1005578 // hotwire_overInternalBot

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (7824L/51K).

static O hotwire_onCompile; // voidfunc(Pair<jarFile, transpiledSource>)
sbool hotwire_serially;
static Lock hotwire_overInternalBot_lock = lock();
sbool hotwire_compileOnServer;

static Class<?> hotwire_overInternalBot(S progID) {
  ret hotwire_overInternalBot(progID, "main");
}

static Class<?> hotwire_overInternalBot(S progID, S mainClass) {
  ret hotwire_overInternalBot(progID, _ -> mainClass);
}

static Class<?> hotwire_overInternalBot(S progID, IF1<ClassLoader, S> calculateMainClass) ctex {
  Pair<File, S> p;
  try {
    p = hotwire_compile(progID);
  } catch e {
    throw rethrow("Error hotwiring " + progID, e);
  }
  File jar = p.a;
  assertTrue(jar.getAbsolutePath(), jar.isFile());
  
  L<File> files = hotwire_collectJars(jar);

  // make class loader
  JavaXClassLoader classLoader = hotwire_makeClassLoader(files);
  classLoader.progID = progID;
  
  S mainClass = calculateMainClass == null ? "main" : calculateMainClass.get(classLoader);
  ret hotwire_finish(classLoader, progID, p.b, mainClass);
}

// returns pair(jar, transpiled src)
static Pair<File, S> hotwire_compile(S progID) {
  Pair<File, S> p = hotwire_compileOnServer && !isLocalSnippetID(progID)
    ? compileSnippetThroughServer(progID)
    : CompilerBot.compileSnippet2(progID);
  lock hotwire_serially ? hotwire_overInternalBot_lock : null;
  callF(hotwire_onCompile, p);
  ret p;
}

Author comment

Began life as a copy of #1002246

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1005578
Snippet name: hotwire_overInternalBot
Eternal ID of this version: #1005578/24
Text MD5: 94b9f7e0293776a379efe28e286c2861
Transpilation MD5: d3bf1ace6b14adb6ef2831e288648bca
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-06-04 22:35:08
Source code size: 1412 bytes / 42 lines
Pitched / IR pitched: No / No
Views / Downloads: 681 / 990
Version history: 23 change(s)
Referenced in: [show references]