MCPcopy Create free account
hub / github.com/SakuraEngine/SakuraEngine / pushclosure

Function pushclosure

xrepo/packages/l/lua/port/lua/src/lvm.c:788–803  ·  view source on GitHub ↗

** create a new Lua closure, push it in the stack, and initialize ** its upvalues. */

Source from the content-addressed store, hash-verified

786** its upvalues.
787*/
788static void pushclosure (lua_State *L, Proto *p, UpVal **encup, StkId base,
789 StkId ra) {
790 int nup = p->sizeupvalues;
791 Upvaldesc *uv = p->upvalues;
792 int i;
793 LClosure *ncl = luaF_newLclosure(L, nup);
794 ncl->p = p;
795 setclLvalue2s(L, ra, ncl); /* anchor new closure in stack */
796 for (i = 0; i < nup; i++) { /* fill in its upvalues */
797 if (uv[i].instack) /* upvalue refers to local variable? */
798 ncl->upvals[i] = luaF_findupval(L, base + uv[i].idx);
799 else /* get upvalue from enclosing function */
800 ncl->upvals[i] = encup[uv[i].idx];
801 luaC_objbarrier(L, ncl, ncl->upvals[i]);
802 }
803}
804
805
806/*

Callers 1

luaV_executeFunction · 0.85

Calls 2

luaF_newLclosureFunction · 0.70
luaF_findupvalFunction · 0.70

Tested by

no test coverage detected