| 236 | |
| 237 | |
| 238 | void luaT_adjustvarargs (lua_State *L, int nfixparams, CallInfo *ci, |
| 239 | const Proto *p) { |
| 240 | int i; |
| 241 | int actual = cast_int(L->top.p - ci->func.p) - 1; /* number of arguments */ |
| 242 | int nextra = actual - nfixparams; /* number of extra arguments */ |
| 243 | ci->u.l.nextraargs = nextra; |
| 244 | luaD_checkstack(L, p->maxstacksize + 1); |
| 245 | /* copy function to the top of the stack */ |
| 246 | setobjs2s(L, L->top.p++, ci->func.p); |
| 247 | /* move fixed parameters to the top of the stack */ |
| 248 | for (i = 1; i <= nfixparams; i++) { |
| 249 | setobjs2s(L, L->top.p++, ci->func.p + i); |
| 250 | setnilvalue(s2v(ci->func.p + i)); /* erase original parameter (for GC) */ |
| 251 | } |
| 252 | ci->func.p += actual + 1; |
| 253 | ci->top.p += actual + 1; |
| 254 | lua_assert(L->top.p <= ci->top.p && ci->top.p <= L->stack_last.p); |
| 255 | } |
| 256 | |
| 257 | |
| 258 | void luaT_getvarargs (lua_State *L, CallInfo *ci, StkId where, int wanted) { |