diff options
Diffstat (limited to 'lfunc.c')
-rw-r--r-- | lfunc.c | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lfunc.c,v 2.49 2017/05/24 18:54:54 roberto Exp roberto $ | 2 | ** $Id: lfunc.c,v 2.50 2017/06/27 11:35:31 roberto Exp roberto $ |
3 | ** Auxiliary functions to manipulate prototypes and closures | 3 | ** Auxiliary functions to manipulate prototypes and closures |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -61,9 +61,8 @@ UpVal *luaF_findupval (lua_State *L, StkId level) { | |||
61 | UpVal *p; | 61 | UpVal *p; |
62 | UpVal *uv; | 62 | UpVal *uv; |
63 | lua_assert(isintwups(L) || L->openupval == NULL); | 63 | lua_assert(isintwups(L) || L->openupval == NULL); |
64 | while ((p = *pp) != NULL && p->v >= level) { | 64 | while ((p = *pp) != NULL && uplevel(p) >= level) { |
65 | lua_assert(upisopen(p)); | 65 | if (uplevel(p) == level && !isdead(G(L), p)) /* corresponding upvalue? */ |
66 | if (p->v == level && !isdead(G(L), p)) /* corresponding upvalue? */ | ||
67 | return p; /* return it */ | 66 | return p; /* return it */ |
68 | pp = &p->u.open.next; | 67 | pp = &p->u.open.next; |
69 | } | 68 | } |
@@ -75,7 +74,7 @@ UpVal *luaF_findupval (lua_State *L, StkId level) { | |||
75 | if (p) | 74 | if (p) |
76 | p->u.open.previous = &uv->u.open.next; | 75 | p->u.open.previous = &uv->u.open.next; |
77 | *pp = uv; | 76 | *pp = uv; |
78 | uv->v = level; /* current value lives in the stack */ | 77 | uv->v = s2v(level); /* current value lives in the stack */ |
79 | if (!isintwups(L)) { /* thread not in list of threads with upvalues? */ | 78 | if (!isintwups(L)) { /* thread not in list of threads with upvalues? */ |
80 | L->twups = G(L)->twups; /* link it to the list */ | 79 | L->twups = G(L)->twups; /* link it to the list */ |
81 | G(L)->twups = L; | 80 | G(L)->twups = L; |
@@ -94,7 +93,8 @@ void luaF_unlinkupval (UpVal *uv) { | |||
94 | 93 | ||
95 | void luaF_close (lua_State *L, StkId level) { | 94 | void luaF_close (lua_State *L, StkId level) { |
96 | UpVal *uv; | 95 | UpVal *uv; |
97 | while (L->openupval != NULL && (uv = L->openupval)->v >= level) { | 96 | while (L->openupval != NULL && |
97 | (uv = L->openupval, uplevel(uv) >= level)) { | ||
98 | TValue *slot = &uv->u.value; /* new position for value */ | 98 | TValue *slot = &uv->u.value; /* new position for value */ |
99 | luaF_unlinkupval(uv); | 99 | luaF_unlinkupval(uv); |
100 | setobj(L, slot, uv->v); /* move value to upvalue slot */ | 100 | setobj(L, slot, uv->v); /* move value to upvalue slot */ |