** create a new Lua closure, push it in the stack, and initialize ** its upvalues. Note that the call to 'luaC_barrierproto' must come ** before the assignment to 'p->cache', as the function needs the ** original value of that field. */
| 399 | ** original value of that field. |
| 400 | */ |
| 401 | static void pushclosure (lua_State *L, Proto *p, UpVal **encup, StkId base, |
| 402 | StkId ra) { |
| 403 | int nup = p->sizeupvalues; |
| 404 | Upvaldesc *uv = p->upvalues; |
| 405 | int i; |
| 406 | Closure *ncl = luaF_newLclosure(L, nup); |
| 407 | ncl->l.p = p; |
| 408 | setclLvalue(L, ra, ncl); /* anchor new closure in stack */ |
| 409 | for (i = 0; i < nup; i++) { /* fill in its upvalues */ |
| 410 | if (uv[i].instack) /* upvalue refers to local variable? */ |
| 411 | ncl->l.upvals[i] = luaF_findupval(L, base + uv[i].idx); |
| 412 | else /* get upvalue from enclosing function */ |
| 413 | ncl->l.upvals[i] = encup[uv[i].idx]; |
| 414 | } |
| 415 | luaC_barrierproto(L, p, ncl); |
| 416 | p->cache = ncl; /* save it on cache for reuse */ |
| 417 | } |
| 418 | |
| 419 | |
| 420 | /* |
no test coverage detected