Libraryless. Click here for Pure Java version (3580L/21K).
svoid tok_tildeCalls(LS tok) { int iTilde; jreplace(tok, ".~", "~."); // calls without type while ((iTilde = jfind(tok, "~.<id>(")) >= 0) { int iStart = tok_findBeginningOfJavaXTerm(tok, iTilde-2); S fname = tok.get(iTilde+4); tokPrepend(tok, iStart, "call("); replaceTokens(tok, iTilde, iTilde+8, ", " + quote(fname) + (eqGet(tok, iTilde+8, ")") ? "" : ", ")); reTok(tok, iStart, iTilde+8); } // calls with type while ((iTilde = jfind(tok, "~.<id> <id>(")) >= 0) { int iStart = tok_findBeginningOfJavaXTerm(tok, iTilde-2); S type = get(tok, iTilde+4); int iFname = iTilde+6; S fname = tok.get(iFname); // TODO: brackets around the whole thing tokPrepend(tok, iStart, "(" + type + ") call("); replaceTokens(tok, iTilde, iFname+4, ", " + quote(fname) + (eqGet(tok, iFname+4, ")") ? "" : ", ")); reTok(tok, iStart, iFname+4); } // field access while ((iTilde = jfind(tok, "~.<id>")) >= 0) { int iStart = tok_findBeginningOfJavaXTerm(tok, iTilde-2); S fieldName = tok.get(iTilde+4); tokPrepend(tok, iStart, "getOpt " + fieldName + "("); replaceTokens(tok, iTilde, iTilde+5, ")"); reTok(tok, iStart, iTilde+5); } }
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: | #1026296 |
Snippet name: | tok_tildeCalls - reflective calls/field access with ~. or .~ |
Eternal ID of this version: | #1026296/15 |
Text MD5: | 0942be6b02d15e68b7496d87682f883a |
Transpilation MD5: | b724f84e49ac8baafa260bd6acc2242a |
Author: | stefan |
Category: | javax / transpiling |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-04-01 16:27:27 |
Source code size: | 1265 bytes / 37 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 299 / 448 |
Version history: | 14 change(s) |
Referenced in: | [show references] |