| 816 | |
| 817 | |
| 818 | static void funcargs (LexState *ls, expdesc *f, int line) { |
| 819 | FuncState *fs = ls->fs; |
| 820 | expdesc args; |
| 821 | int base, nparams; |
| 822 | switch (ls->t.token) { |
| 823 | case '(': { /* funcargs -> '(' [ explist ] ')' */ |
| 824 | luaX_next(ls); |
| 825 | if (ls->t.token == ')') /* arg list is empty? */ |
| 826 | args.k = VVOID; |
| 827 | else { |
| 828 | explist(ls, &args); |
| 829 | luaK_setmultret(fs, &args); |
| 830 | } |
| 831 | check_match(ls, ')', '(', line); |
| 832 | break; |
| 833 | } |
| 834 | case '{': { /* funcargs -> constructor */ |
| 835 | constructor(ls, &args); |
| 836 | break; |
| 837 | } |
| 838 | case TK_STRING: { /* funcargs -> STRING */ |
| 839 | codestring(ls, &args, ls->t.seminfo.ts); |
| 840 | luaX_next(ls); /* must use 'seminfo' before 'next' */ |
| 841 | break; |
| 842 | } |
| 843 | default: { |
| 844 | luaX_syntaxerror(ls, "function arguments expected"); |
| 845 | } |
| 846 | } |
| 847 | lua_assert(f->k == VNONRELOC); |
| 848 | base = f->u.info; /* base register for call */ |
| 849 | if (hasmultret(args.k)) |
| 850 | nparams = LUA_MULTRET; /* open call */ |
| 851 | else { |
| 852 | if (args.k != VVOID) |
| 853 | luaK_exp2nextreg(fs, &args); /* close last argument */ |
| 854 | nparams = fs->freereg - (base+1); |
| 855 | } |
| 856 | init_exp(f, VCALL, luaK_codeABC(fs, OP_CALL, base, nparams+1, 2)); |
| 857 | luaK_fixline(fs, line); |
| 858 | fs->freereg = base+1; /* call remove function and arguments and leaves |
| 859 | (unless changed) one result */ |
| 860 | } |
| 861 | |
| 862 | |
| 863 |
no test coverage detected