diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-03-27 17:08:02 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-03-27 17:08:02 -0300 |
commit | 102a1be6159b34190813bfd7a7ed6c04633c6200 (patch) | |
tree | b03054b4832fefea3c9f114d3b367f2fa0dbac88 | |
parent | 4c031966976a0ae5d24b709fe94e90dc3fbac9ef (diff) | |
download | lua-102a1be6159b34190813bfd7a7ed6c04633c6200.tar.gz lua-102a1be6159b34190813bfd7a7ed6c04633c6200.tar.bz2 lua-102a1be6159b34190813bfd7a7ed6c04633c6200.zip |
no more support for gc TM for tables
-rw-r--r-- | lbuiltin.c | 6 | ||||
-rw-r--r-- | lgc.c | 21 | ||||
-rw-r--r-- | ltm.c | 28 |
3 files changed, 16 insertions, 39 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lbuiltin.c,v 1.96 2000/03/10 18:37:44 roberto Exp roberto $ | 2 | ** $Id: lbuiltin.c,v 1.97 2000/03/24 17:26:08 roberto Exp roberto $ |
3 | ** Built-in functions | 3 | ** Built-in functions |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -239,10 +239,8 @@ void luaB_settagmethod (lua_State *L) { | |||
239 | lua_Object nf = luaL_nonnullarg(L, 3); | 239 | lua_Object nf = luaL_nonnullarg(L, 3); |
240 | luaL_arg_check(L, lua_isnil(L, nf) || lua_isfunction(L, nf), 3, | 240 | luaL_arg_check(L, lua_isnil(L, nf) || lua_isfunction(L, nf), 3, |
241 | "function or nil expected"); | 241 | "function or nil expected"); |
242 | #ifndef LUA_COMPAT_GC | ||
243 | if (strcmp(event, "gc") == 0 && tag != TAG_NIL) | 242 | if (strcmp(event, "gc") == 0 && tag != TAG_NIL) |
244 | lua_error(L, "cannot set this `gc' tag method from Lua"); | 243 | lua_error(L, "deprecated use: cannot set the `gc' tag method from Lua"); |
245 | #endif | ||
246 | lua_pushobject(L, nf); | 244 | lua_pushobject(L, nf); |
247 | lua_pushobject(L, lua_settagmethod(L, tag, event)); | 245 | lua_pushobject(L, lua_settagmethod(L, tag, event)); |
248 | } | 246 | } |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lgc.c,v 1.41 2000/01/28 16:53:00 roberto Exp roberto $ | 2 | ** $Id: lgc.c,v 1.42 2000/03/10 18:37:44 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 | */ |
@@ -216,24 +216,6 @@ static void collectstring (lua_State *L, int limit) { | |||
216 | } | 216 | } |
217 | 217 | ||
218 | 218 | ||
219 | #ifdef LUA_COMPAT_GC | ||
220 | static void tableTM (lua_State *L) { | ||
221 | Hash *p; | ||
222 | TObject o; | ||
223 | ttype(&o) = TAG_ARRAY; | ||
224 | for (p = L->roottable; p; p = p->next) { | ||
225 | if (!p->marked) { | ||
226 | avalue(&o) = p; | ||
227 | luaD_gcIM(L, &o); | ||
228 | } | ||
229 | } | ||
230 | } | ||
231 | #else | ||
232 | #define tableTM(L) /* do nothing */ | ||
233 | #endif | ||
234 | |||
235 | |||
236 | |||
237 | static void markall (lua_State *L) { | 219 | static void markall (lua_State *L) { |
238 | travstack(L); /* mark stack objects */ | 220 | travstack(L); /* mark stack objects */ |
239 | travglobal(L); /* mark global variable values and names */ | 221 | travglobal(L); /* mark global variable values and names */ |
@@ -246,7 +228,6 @@ void luaC_collect (lua_State *L, int all) { | |||
246 | int oldah = L->allowhooks; | 228 | int oldah = L->allowhooks; |
247 | L->allowhooks = 0; /* stop debug hooks during GC */ | 229 | L->allowhooks = 0; /* stop debug hooks during GC */ |
248 | L->GCthreshold *= 4; /* to avoid GC during GC */ | 230 | L->GCthreshold *= 4; /* to avoid GC during GC */ |
249 | tableTM(L); /* call TM for tables (if LUA_COMPAT_GC) */ | ||
250 | collecttable(L); | 231 | collecttable(L); |
251 | collectstring(L, all?MAX_INT:1); | 232 | collectstring(L, all?MAX_INT:1); |
252 | collectproto(L); | 233 | collectproto(L); |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltm.c,v 1.34 2000/03/10 18:37:44 roberto Exp roberto $ | 2 | ** $Id: ltm.c,v 1.35 2000/03/20 19:14:54 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 | */ |
@@ -25,10 +25,12 @@ const char *const luaT_eventname[] = { /* ORDER IM */ | |||
25 | }; | 25 | }; |
26 | 26 | ||
27 | 27 | ||
28 | static int luaI_checkevent (lua_State *L, const char *name) { | 28 | static int luaI_checkevent (lua_State *L, const char *name, int t) { |
29 | int e = luaL_findstring(name, luaT_eventname); | 29 | int e = luaL_findstring(name, luaT_eventname); |
30 | if (e >= IM_N) | 30 | if (e >= IM_N) |
31 | luaL_verror(L, "event `%.50s' is deprecated", name); | 31 | luaL_verror(L, "event `%.50s' is deprecated", name); |
32 | if (e == IM_GC && t == TAG_ARRAY) | ||
33 | luaL_verror(L, "event `gc' for tables is deprecated"); | ||
32 | if (e < 0) | 34 | if (e < 0) |
33 | luaL_verror(L, "`%.50s' is not a valid event name", name); | 35 | luaL_verror(L, "`%.50s' is not a valid event name", name); |
34 | return e; | 36 | return e; |
@@ -41,20 +43,16 @@ static int luaI_checkevent (lua_State *L, const char *name) { | |||
41 | */ | 43 | */ |
42 | /* ORDER LUA_T, ORDER IM */ | 44 | /* ORDER LUA_T, ORDER IM */ |
43 | static const char luaT_validevents[NUM_TAGS][IM_N] = { | 45 | static const char luaT_validevents[NUM_TAGS][IM_N] = { |
44 | {1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1}, /* TAG_USERDATA */ | 46 | {1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1}, /* TAG_USERDATA */ |
45 | {1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1}, /* TAG_NUMBER */ | 47 | {1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1}, /* TAG_NUMBER */ |
46 | {1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}, /* TAG_STRING */ | 48 | {1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}, /* TAG_STRING */ |
47 | {0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1}, /* TAG_ARRAY */ | 49 | {0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1}, /* TAG_ARRAY */ |
48 | {1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0}, /* TAG_LPROTO */ | 50 | {1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0}, /* TAG_LPROTO */ |
49 | {1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0}, /* TAG_CPROTO */ | 51 | {1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0}, /* TAG_CPROTO */ |
50 | {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1} /* TAG_NIL */ | 52 | {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1} /* TAG_NIL */ |
51 | }; | 53 | }; |
52 | 54 | ||
53 | static int luaT_validevent (int t, int e) { /* ORDER LUA_T */ | 55 | static int luaT_validevent (int t, int e) { /* ORDER LUA_T */ |
54 | #ifdef LUA_COMPAT_GC | ||
55 | if (t == TAG_ARRAY && e == IM_GC) | ||
56 | return 1; /* old versions allowed gc tag method for tables */ | ||
57 | #endif | ||
58 | return (t > TAG_NIL) ? 1 : luaT_validevents[t][e]; | 56 | return (t > TAG_NIL) ? 1 : luaT_validevents[t][e]; |
59 | } | 57 | } |
60 | 58 | ||
@@ -126,7 +124,7 @@ int luaT_effectivetag (lua_State *L, const TObject *o) { | |||
126 | 124 | ||
127 | const TObject *luaT_gettagmethod (lua_State *L, int t, const char *event) { | 125 | const TObject *luaT_gettagmethod (lua_State *L, int t, const char *event) { |
128 | int e; | 126 | int e; |
129 | e = luaI_checkevent(L, event); | 127 | e = luaI_checkevent(L, event, t); |
130 | checktag(L, t); | 128 | checktag(L, t); |
131 | if (luaT_validevent(t, e)) | 129 | if (luaT_validevent(t, e)) |
132 | return luaT_getim(L, t,e); | 130 | return luaT_getim(L, t,e); |
@@ -138,7 +136,7 @@ const TObject *luaT_gettagmethod (lua_State *L, int t, const char *event) { | |||
138 | void luaT_settagmethod (lua_State *L, int t, const char *event, TObject *func) { | 136 | void luaT_settagmethod (lua_State *L, int t, const char *event, TObject *func) { |
139 | TObject temp; | 137 | TObject temp; |
140 | int e; | 138 | int e; |
141 | e = luaI_checkevent(L, event); | 139 | e = luaI_checkevent(L, event, t); |
142 | checktag(L, t); | 140 | checktag(L, t); |
143 | if (!luaT_validevent(t, e)) | 141 | if (!luaT_validevent(t, e)) |
144 | luaL_verror(L, "cannot change `%.20s' tag method for type `%.20s'%.20s", | 142 | luaL_verror(L, "cannot change `%.20s' tag method for type `%.20s'%.20s", |