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

22
LINES

< > BotCompany Repo | #1033170 // tok_reImmutableVars

JavaX fragment (include) [tags: use-pretranspiled]

Transpiled version (5670L) is out of date.

// turns out reMutable and reImmutable are the same thing :)
// TODO: handle this.myVar
svoid tok_reImmutableVars(LS tok) {
  tok_unifyKeywords(tok, remutableKeywords(), "reImmutable");
      
  // without assignment
  jreplace_dyn(tok, "reImmutable <id>;", (_tok, i) -> {
    S var = _get(tok, i+2);
    S var2 = makeVar(var);
    ret "var \*var2*/ = \*var*/; replace var \*var*/ with \*var2*/.\n";
  });
  
  // with assignment
  for (int i : jfind_all_reversed(tok, "reImmutable <id> =")) {
    S var = _get(tok, i+2);
    S var2 = makeVar(var);
    int j = tok_endOfStatement(tok, i+6);
    S expr = joinSubList(tok, i+6, j-1);
    tokReplace_reTok(tok, i, j,
      "var \*var2*/ = \*expr*/; replace var \*var*/ with \*var2*/.\n");
  }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1033170
Snippet name: tok_reImmutableVars
Eternal ID of this version: #1033170/12
Text MD5: 400bdad3f58ecc1eac35f1efd6d02ff0
Author: stefan
Category: javax / transpiling
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-04-15 03:07:56
Source code size: 764 bytes / 22 lines
Pitched / IR pitched: No / No
Views / Downloads: 204 / 341
Version history: 11 change(s)
Referenced in: [show references]