diff options
Diffstat (limited to 'lfunc.c')
| -rw-r--r-- | lfunc.c | 5 |
1 files changed, 4 insertions, 1 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lfunc.c,v 1.56 2002/05/02 13:06:20 roberto Exp roberto $ | 2 | ** $Id: lfunc.c,v 1.57 2002/06/20 20:41:46 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 | */ |
| @@ -54,6 +54,7 @@ UpVal *luaF_findupval (lua_State *L, StkId level) { | |||
| 54 | pp = &p->next; | 54 | pp = &p->next; |
| 55 | } | 55 | } |
| 56 | p = luaM_new(L, UpVal); /* not found: create a new one */ | 56 | p = luaM_new(L, UpVal); /* not found: create a new one */ |
| 57 | p->marked = 1; /* open upvalues should not be collected */ | ||
| 57 | p->v = level; /* current value lives in the stack */ | 58 | p->v = level; /* current value lives in the stack */ |
| 58 | p->next = *pp; /* chain it in the proper position */ | 59 | p->next = *pp; /* chain it in the proper position */ |
| 59 | *pp = p; | 60 | *pp = p; |
| @@ -64,6 +65,8 @@ UpVal *luaF_findupval (lua_State *L, StkId level) { | |||
| 64 | void luaF_close (lua_State *L, StkId level) { | 65 | void luaF_close (lua_State *L, StkId level) { |
| 65 | UpVal *p; | 66 | UpVal *p; |
| 66 | while ((p = L->openupval) != NULL && p->v >= level) { | 67 | while ((p = L->openupval) != NULL && p->v >= level) { |
| 68 | lua_assert(p->marked); | ||
| 69 | p->marked = 0; | ||
| 67 | setobj(&p->value, p->v); /* save current value */ | 70 | setobj(&p->value, p->v); /* save current value */ |
| 68 | p->v = &p->value; /* now current value lives here */ | 71 | p->v = &p->value; /* now current value lives here */ |
| 69 | L->openupval = p->next; /* remove from `open' list */ | 72 | L->openupval = p->next; /* remove from `open' list */ |
