MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / pushclosure

Function pushclosure

lib/lua/src/lvm.c:803–818  ·  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

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

Callers 1

luaV_executeFunction · 0.85

Calls 2

luaF_newLclosureFunction · 0.85
luaF_findupvalFunction · 0.85

Tested by

no test coverage detected