Transpiled version (4270L) is out of date.
1 | svoid tok_expandMultiTypeArgument_v3(LS tok, |
2 | int iArgStart, int iArgEnd, // start and end of argument |
3 | S argName, S mainType, LPairS alts) { |
4 | |
5 | iArgEnd |= 1; |
6 | |
7 | int iOpening = lastIndexOf(tok, iArgStart, "("); // TODO: brackets |
8 | int iClosing = findEndOfBracketPart2(tok, iOpening)-1; |
9 | |
10 | // function name |
11 | int iName = iOpening-2; |
12 | S name = assertIdentifier(get(tok, iName)); |
13 | |
14 | int iType = tok_leftScanType(tok, iName); |
15 | int iStart = tok_leftScanTypeArgsOpt(tok, iType); |
16 | iStart = leftScanModifiers(tok, iStart); |
17 | //print("Found method head: " + joinSubList(tok, iStart, iClosing+1)); |
18 | LS _args1 = subList(tok, iOpening+1, iArgStart); |
19 | LS _args2 = subList(tok, iArgEnd&~1, iClosing); |
20 | LS args1 = tok_parseArgsDeclList2(_args1); |
21 | LS args2 = tok_parseArgsDeclList2(_args2); |
22 | LS type = subList(tok, iType-1, iName); |
23 | bool isVoid = containsOneOf(codeTokens(type), javaxVoidAliases()); |
24 | //printVars(+expr, +_args1, +_args2, +args1, +args2, +type, +isVoid); |
25 | |
26 | new LS altFunctions; |
27 | |
28 | for (S altDecl, S conversionExpr : unpair alts) { |
29 | if (tok_isSingleIdentifier(altDecl)) |
30 | altDecl += " \*argName*/"; |
31 | |
32 | if (tok_isSingleIdentifier(conversionExpr)) |
33 | conversionExpr += "(\*argName*/)"; |
34 | |
35 | S altHead = joinSubList(tok, iStart, iOpening+1) |
36 | + joinWithComma(concatLists( |
37 | args1, |
38 | ll(altDecl), |
39 | args2)) + ")"; |
40 | altFunctions.add(altHead + " { " |
41 | + (isVoid ? "" : "return ") + name + "(" + |
42 | joinWithComma(concatLists( |
43 | map tok_lastIdentifier(args1), |
44 | ll(conversionExpr), |
45 | map tok_lastIdentifier(args2))) + "); }\n"); |
46 | } |
47 | |
48 | replaceTokens_reTok(tok, iArgStart|1, iArgEnd, mainType + " " + argName); |
49 | tokPrepend_reTok(tok, iStart, lines(altFunctions)); |
50 | } |
Began life as a copy of #1032175
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx
No comments. add comment
Snippet ID: | #1032213 |
Snippet name: | tok_expandMultiTypeArgument_v3 |
Eternal ID of this version: | #1032213/4 |
Text MD5: | 3a746f6ddb4ccf0d4a879271054da6bd |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-06-27 10:33:15 |
Source code size: | 1823 bytes / 50 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 204 / 297 |
Version history: | 3 change(s) |
Referenced in: | [show references] |