Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

13
LINES

< > BotCompany Repo | #1031587 // tok_transpileGetSet - "get/set" [old version with late evaluation of argument]

JavaX fragment (include)

svoid tok_transpileGetSet(LS tok) {
  for (int i : jfindAll_reverse(tok, "get/set <id>(")) {
    S field = tok.get(i+6);
    int iOpening = i+8;
    int iClosing = tok_findEndOfBracketPart(tok, iOpening)-1;
    S expr = tok_join(tok, iOpening+1, iClosing);
    S var = makeVar(), var2 = makeVar();
    tokReplace_reTok(tok, i, iClosing+1,
      replaceDollarVars("iSetAndGet($var -> { var \*var2*/ = $expr; $var2?.$field = $var; }, " +
        "() -> { var \*var2*/ = $expr; ret $var2?.$field; })",
        +var, +var2, +expr, +field);
  }
}

Author comment

Began life as a copy of #1031580

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt

No comments. add comment

Snippet ID: #1031587
Snippet name: tok_transpileGetSet - "get/set" [old version with late evaluation of argument]
Eternal ID of this version: #1031587/1
Text MD5: 2d444720055d9cab7b612bc36e880a22
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-06-22 06:53:43
Source code size: 553 bytes / 13 lines
Pitched / IR pitched: No / No
Views / Downloads: 195 / 214
Referenced in: [show references]