** 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. */
| 460 | ** original value of that field. |
| 461 | */ |
| 462 | static void pushclosure (lua_State *L, Proto *p, UpVal **encup, StkId base, |
| 463 | StkId ra) { |
| 464 | int nup = p->sizeupvalues; |
| 465 | Upvaldesc *uv = p->upvalues; |
| 466 | int i; |
| 467 | Closure *ncl = luaF_newLclosure(L, nup); |
| 468 | ncl->l.p = p; |
| 469 | setclLvalue(L, ra, ncl); /* anchor new closure in stack */ |
| 470 | for (i = 0; i < nup; i++) { /* fill in its upvalues */ |
| 471 | if (uv[i].instack) /* upvalue refers to local variable? */ |
| 472 | ncl->l.upvals[i] = luaF_findupval(L, base + uv[i].idx); |
| 473 | else /* get upvalue from enclosing function */ |
| 474 | ncl->l.upvals[i] = encup[uv[i].idx]; |
| 475 | } |
| 476 | luaC_barrierproto(L, p, ncl); |
| 477 | p->cache = ncl; /* save it on cache for reuse */ |
| 478 | } |
| 479 | |
| 480 | |
| 481 | /* |
no test coverage detected