| 845 | |
| 846 | |
| 847 | static void funcargs(LexState *ls, expdesc *f, int line) { |
| 848 | FuncState *fs = ls->fs; |
| 849 | expdesc args; |
| 850 | int base, nparams; |
| 851 | switch (ls->t.token) { |
| 852 | case '(': { /* funcargs -> '(' [ explist ] ')' */ |
| 853 | luaX_next(ls); |
| 854 | if (ls->t.token == ')') /* arg list is empty? */ |
| 855 | args.k = VVOID; |
| 856 | else { |
| 857 | explist(ls, &args); |
| 858 | luaK_setmultret(fs, &args); |
| 859 | } |
| 860 | check_match(ls, ')', '(', line); |
| 861 | break; |
| 862 | } |
| 863 | case '{': { /* funcargs -> constructor */ |
| 864 | constructor(ls, &args); |
| 865 | break; |
| 866 | } |
| 867 | case TK_STRING: { /* funcargs -> STRING */ |
| 868 | codestring(ls, &args, ls->t.seminfo.ts); |
| 869 | luaX_next(ls); /* must use 'seminfo' before 'next' */ |
| 870 | break; |
| 871 | } |
| 872 | default: { |
| 873 | luaX_syntaxerror(ls, "function arguments expected"); |
| 874 | } |
| 875 | } |
| 876 | lua_assert(f->k == VNONRELOC); |
| 877 | base = f->u.info; /* base register for call */ |
| 878 | if (hasmultret(args.k)) |
| 879 | nparams = LUA_MULTRET; /* open call */ |
| 880 | else { |
| 881 | if (args.k != VVOID) |
| 882 | luaK_exp2nextreg(fs, &args); /* close last argument */ |
| 883 | nparams = fs->freereg - (base + 1); |
| 884 | } |
| 885 | init_exp(f, VCALL, luaK_codeABC(fs, OP_CALL, base, nparams + 1, 2)); |
| 886 | luaK_fixline(fs, line); |
| 887 | fs->freereg = base + 1; /* call remove function and arguments and leaves |
| 888 | (unless changed) one result */ |
| 889 | } |
| 890 | |
| 891 | |
| 892 |
no test coverage detected