Libraryless. Click here for Pure Java version (3577L/22K).
1 | static void tok_timedCachedFunctions(LS tok) { pcall { |
2 | int i; |
3 | while ((i = jfind(tok, "timedCached[<int>.<int>] <id>")) >= 0) { |
4 | int bracket1 = indexOf(tok, "]", i); |
5 | S time = joinSubList(tok, i+4, bracket1-1); |
6 | int bracket = indexOf(tok, "(", bracket1); |
7 | S fName = assertIdentifier(tok.get(bracket-2)); |
8 | S type = joinSubList(tok, bracket1+2, bracket-3); |
9 | S boxedType = tok_toNonPrimitiveTypes(type); |
10 | var modifiersList = tok_modifiersLeftOf(tok, i); |
11 | S modifiers = joinWithSpace(modifiersList); |
12 | S functionModifiers = joinWithSpace(listMinus(modifiersList, "transient")); |
13 | |
14 | replaceTokens(tok, i, bracket-1, |
15 | "TimedCache<\*boxedType*/> \*fName*/_cache = new <>(\*time*/, lambda0 \*fName*/_load);\n" |
16 | + "\*functionModifiers*/ \*type*/ \*fName*/() { ret \*fName*/_cache!; }\n\n" |
17 | + "\*functionModifiers*/ \*boxedType*/ \*fName*/_load"); |
18 | reTok(tok, i, bracket-3); |
19 | } |
20 | }} |
Began life as a copy of #1010513
download show line numbers debug dex old transpilations
Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1025861 |
Snippet name: | tok_timedCachedFunctions - use class TimedCache (single object cache) |
Eternal ID of this version: | #1025861/13 |
Text MD5: | ce181d3fe34af23495806475024be8b0 |
Transpilation MD5: | bea316d051d7de41c7d8380a45d253a2 |
Author: | stefan |
Category: | javax / transpiling |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-06-26 20:24:48 |
Source code size: | 942 bytes / 20 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 282 / 435 |
Version history: | 12 change(s) |
Referenced in: | [show references] |