MCPcopy Create free account
hub / github.com/DFHack/dfhack / luaF_findupval

Function luaF_findupval

depends/lua/src/lfunc.c:57–80  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

55
56
57UpVal *luaF_findupval (lua_State *L, StkId level) {
58 UpVal **pp = &L->openupval;
59 UpVal *p;
60 UpVal *uv;
61 lua_assert(isintwups(L) || L->openupval == NULL);
62 while (*pp != NULL && (p = *pp)->v >= level) {
63 lua_assert(upisopen(p));
64 if (p->v == level) /* found a corresponding upvalue? */
65 return p; /* return it */
66 pp = &p->u.open.next;
67 }
68 /* not found: create a new upvalue */
69 uv = luaM_new(L, UpVal);
70 uv->refcount = 0;
71 uv->u.open.next = *pp; /* link it to list of open upvalues */
72 uv->u.open.touched = 1;
73 *pp = uv;
74 uv->v = level; /* current value lives in the stack */
75 if (!isintwups(L)) { /* thread not in list of threads with upvalues? */
76 L->twups = G(L)->twups; /* link it to the list */
77 G(L)->twups = L;
78 }
79 return uv;
80}
81
82
83void luaF_close (lua_State *L, StkId level) {

Callers 1

pushclosureFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected