diff options
Diffstat (limited to 'lfunc.c')
-rw-r--r-- | lfunc.c | 15 |
1 files changed, 8 insertions, 7 deletions
@@ -59,14 +59,15 @@ void luaF_initupvals (lua_State *L, LClosure *cl) { | |||
59 | 59 | ||
60 | 60 | ||
61 | /* | 61 | /* |
62 | ** Create a new upvalue with the given tag at the given level, | 62 | ** Create a new upvalue at the given level, and link it to the list of |
63 | ** and link it to the list of open upvalues of 'L' after entry 'prev'. | 63 | ** open upvalues of 'L' after entry 'prev'. |
64 | **/ | 64 | **/ |
65 | static UpVal *newupval (lua_State *L, int tag, StkId level, UpVal **prev) { | 65 | static UpVal *newupval (lua_State *L, int tbc, StkId level, UpVal **prev) { |
66 | GCObject *o = luaC_newobj(L, tag, sizeof(UpVal)); | 66 | GCObject *o = luaC_newobj(L, LUA_TUPVAL, sizeof(UpVal)); |
67 | UpVal *uv = gco2upv(o); | 67 | UpVal *uv = gco2upv(o); |
68 | UpVal *next = *prev; | 68 | UpVal *next = *prev; |
69 | uv->v = s2v(level); /* current value lives in the stack */ | 69 | uv->v = s2v(level); /* current value lives in the stack */ |
70 | uv->tbc = tbc; | ||
70 | uv->u.open.next = next; /* link it to list of open upvalues */ | 71 | uv->u.open.next = next; /* link it to list of open upvalues */ |
71 | uv->u.open.previous = prev; | 72 | uv->u.open.previous = prev; |
72 | if (next) | 73 | if (next) |
@@ -94,7 +95,7 @@ UpVal *luaF_findupval (lua_State *L, StkId level) { | |||
94 | pp = &p->u.open.next; | 95 | pp = &p->u.open.next; |
95 | } | 96 | } |
96 | /* not found: create a new upvalue after 'pp' */ | 97 | /* not found: create a new upvalue after 'pp' */ |
97 | return newupval(L, LUA_TUPVAL, level, pp); | 98 | return newupval(L, 0, level, pp); |
98 | } | 99 | } |
99 | 100 | ||
100 | 101 | ||
@@ -170,7 +171,7 @@ static int callclosemth (lua_State *L, StkId level, int status) { | |||
170 | static void trynewtbcupval (lua_State *L, void *ud) { | 171 | static void trynewtbcupval (lua_State *L, void *ud) { |
171 | StkId level = cast(StkId, ud); | 172 | StkId level = cast(StkId, ud); |
172 | lua_assert(L->openupval == NULL || uplevel(L->openupval) < level); | 173 | lua_assert(L->openupval == NULL || uplevel(L->openupval) < level); |
173 | newupval(L, LUA_TUPVALTBC, level, &L->openupval); | 174 | newupval(L, 1, level, &L->openupval); |
174 | } | 175 | } |
175 | 176 | ||
176 | 177 | ||
@@ -204,7 +205,7 @@ int luaF_close (lua_State *L, StkId level, int status) { | |||
204 | while ((uv = L->openupval) != NULL && uplevel(uv) >= level) { | 205 | while ((uv = L->openupval) != NULL && uplevel(uv) >= level) { |
205 | TValue *slot = &uv->u.value; /* new position for value */ | 206 | TValue *slot = &uv->u.value; /* new position for value */ |
206 | lua_assert(uplevel(uv) < L->top); | 207 | lua_assert(uplevel(uv) < L->top); |
207 | if (uv->tt == LUA_TUPVALTBC && status != NOCLOSINGMETH) { | 208 | if (uv->tbc && status != NOCLOSINGMETH) { |
208 | /* must run closing method, which may change the stack */ | 209 | /* must run closing method, which may change the stack */ |
209 | ptrdiff_t levelrel = savestack(L, level); | 210 | ptrdiff_t levelrel = savestack(L, level); |
210 | status = callclosemth(L, uplevel(uv), status); | 211 | status = callclosemth(L, uplevel(uv), status); |