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