aboutsummaryrefslogtreecommitdiff
path: root/lfunc.c
diff options
context:
space:
mode:
Diffstat (limited to 'lfunc.c')
-rw-r--r--lfunc.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/lfunc.c b/lfunc.c
index f7edf56b..6f2f897f 100644
--- a/lfunc.c
+++ b/lfunc.c
@@ -83,21 +83,20 @@ static UpVal *newupval (lua_State *L, int tbc, StkId level, UpVal **prev) {
83 83
84/* 84/*
85** Find and reuse, or create if it does not exist, an upvalue 85** Find and reuse, or create if it does not exist, an upvalue
86** at the given level and set it to the given slot. 86** at the given level.
87*/ 87*/
88void luaF_setupval (lua_State *L, StkId level, UpVal **slot) { 88UpVal *luaF_findupval (lua_State *L, StkId level) {
89 UpVal **pp = &L->openupval; 89 UpVal **pp = &L->openupval;
90 UpVal *p; 90 UpVal *p;
91 lua_assert(isintwups(L) || L->openupval == NULL); 91 lua_assert(isintwups(L) || L->openupval == NULL);
92 while ((p = *pp) != NULL && uplevel(p) >= level) { /* search for it */ 92 while ((p = *pp) != NULL && uplevel(p) >= level) { /* search for it */
93 *slot = p; 93 lua_assert(!isdead(G(L), p));
94 if (uplevel(p) == level && !isdead(G(L), p)) /* corresponding upvalue? */ 94 if (uplevel(p) == level) /* corresponding upvalue? */
95 return; /* found it */ 95 return p; /* return it */
96 pp = &p->u.open.next; 96 pp = &p->u.open.next;
97 } 97 }
98 /* not found: create a new upvalue after 'pp' (which is 98 /* not found: create a new upvalue after 'pp' */
99 anchored in 'slot', in case of an emergency collection) */ 99 return newupval(L, 0, level, pp);
100 *slot = newupval(L, 0, level, pp);
101} 100}
102 101
103 102