diff options
Diffstat (limited to 'ltm.c')
-rw-r--r-- | ltm.c | 27 |
1 files changed, 16 insertions, 11 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltm.c,v 1.2 1997/09/26 15:02:26 roberto Exp roberto $ | 2 | ** $Id: ltm.c,v 1.3 1997/10/16 20:07:40 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 | */ |
@@ -93,8 +93,8 @@ static char validevents[NUM_TAGS][IM_N] = { /* ORDER LUA_T, ORDER IM */ | |||
93 | {1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1}, /* LUA_T_NUMBER */ | 93 | {1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1}, /* LUA_T_NUMBER */ |
94 | {1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}, /* LUA_T_STRING */ | 94 | {1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}, /* LUA_T_STRING */ |
95 | {0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, /* LUA_T_ARRAY */ | 95 | {0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, /* LUA_T_ARRAY */ |
96 | {1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0}, /* LUA_T_FUNCTION */ | 96 | {1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0}, /* LUA_T_PROTO */ |
97 | {1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0}, /* LUA_T_CFUNCTION */ | 97 | {1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0}, /* LUA_T_CPROTO */ |
98 | {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1} /* LUA_T_NIL */ | 98 | {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1} /* LUA_T_NIL */ |
99 | }; | 99 | }; |
100 | 100 | ||
@@ -145,14 +145,19 @@ void luaT_realtag (int tag) | |||
145 | 145 | ||
146 | int luaT_efectivetag (TObject *o) | 146 | int luaT_efectivetag (TObject *o) |
147 | { | 147 | { |
148 | lua_Type t = ttype(o); | 148 | int t; |
149 | if (t == LUA_T_USERDATA) { | 149 | switch (t = ttype(o)) { |
150 | int tag = o->value.ts->u.d.tag; | 150 | case LUA_T_USERDATA: { |
151 | return (tag >= 0) ? LUA_T_USERDATA : tag; | 151 | int tag = o->value.ts->u.d.tag; |
152 | return (tag >= 0) ? LUA_T_USERDATA : tag; | ||
153 | } | ||
154 | case LUA_T_ARRAY: | ||
155 | return o->value.a->htag; | ||
156 | case LUA_T_FUNCTION: case LUA_T_MARK: | ||
157 | return o->value.cl->consts[0].ttype; | ||
158 | default: | ||
159 | return t; | ||
152 | } | 160 | } |
153 | else if (t == LUA_T_ARRAY) | ||
154 | return o->value.a->htag; | ||
155 | else return t; | ||
156 | } | 161 | } |
157 | 162 | ||
158 | 163 | ||
@@ -163,7 +168,7 @@ TObject *luaT_gettagmethod (int t, char *event) | |||
163 | if (validevent(t, e)) | 168 | if (validevent(t, e)) |
164 | return luaT_getim(t,e); | 169 | return luaT_getim(t,e); |
165 | else | 170 | else |
166 | return luaT_getim(LUA_T_CMARK, IM_GETTABLE); /* always nil */ | 171 | return luaT_getim(LUA_T_NUMBER, IM_ADD); /* always nil */ |
167 | } | 172 | } |
168 | 173 | ||
169 | 174 | ||