MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / pushclosure

Function pushclosure

3rd/lua-5.4.3/src/lvm.c:787–802  ·  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

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

Callers 1

luaV_executeFunction · 0.85

Calls 2

luaF_newLclosureFunction · 0.85
luaF_findupvalFunction · 0.85

Tested by

no test coverage detected