diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2005-02-18 10:40:02 -0200 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2005-02-18 10:40:02 -0200 |
| commit | 7d45a5f48ff32a4e09a1734de23823943d6a6b28 (patch) | |
| tree | de7bef1faf37d9b639928e5269e89d7112b5b6fa /lgc.c | |
| parent | 73d764024451c24bc43b8e5102fe90974a86b7f4 (diff) | |
| download | lua-7d45a5f48ff32a4e09a1734de23823943d6a6b28.tar.gz lua-7d45a5f48ff32a4e09a1734de23823943d6a6b28.tar.bz2 lua-7d45a5f48ff32a4e09a1734de23823943d6a6b28.zip | |
C functions and userdata also have environments
Diffstat (limited to 'lgc.c')
| -rw-r--r-- | lgc.c | 5 |
1 files changed, 3 insertions, 2 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lgc.c,v 2.24 2005/02/11 20:03:35 roberto Exp roberto $ | 2 | ** $Id: lgc.c,v 2.25 2005/02/14 13:19:50 roberto Exp roberto $ |
| 3 | ** Garbage Collector | 3 | ** Garbage Collector |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -79,6 +79,7 @@ static void reallymarkobject (global_State *g, GCObject *o) { | |||
| 79 | Table *mt = gco2u(o)->metatable; | 79 | Table *mt = gco2u(o)->metatable; |
| 80 | gray2black(o); /* udata are never gray */ | 80 | gray2black(o); /* udata are never gray */ |
| 81 | if (mt) markobject(g, mt); | 81 | if (mt) markobject(g, mt); |
| 82 | markobject(g, gco2u(o)->env); | ||
| 82 | return; | 83 | return; |
| 83 | } | 84 | } |
| 84 | case LUA_TUPVAL: { | 85 | case LUA_TUPVAL: { |
| @@ -223,6 +224,7 @@ static void traverseproto (global_State *g, Proto *f) { | |||
| 223 | 224 | ||
| 224 | 225 | ||
| 225 | static void traverseclosure (global_State *g, Closure *cl) { | 226 | static void traverseclosure (global_State *g, Closure *cl) { |
| 227 | markobject(g, cl->c.env); | ||
| 226 | if (cl->c.isC) { | 228 | if (cl->c.isC) { |
| 227 | int i; | 229 | int i; |
| 228 | for (i=0; i<cl->c.nupvalues; i++) /* mark its upvalues */ | 230 | for (i=0; i<cl->c.nupvalues; i++) /* mark its upvalues */ |
| @@ -231,7 +233,6 @@ static void traverseclosure (global_State *g, Closure *cl) { | |||
| 231 | else { | 233 | else { |
| 232 | int i; | 234 | int i; |
| 233 | lua_assert(cl->l.nupvalues == cl->l.p->nups); | 235 | lua_assert(cl->l.nupvalues == cl->l.p->nups); |
| 234 | markobject(g, hvalue(&cl->l.g)); | ||
| 235 | markobject(g, cl->l.p); | 236 | markobject(g, cl->l.p); |
| 236 | for (i=0; i<cl->l.nupvalues; i++) /* mark its upvalues */ | 237 | for (i=0; i<cl->l.nupvalues; i++) /* mark its upvalues */ |
| 237 | markobject(g, cl->l.upvals[i]); | 238 | markobject(g, cl->l.upvals[i]); |
