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

48
LINES

< > BotCompany Repo | #1020726 - loadLibraryOrSrcLib

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

Transpiled version (10739L) is out of date.

scope loadLibraryOrSrcLib.

sbool #srcLibsEnabled = true;

// to avoid checking src libs too often when booting OS
static ThreadLocal<Map<Long, File>> #tempCache = new ThreadLocal;
static new ThreadLocal<IF1<S, File>> loadLibraryOrSrcLib_compiler;

static File loadLibraryOrSrcLib(S snippetID, IF1<S, File> compiler default loadLibraryOrSrcLib_compiler!) ctex {
  vmBus_send loadLibraryOrSrcLib(snippetID);
  long id = parseSnippetID(snippetID);
  
  if (#tempCache! != null) {
    File f = #tempCache->get(id);
    if (f != null)
      ret f with print(snippetID + " from tempCache: " + f);
  }
  
  bool srcLib = #srcLibsEnabled && isMarkedAsSrcLib(snippetID);
  if (srcLib) {
    print(snippetID + " marked as src lib, compiling");
    File f;
    if (compiler != null)
      f = compiler.get(snippetID);
    else
      f = pairA(hotwire_compile(snippetID));
    print("Src lib: " + f);
    mapPut(#tempCache!, id, f);
    ret f;
  }
    
  File f = DiskSnippetCache_getLibrary(id);
  if (fileSize(f) != 0) ret f with print(snippetID + " from disk cache: " + f);
  try {
    print("Trying " + snippetID + " as binary library");
    ret loadDataSnippetToFile(snippetID);
  } catch e {
    if (#srcLibsEnabled) {
      print("Trying " + snippetID + " as src lib");
      if (nempty(loadSnippet(snippetID))) {
        print("Is src lib.");
        markAsSrcLib(snippetID);
        ret pairA(hotwire_compile(snippetID));
      }
    }
    throw rethrow(e);
  }
}

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: #1020726
Snippet name: loadLibraryOrSrcLib
Eternal ID of this version: #1020726/19
Text MD5: 69d916358c3da7dc7a94c50d216bfaa8
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-11-02 01:25:07
Source code size: 1508 bytes / 48 lines
Pitched / IR pitched: No / No
Views / Downloads: 260 / 366
Version history: 18 change(s)
Referenced in: [show references]