Transpiled version (5379L) is out of date.
1 | // We'd be really fancy if we filtered out return statements in all |
2 | // inner blocks. |
3 | sbool containsReturnWithArgument(LS tok) { |
4 | for (int i = 1; i+2 < l(tok); i += 2) { |
5 | S t = tok.get(i); |
6 | if (eqOneOf(t, "ret", "return") && neqOneOf(tok.get(i+2), ";", "if", "unless", "with")) |
7 | true; |
8 | |
9 | // skip embedded functions & classes |
10 | if (eqOneOf(t, "embedded", "class") && isIdentifier(get(tok, i+2)) |
11 | // skip anonymous classes |
12 | || eq(t, "(") && eqGet(tok, i+2, ")") && eqGet(tok, i+4, "{")) |
13 | i = tok_findEndOfMethodDecl(tok, i)-1; // this might just work for classes too |
14 | |
15 | // skip runnables / lambdas |
16 | if (eqOneOf(t, "r", ">") && eqGet(tok, i+2, "{")) |
17 | i = findEndOfBlock(tok, i+2)-1; |
18 | } |
19 | false; |
20 | } |
21 | |
22 | sbool containsReturnWithArgument(S code) { |
23 | ret containsReturnWithArgument(javaTok(code)); |
24 | } |
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: | 638 / 709 |
Version history: | 10 change(s) |
Referenced in: | [show references] |