| 221 | |
| 222 | |
| 223 | int luaF_close (lua_State *L, StkId level, int status) { |
| 224 | UpVal *uv; |
| 225 | while ((uv = L->openupval) != NULL && uplevel(uv) >= level) { |
| 226 | TValue *slot = &uv->u.value; /* new position for value */ |
| 227 | lua_assert(uplevel(uv) < L->top); |
| 228 | if (uv->tbc && status != NOCLOSINGMETH) { |
| 229 | /* must run closing method, which may change the stack */ |
| 230 | ptrdiff_t levelrel = savestack(L, level); |
| 231 | status = callclosemth(L, uplevel(uv), status); |
| 232 | level = restorestack(L, levelrel); |
| 233 | } |
| 234 | luaF_unlinkupval(uv); |
| 235 | setobj(L, slot, uv->v); /* move value to upvalue slot */ |
| 236 | uv->v = slot; /* now current value lives here */ |
| 237 | if (!iswhite(uv)) |
| 238 | gray2black(uv); /* closed upvalues cannot be gray */ |
| 239 | luaC_barrier(L, uv, slot); |
| 240 | } |
| 241 | return status; |
| 242 | } |
| 243 | |
| 244 | |
| 245 | Proto *luaF_newproto (lua_State *L) { |
no test coverage detected