diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1997-11-03 18:45:23 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1997-11-03 18:45:23 -0200 |
commit | 7135803cc87fafe80494bdc094613515487410b9 (patch) | |
tree | 439f9c6f1173707f7e37520c550e48edb5cafab8 | |
parent | b7567b667367180b75fbb60f7a73b75e5e89889e (diff) | |
download | lua-7135803cc87fafe80494bdc094613515487410b9.tar.gz lua-7135803cc87fafe80494bdc094613515487410b9.tar.bz2 lua-7135803cc87fafe80494bdc094613515487410b9.zip |
"global" version of a nil object.
-rw-r--r-- | lgc.c | 15 | ||||
-rw-r--r-- | lobject.c | 6 | ||||
-rw-r--r-- | lobject.h | 4 | ||||
-rw-r--r-- | ltm.c | 4 |
4 files changed, 13 insertions, 16 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lgc.c,v 1.5 1997/10/23 16:26:37 roberto Exp roberto $ | 2 | ** $Id: lgc.c,v 1.6 1997/10/24 17:17: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 | */ |
@@ -66,9 +66,8 @@ void lua_unref (int ref) | |||
66 | 66 | ||
67 | TObject* luaC_getref (int ref) | 67 | TObject* luaC_getref (int ref) |
68 | { | 68 | { |
69 | static TObject nul = {LUA_T_NIL, {0}}; | ||
70 | if (ref == -1) | 69 | if (ref == -1) |
71 | return &nul; | 70 | return &luaO_nilobject; |
72 | if (ref >= 0 && ref < refSize && | 71 | if (ref >= 0 && ref < refSize && |
73 | (refArray[ref].status == LOCK || refArray[ref].status == HOLD)) | 72 | (refArray[ref].status == LOCK || refArray[ref].status == HOLD)) |
74 | return &refArray[ref].o; | 73 | return &refArray[ref].o; |
@@ -240,14 +239,6 @@ static int markobject (TObject *o) | |||
240 | } | 239 | } |
241 | 240 | ||
242 | 241 | ||
243 | static void call_nilIM (void) | ||
244 | { /* signals end of garbage collection */ | ||
245 | TObject t; | ||
246 | ttype(&t) = LUA_T_NIL; | ||
247 | luaD_gcIM(&t); /* end of list */ | ||
248 | } | ||
249 | |||
250 | |||
251 | 242 | ||
252 | #define GARBAGE_BLOCK 150 | 243 | #define GARBAGE_BLOCK 150 |
253 | 244 | ||
@@ -279,7 +270,7 @@ long lua_collectgarbage (long limit) | |||
279 | luaC_threshold *= 4; /* to avoid GC during GC */ | 270 | luaC_threshold *= 4; /* to avoid GC during GC */ |
280 | hashcallIM(freetable); /* GC tag methods for tables */ | 271 | hashcallIM(freetable); /* GC tag methods for tables */ |
281 | strcallIM(freestr); /* GC tag methods for userdata */ | 272 | strcallIM(freestr); /* GC tag methods for userdata */ |
282 | call_nilIM(); /* GC tag method for nil (signal end of GC) */ | 273 | luaD_gcIM(&luaO_nilobject); /* GC tag method for nil (signal end of GC) */ |
283 | luaH_free(freetable); | 274 | luaH_free(freetable); |
284 | luaS_free(freestr); | 275 | luaS_free(freestr); |
285 | luaF_freeproto(freefunc); | 276 | luaF_freeproto(freefunc); |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lobject.c,v 1.4 1997/10/23 16:26:37 roberto Exp roberto $ | 2 | ** $Id: lobject.c,v 1.5 1997/10/24 17:17:24 roberto Exp roberto $ |
3 | ** Some generic functions over Lua objects | 3 | ** Some generic functions over Lua objects |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -17,6 +17,10 @@ char *luaO_typenames[] = { /* ORDER LUA_T */ | |||
17 | }; | 17 | }; |
18 | 18 | ||
19 | 19 | ||
20 | TObject luaO_nilobject = {LUA_T_NIL, {NULL}}; | ||
21 | |||
22 | |||
23 | |||
20 | unsigned long luaO_nblocks = 0; | 24 | unsigned long luaO_nblocks = 0; |
21 | 25 | ||
22 | 26 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lobject.h,v 1.6 1997/10/23 16:26:37 roberto Exp roberto $ | 2 | ** $Id: lobject.h,v 1.7 1997/10/24 17:17:24 roberto Exp roberto $ |
3 | ** Type definitions for Lua objects | 3 | ** Type definitions for Lua objects |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -166,6 +166,8 @@ extern unsigned long luaO_nblocks; | |||
166 | 166 | ||
167 | extern char *luaO_typenames[]; | 167 | extern char *luaO_typenames[]; |
168 | 168 | ||
169 | extern TObject luaO_nilobject; | ||
170 | |||
169 | int luaO_equalObj (TObject *t1, TObject *t2); | 171 | int luaO_equalObj (TObject *t1, TObject *t2); |
170 | int luaO_redimension (int oldsize); | 172 | int luaO_redimension (int oldsize); |
171 | int luaO_findstring (char *name, char *list[]); | 173 | int luaO_findstring (char *name, char *list[]); |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltm.c,v 1.3 1997/10/16 20:07:40 roberto Exp roberto $ | 2 | ** $Id: ltm.c,v 1.4 1997/10/24 17:17:24 roberto Exp roberto $ |
3 | ** Tag methods | 3 | ** Tag methods |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -168,7 +168,7 @@ TObject *luaT_gettagmethod (int t, char *event) | |||
168 | if (validevent(t, e)) | 168 | if (validevent(t, e)) |
169 | return luaT_getim(t,e); | 169 | return luaT_getim(t,e); |
170 | else | 170 | else |
171 | return luaT_getim(LUA_T_NUMBER, IM_ADD); /* always nil */ | 171 | return &luaO_nilobject; |
172 | } | 172 | } |
173 | 173 | ||
174 | 174 | ||