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)

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

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: 197 / 216
Referenced in: [show references]