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