Transpiled version (5830L) is out of date.
static void tok_simplyCachedFunctions(L<S> tok) { pcall { int i = -1; while ((i = jfind(tok, i+1, "simplyCached <id>")) >= 0) { Cl<S> modifiers = tok_modifiersLeftOf(tok, i); int iMod = tok_leftScanModifiers(tok, i); int bracket = indexOf(tok, "(", i); S fName; try { fName = assertIdentifier(tok.get(bracket-2)); } on fail { printTokenContext(tok, iMod, bracket-2); } int iMod2 = tok_rightScanModifiers(tok, i+2); modifiers.addAll(codeTokensFromSubList(tok, i+2, iMod2)); S type = joinSubList(tok, iMod2, bracket-3); S boxedType = tok_toNonPrimitiveTypes(type); S fieldMods = joinWithSpace(listMinus(modifiers, "final", "abstract")); S functionMods = joinWithSpace(listMinus(modifiers, "transient", "abstract")); S loadFunctionMods = joinWithSpace(listMinus(modifiers, "transient")); bool isVoid = eq(type, "void"); S var = isVoid ? "ran_" + fName : fName + "_cache"; S implFunc = isVoid ? fName + "_impl" : fName + "_load"; S varType = isVoid ? "bool" : boxedType; S replacement = // variable declaration "\*fieldMods*/ \*varType*/ \*var*/;\n" + "\*functionMods*/ \*type*/ \*fName*/() { " // function body + (isVoid ? "if (\*var*/) ret; set \*var*/; \*implFunc*/();" : "if (\*var*/ == null) \*var*/ = \*fName*/_load(); ret \*var*/;") + "}\n\n" // beginning of impl function + "\*loadFunctionMods*/ \*type*/ \*implFunc*/"; replaceTokens_reTok(tok, iMod, bracket-1, replacement); } }}
Began life as a copy of #1010513
download show line numbers debug dex old transpilations
Travelled to 9 computer(s): bhatertpkbcr, cfunsshuasjs, gwrvuhgaqvyk, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1020989 |
Snippet name: | tok_simplyCachedFunctions |
Eternal ID of this version: | #1020989/26 |
Text MD5: | af51afa8096c64a94f01c3c6e73f5110 |
Author: | stefan |
Category: | javax / transpiling |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-08-05 16:49:10 |
Source code size: | 1632 bytes / 44 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 460 / 671 |
Version history: | 25 change(s) |
Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) #1024403 - tok_mruCachedFunctions [dev.] #1034327 - test_tok_simplyCachedFunctions #1034364 - tok_cachedFunctions_new |