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

Function pushclosure

third-party/lua-5.5.0/src/lvm.c:834–849  ·  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

832** its upvalues.
833*/
834static void pushclosure (lua_State *L, Proto *p, UpVal **encup, StkId base,
835 StkId ra) {
836 int nup = p->sizeupvalues;
837 Upvaldesc *uv = p->upvalues;
838 int i;
839 LClosure *ncl = luaF_newLclosure(L, nup);
840 ncl->p = p;
841 setclLvalue2s(L, ra, ncl); /* anchor new closure in stack */
842 for (i = 0; i < nup; i++) { /* fill in its upvalues */
843 if (uv[i].instack) /* upvalue refers to local variable? */
844 ncl->upvals[i] = luaF_findupval(L, base + uv[i].idx);
845 else /* get upvalue from enclosing function */
846 ncl->upvals[i] = encup[uv[i].idx];
847 luaC_objbarrier(L, ncl, ncl->upvals[i]);
848 }
849}
850
851
852/*

Callers 1

luaV_executeFunction · 0.70

Calls 2

luaF_newLclosureFunction · 0.70
luaF_findupvalFunction · 0.70

Tested by

no test coverage detected