Transpiled version (5379L) is out of date.
// We'd be really fancy if we filtered out return statements in all // inner blocks. sbool containsReturnWithArgument(LS tok) { for (int i = 1; i+2 < l(tok); i += 2) { S t = tok.get(i); if (eqOneOf(t, "ret", "return") && neqOneOf(tok.get(i+2), ";", "if", "unless", "with")) true; // skip embedded functions & classes if (eqOneOf(t, "embedded", "class") && isIdentifier(get(tok, i+2)) // skip anonymous classes || eq(t, "(") && eqGet(tok, i+2, ")") && eqGet(tok, i+4, "{")) i = tok_findEndOfMethodDecl(tok, i)-1; // this might just work for classes too // skip runnables / lambdas if (eqOneOf(t, "r", ">") && eqGet(tok, i+2, "{")) i = findEndOfBlock(tok, i+2)-1; } false; } sbool containsReturnWithArgument(S code) { ret containsReturnWithArgument(javaTok(code)); }
Began life as a copy of #1003913
download show line numbers debug dex old transpilations
Travelled to 16 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1003914 |
Snippet name: | containsReturnWithArgument - does JavaX code contain a return statement with a value? |
Eternal ID of this version: | #1003914/11 |
Text MD5: | 8baabf20aa4d835c0f5c6b117d51d216 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-03-05 23:01:09 |
Source code size: | 858 bytes / 24 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 636 / 706 |
Version history: | 10 change(s) |
Referenced in: | [show references] |