Libraryless. Click here for Pure Java version (6058L/33K).
// a cast B ? a.b : ... // => a instanceof B ? ((B) a).b : ... svoid tok_castQuestionDot(L<S> tok) { for (int i : jfind_all_reversed(tok, "<id> cast <id> ?")) { int iEndOfType = indexOf(tok, i, "?"); int iColon = indexOf(tok, iEndOfType, ":"); S var = tok.get(i), type = joinSubList(tok, i+4, iEndOfType-1); S rawType = tok_dropTypeParameters(type); tok_insertCasts_reTok(tok, iEndOfType, iColon, var, type); tok.set(i+2, "instanceof"); } }
Began life as a copy of #1017552
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1033873 |
Snippet name: | tok_castQuestionDot - actually misnamed. transpiles cast + ternary operator |
Eternal ID of this version: | #1033873/2 |
Text MD5: | b9b96236f6aaae119dc0d04269d4905a |
Transpilation MD5: | 84128198118721325204d5aab4d7843c |
Author: | stefan |
Category: | javax / transpiling |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-01-28 19:23:43 |
Source code size: | 485 bytes / 13 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 160 / 233 |
Version history: | 1 change(s) |
Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) |