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.

sS tok_reverseFunctionArguments(S s) {
  ret join(tok_reverseFunctionArguments(javaTok(s));
}

static LS tok_reverseFunctionArguments(LS tok) {
  tok = first(findFullFunctionDefs(tok, true));
  S name = tok_methodName(tok);
  bool isVoid = tok_staticFunctionAlwaysReturnsVoid(tok, name);
  IntRange r = tok_findArgs(tok);
  LPairS typesAndNames = tok_typesAndNamesOfParams(subList(tok, r));
  replaceSublist(tok, shrinkIntRange(r, 1), ll(tok_joinTypesAndNames(reversed(typesAndNames))));
  replaceSublist(tok, cloneList(tok_methodBody(tok)), ll(
    " {\n  "
      + (isVoid ? "" : "ret ") + name + "(" + joinWithComma(secondOfPairs(typesAndNames)) + ");"
        + "\n}\n"));
  for (int i = 1; i < l(tok); i += 2)
    if (functionAdjuvantKeywords().contains(tok.get(i)))
      clearTokens(tok, i, i+2);
  ret tok;
}

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: 357 / 457
Version history: 5 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1019709 - tok_dropFunctionArguments - doesn't reTok