MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / pushclosure

Function pushclosure

third-party/lua-5.4.6/src/lvm.c:796–811  ·  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

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

Callers 1

luaV_executeFunction · 0.70

Calls 2

luaF_newLclosureFunction · 0.70
luaF_findupvalFunction · 0.70

Tested by

no test coverage detected