** initial stack: func arg1 ... argn extra1 ... ** ^ ci->func ^ L->top ** final stack: func nil ... nil extra1 ... func arg1 ... argn ** ^ ci->func */
| 253 | ** ^ ci->func |
| 254 | */ |
| 255 | static void buildhiddenargs (lua_State *L, CallInfo *ci, const Proto *p, |
| 256 | int totalargs, int nfixparams, int nextra) { |
| 257 | int i; |
| 258 | ci->u.l.nextraargs = nextra; |
| 259 | luaD_checkstack(L, p->maxstacksize + 1); |
| 260 | /* copy function to the top of the stack, after extra arguments */ |
| 261 | setobjs2s(L, L->top.p++, ci->func.p); |
| 262 | /* move fixed parameters to after the copied function */ |
| 263 | for (i = 1; i <= nfixparams; i++) { |
| 264 | setobjs2s(L, L->top.p++, ci->func.p + i); |
| 265 | setnilvalue(s2v(ci->func.p + i)); /* erase original parameter (for GC) */ |
| 266 | } |
| 267 | ci->func.p += totalargs + 1; /* 'func' now lives after hidden arguments */ |
| 268 | ci->top.p += totalargs + 1; |
| 269 | } |
| 270 | |
| 271 | |
| 272 | void luaT_adjustvarargs (lua_State *L, CallInfo *ci, const Proto *p) { |
no outgoing calls
no test coverage detected