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

15
LINES

< > BotCompany Repo | #1033031 // tok_onCleanExit

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

Transpiled version (4573L) is out of date.

svoid tok_onCleanExit(LS tok) {
  int i;
  while ((i = jfind(tok, "on clean exit {")) >= 0) {
    int iCurly = indexOf(tok, i, "{");
    int iCurlyEnd = findEndOfBracketPart(tok, iCurly)-1;
    int iRest = iCurlyEnd+2;
    int iEndOfOuterBlock = findEndOfBracketPart(tok, iCurlyEnd)-1;
    
    S code = joinSubList(tok, iCurly, iCurlyEnd+1);
    S var = makeVar();
    
    tokPrepend_reTok(tok, iEndOfOuterBlock, "} on fail { set \*var*/; } finally { if (!\*var*/) \*code*/ } } ");
    tokReplace_reTok(tok, i, iRest, "{ bool \*var*/; try { ");
  }
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1033031
Snippet name: tok_onCleanExit
Eternal ID of this version: #1033031/6
Text MD5: 772f841e1df48ffce10801ed96e1aad6
Author: stefan
Category: javax / transpiling
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-10-11 13:41:36
Source code size: 568 bytes / 15 lines
Pitched / IR pitched: No / No
Views / Downloads: 206 / 257
Version history: 5 change(s)
Referenced in: [show references]