aboutsummaryrefslogtreecommitdiff
path: root/ltm.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2000-03-27 17:08:02 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2000-03-27 17:08:02 -0300
commit102a1be6159b34190813bfd7a7ed6c04633c6200 (patch)
treeb03054b4832fefea3c9f114d3b367f2fa0dbac88 /ltm.c
parent4c031966976a0ae5d24b709fe94e90dc3fbac9ef (diff)
downloadlua-102a1be6159b34190813bfd7a7ed6c04633c6200.tar.gz
lua-102a1be6159b34190813bfd7a7ed6c04633c6200.tar.bz2
lua-102a1be6159b34190813bfd7a7ed6c04633c6200.zip
no more support for gc TM for tables
Diffstat (limited to 'ltm.c')
-rw-r--r--ltm.c28
1 files changed, 13 insertions, 15 deletions
diff --git a/ltm.c b/ltm.c
index 30be02ad..d9ec4476 100644
--- a/ltm.c
+++ b/ltm.c
@@ -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
28static int luaI_checkevent (lua_State *L, const char *name) { 28static 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 */
43static const char luaT_validevents[NUM_TAGS][IM_N] = { 45static 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
53static int luaT_validevent (int t, int e) { /* ORDER LUA_T */ 55static 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
127const TObject *luaT_gettagmethod (lua_State *L, int t, const char *event) { 125const 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) {
138void luaT_settagmethod (lua_State *L, int t, const char *event, TObject *func) { 136void 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",