diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2003-03-18 09:50:04 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2003-03-18 09:50:04 -0300 |
commit | ab9e062928f7b9201fd5366a34a4fc855d13bc46 (patch) | |
tree | 37224175e0dd89badfccc6d745bdb5c850fd34c4 /lgc.c | |
parent | 81cdbabf095e23bf9fb5cef842967acb499b7bcc (diff) | |
download | lua-ab9e062928f7b9201fd5366a34a4fc855d13bc46.tar.gz lua-ab9e062928f7b9201fd5366a34a4fc855d13bc46.tar.bz2 lua-ab9e062928f7b9201fd5366a34a4fc855d13bc46.zip |
name changes to avoid name collision between macros and variables
Diffstat (limited to 'lgc.c')
-rw-r--r-- | lgc.c | 46 |
1 files changed, 23 insertions, 23 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lgc.c,v 1.168 2003/02/10 17:32:50 roberto Exp roberto $ | 2 | ** $Id: lgc.c,v 1.169 2003/02/11 10:46:24 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 | */ |
@@ -27,7 +27,7 @@ typedef struct GCState { | |||
27 | GCObject *wk; /* list of traversed key-weak tables (to be cleared) */ | 27 | GCObject *wk; /* list of traversed key-weak tables (to be cleared) */ |
28 | GCObject *wv; /* list of traversed value-weak tables */ | 28 | GCObject *wv; /* list of traversed value-weak tables */ |
29 | GCObject *wkv; /* list of traversed key-value weak tables */ | 29 | GCObject *wkv; /* list of traversed key-value weak tables */ |
30 | global_State *G; | 30 | global_State *g; |
31 | } GCState; | 31 | } GCState; |
32 | 32 | ||
33 | 33 | ||
@@ -102,7 +102,7 @@ static void reallymarkobject (GCState *st, GCObject *o) { | |||
102 | 102 | ||
103 | static void marktmu (GCState *st) { | 103 | static void marktmu (GCState *st) { |
104 | GCObject *u; | 104 | GCObject *u; |
105 | for (u = st->G->tmudata; u; u = u->gch.next) { | 105 | for (u = st->g->tmudata; u; u = u->gch.next) { |
106 | unmark(u); /* may be marked, if left from previous GC */ | 106 | unmark(u); /* may be marked, if left from previous GC */ |
107 | reallymarkobject(st, u); | 107 | reallymarkobject(st, u); |
108 | } | 108 | } |
@@ -138,9 +138,9 @@ void luaC_separateudata (lua_State *L) { | |||
138 | 138 | ||
139 | 139 | ||
140 | static void removekey (Node *n) { | 140 | static void removekey (Node *n) { |
141 | setnilvalue(val(n)); /* remove corresponding value ... */ | 141 | setnilvalue(gval(n)); /* remove corresponding value ... */ |
142 | if (iscollectable(key(n))) | 142 | if (iscollectable(gkey(n))) |
143 | setttype(key(n), LUA_TNONE); /* dead key; remove it */ | 143 | setttype(gkey(n), LUA_TNONE); /* dead key; remove it */ |
144 | } | 144 | } |
145 | 145 | ||
146 | 146 | ||
@@ -150,8 +150,8 @@ static void traversetable (GCState *st, Table *h) { | |||
150 | int weakvalue = 0; | 150 | int weakvalue = 0; |
151 | const TObject *mode; | 151 | const TObject *mode; |
152 | markvalue(st, h->metatable); | 152 | markvalue(st, h->metatable); |
153 | lua_assert(h->lsizenode || h->node == st->G->dummynode); | 153 | lua_assert(h->lsizenode || h->node == st->g->dummynode); |
154 | mode = gfasttm(st->G, h->metatable, TM_MODE); | 154 | mode = gfasttm(st->g, h->metatable, TM_MODE); |
155 | if (mode && ttisstring(mode)) { /* is there a weak mode? */ | 155 | if (mode && ttisstring(mode)) { /* is there a weak mode? */ |
156 | weakkey = (strchr(svalue(mode), 'k') != NULL); | 156 | weakkey = (strchr(svalue(mode), 'k') != NULL); |
157 | weakvalue = (strchr(svalue(mode), 'v') != NULL); | 157 | weakvalue = (strchr(svalue(mode), 'v') != NULL); |
@@ -167,17 +167,17 @@ static void traversetable (GCState *st, Table *h) { | |||
167 | } | 167 | } |
168 | } | 168 | } |
169 | if (!weakvalue) { | 169 | if (!weakvalue) { |
170 | i = sizearray(h); | 170 | i = h->sizearray; |
171 | while (i--) | 171 | while (i--) |
172 | markobject(st, &h->array[i]); | 172 | markobject(st, &h->array[i]); |
173 | } | 173 | } |
174 | i = sizenode(h); | 174 | i = sizenode(h); |
175 | while (i--) { | 175 | while (i--) { |
176 | Node *n = node(h, i); | 176 | Node *n = gnode(h, i); |
177 | if (!ttisnil(val(n))) { | 177 | if (!ttisnil(gval(n))) { |
178 | lua_assert(!ttisnil(key(n))); | 178 | lua_assert(!ttisnil(gkey(n))); |
179 | condmarkobject(st, key(n), !weakkey); | 179 | condmarkobject(st, gkey(n), !weakkey); |
180 | condmarkobject(st, val(n), !weakvalue); | 180 | condmarkobject(st, gval(n), !weakvalue); |
181 | } | 181 | } |
182 | } | 182 | } |
183 | } | 183 | } |
@@ -303,8 +303,8 @@ static void cleartablekeys (GCObject *l) { | |||
303 | int i = sizenode(h); | 303 | int i = sizenode(h); |
304 | lua_assert(h->marked & KEYWEAK); | 304 | lua_assert(h->marked & KEYWEAK); |
305 | while (i--) { | 305 | while (i--) { |
306 | Node *n = node(h, i); | 306 | Node *n = gnode(h, i); |
307 | if (!valismarked(key(n))) /* key was collected? */ | 307 | if (!valismarked(gkey(n))) /* key was collected? */ |
308 | removekey(n); /* remove entry from table */ | 308 | removekey(n); /* remove entry from table */ |
309 | } | 309 | } |
310 | l = h->gclist; | 310 | l = h->gclist; |
@@ -318,7 +318,7 @@ static void cleartablekeys (GCObject *l) { | |||
318 | static void cleartablevalues (GCObject *l) { | 318 | static void cleartablevalues (GCObject *l) { |
319 | while (l) { | 319 | while (l) { |
320 | Table *h = gcotoh(l); | 320 | Table *h = gcotoh(l); |
321 | int i = sizearray(h); | 321 | int i = h->sizearray; |
322 | lua_assert(h->marked & VALUEWEAK); | 322 | lua_assert(h->marked & VALUEWEAK); |
323 | while (i--) { | 323 | while (i--) { |
324 | TObject *o = &h->array[i]; | 324 | TObject *o = &h->array[i]; |
@@ -327,8 +327,8 @@ static void cleartablevalues (GCObject *l) { | |||
327 | } | 327 | } |
328 | i = sizenode(h); | 328 | i = sizenode(h); |
329 | while (i--) { | 329 | while (i--) { |
330 | Node *n = node(h, i); | 330 | Node *n = gnode(h, i); |
331 | if (!valismarked(val(n))) /* value was collected? */ | 331 | if (!valismarked(gval(n))) /* value was collected? */ |
332 | removekey(n); /* remove entry from table */ | 332 | removekey(n); /* remove entry from table */ |
333 | } | 333 | } |
334 | l = h->gclist; | 334 | l = h->gclist; |
@@ -441,11 +441,11 @@ void luaC_sweep (lua_State *L, int all) { | |||
441 | 441 | ||
442 | /* mark root set */ | 442 | /* mark root set */ |
443 | static void markroot (GCState *st, lua_State *L) { | 443 | static void markroot (GCState *st, lua_State *L) { |
444 | global_State *G = st->G; | 444 | global_State *g = st->g; |
445 | markobject(st, defaultmeta(L)); | 445 | markobject(st, defaultmeta(L)); |
446 | markobject(st, registry(L)); | 446 | markobject(st, registry(L)); |
447 | traversestack(st, G->mainthread); | 447 | traversestack(st, g->mainthread); |
448 | if (L != G->mainthread) /* another thread is running? */ | 448 | if (L != g->mainthread) /* another thread is running? */ |
449 | markvalue(st, L); /* cannot collect it */ | 449 | markvalue(st, L); /* cannot collect it */ |
450 | } | 450 | } |
451 | 451 | ||
@@ -453,7 +453,7 @@ static void markroot (GCState *st, lua_State *L) { | |||
453 | static void mark (lua_State *L) { | 453 | static void mark (lua_State *L) { |
454 | GCState st; | 454 | GCState st; |
455 | GCObject *wkv; | 455 | GCObject *wkv; |
456 | st.G = G(L); | 456 | st.g = G(L); |
457 | st.tmark = NULL; | 457 | st.tmark = NULL; |
458 | st.wkv = st.wk = st.wv = NULL; | 458 | st.wkv = st.wk = st.wv = NULL; |
459 | markroot(&st, L); | 459 | markroot(&st, L); |