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

9
LINES

< > BotCompany Repo | #1032295 // tok_insertCast

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

Libraryless. Click here for Pure Java version (3149L/17K).

svoid tok_insertCast(LS tok, int i, S type) {
  S expr = tok.get(i);
  S prev = get(tok, i-2), next = get(tok, i+2);
  bool needBrackets = !(
    doubleEq(prev, "=", next, ";")
    || doubleEq(prev, "(", next, ")")
  );
  tok.set(i, roundBracketIf(needBrackets, "(" + type + ") " + expr));
}
 

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1032295
Snippet name: tok_insertCast
Eternal ID of this version: #1032295/2
Text MD5: 7dab8999bab1b757971a1152a785b055
Transpilation MD5: 597f23b937b8ccecf0675e00d65d8506
Author: stefan
Category: javax / transpiling
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-08-27 00:55:52
Source code size: 304 bytes / 9 lines
Pitched / IR pitched: No / No
Views / Downloads: 192 / 274
Version history: 1 change(s)
Referenced in: [show references]