MCPcopy Create free account
hub / github.com/Achain-Dev/Achain / pushclosure

Function pushclosure

src/Chain/libraries/glua/lvm.cpp:678–697  ·  view source on GitHub ↗

** create a new Lua closure, push it in the stack, and initialize ** its upvalues. Note that the closure is not cached if prototype is ** already black (which means that 'cache' was already cleared by the ** GC). */

Source from the content-addressed store, hash-verified

676** GC).
677*/
678static void pushclosure(lua_State *L, Proto *p, UpVal **encup, StkId base,
679 StkId ra) {
680 int nup = p->sizeupvalues;
681 Upvaldesc *uv = p->upvalues;
682 int i;
683 LClosure *ncl = luaF_newLclosure(L, nup);
684 ncl->p = p;
685 setclLvalue(L, ra, ncl); /* anchor new closure in stack */
686 for (i = 0; i < nup; i++) { /* fill in its upvalues */
687 if (uv[i].instack) /* upvalue refers to local variable? */
688 ncl->upvals[i] = luaF_findupval(L, base + uv[i].idx);
689 else /* get upvalue from enclosing function */
690 ncl->upvals[i] = encup[uv[i].idx];
691 if (nullptr != ncl->upvals[i])
692 ncl->upvals[i]->refcount++;
693 /* new closure is white, so we do not need a barrier here */
694 }
695 if (!isblack(p)) /* cache will not break GC invariant? */
696 p->cache = ncl; /* save it on cache for reuse */
697}
698
699/*
700** finish execution of an opcode interrupted by an yield

Callers 1

vmcaseFunction · 0.85

Calls 2

luaF_newLclosureFunction · 0.85
luaF_findupvalFunction · 0.85

Tested by

no test coverage detected