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