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

Function pushclosure

extlibs/lua/src/lvm.c:784–799  ·  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

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

Callers 1

luaV_executeFunction · 0.85

Calls 2

luaF_newLclosureFunction · 0.85
luaF_findupvalFunction · 0.85

Tested by

no test coverage detected