1 | // now using lambda0 instead of f |
2 | static void tok_cachedFunctions(L<S> tok) { pcall { |
3 | if (!tok.contains("cached")) ret; |
4 | int i; |
5 | while ((i = jfind(tok, "static cached <id>")) >= 0) { |
6 | int bracket = indexOf(tok, "(", i); |
7 | S fName = assertIdentifier(tok.get(bracket-2)); |
8 | S type = joinSubList(tok, i+4, bracket-3); |
9 | S boxedType = tok_toNonPrimitiveTypes(type); |
10 | |
11 | replaceTokens(tok, i, bracket-1, "static Cache<\*boxedType*/> \*fName*/_cache = new Cache<>(lambda0 \*fName*/_load);\n" |
12 | + "static \*type*/ \*fName*/() { ret \*fName*/_cache!; }\n\n" + "static \*boxedType*/ \*fName*/_load"); |
13 | reTok(tok, i, bracket-3); |
14 | } |
15 | }} |
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1010513 |
Snippet name: | tok_cachedFunctions - use class Cache (single object cache) |
Eternal ID of this version: | #1010513/12 |
Text MD5: | 86ada33690f2ca5314b2c993a8234c82 |
Author: | stefan |
Category: | javax / transpiling |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-09-08 10:19:05 |
Source code size: | 664 bytes / 15 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 549 / 609 |
Version history: | 11 change(s) |
Referenced in: | [show references] |