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

20
LINES

< > BotCompany Repo | #1019161 // tok_reverseFunctionArguments

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

Transpiled version (13408L) is out of date.

1  
sS tok_reverseFunctionArguments(S s) {
2  
  ret join(tok_reverseFunctionArguments(javaTok(s));
3  
}
4  
5  
static LS tok_reverseFunctionArguments(LS tok) {
6  
  tok = first(findFullFunctionDefs(tok, true));
7  
  S name = tok_methodName(tok);
8  
  bool isVoid = tok_staticFunctionAlwaysReturnsVoid(tok, name);
9  
  IntRange r = tok_findArgs(tok);
10  
  LPairS typesAndNames = tok_typesAndNamesOfParams(subList(tok, r));
11  
  replaceSublist(tok, shrinkIntRange(r, 1), ll(tok_joinTypesAndNames(reversed(typesAndNames))));
12  
  replaceSublist(tok, cloneList(tok_methodBody(tok)), ll(
13  
    " {\n  "
14  
      + (isVoid ? "" : "ret ") + name + "(" + joinWithComma(secondOfPairs(typesAndNames)) + ");"
15  
        + "\n}\n"));
16  
  for (int i = 1; i < l(tok); i += 2)
17  
    if (functionAdjuvantKeywords().contains(tok.get(i)))
18  
      clearTokens(tok, i, i+2);
19  
  ret tok;
20  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 12 computer(s): bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1019161
Snippet name: tok_reverseFunctionArguments
Eternal ID of this version: #1019161/6
Text MD5: f778fca9ec493db8423ea587f28394c2
Author: stefan
Category: javax / transpiling
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2023-01-16 15:38:45
Source code size: 835 bytes / 20 lines
Pitched / IR pitched: No / No
Views / Downloads: 356 / 456
Version history: 5 change(s)
Referenced in: [show references]