MCPcopy Create free account
hub / github.com/F-Stack/f-stack / pushclosure

Function pushclosure

freebsd/contrib/openzfs/module/lua/lvm.c:462–478  ·  view source on GitHub ↗

** 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. */

Source from the content-addressed store, hash-verified

460** original value of that field.
461*/
462static 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/*

Callers 1

luaV_executeFunction · 0.70

Calls 2

luaF_newLclosureFunction · 0.70
luaF_findupvalFunction · 0.70

Tested by

no test coverage detected