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/20
Text MD5: 6e4d21062ed79d2e0f26484c8136802a
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-03-29 18:47:38
Source code size: 1512 bytes / 48 lines
Pitched / IR pitched: No / No
Views / Downloads: 428 / 598
Version history: 19 change(s)
Referenced in: [show references]