From e78cf96c971234ea25e35a9672ef00ea389d843f Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Fri, 24 Oct 1997 15:17:24 -0200 Subject: first version of Cclosures. --- ltm.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'ltm.c') diff --git a/ltm.c b/ltm.c index 913c4b7d..980fd4d6 100644 --- a/ltm.c +++ b/ltm.c @@ -1,5 +1,5 @@ /* -** $Id: ltm.c,v 1.2 1997/09/26 15:02:26 roberto Exp roberto $ +** $Id: ltm.c,v 1.3 1997/10/16 20:07:40 roberto Exp roberto $ ** Tag methods ** See Copyright Notice in lua.h */ @@ -93,8 +93,8 @@ static char validevents[NUM_TAGS][IM_N] = { /* ORDER LUA_T, ORDER IM */ {1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1}, /* LUA_T_NUMBER */ {1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}, /* LUA_T_STRING */ {0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, /* LUA_T_ARRAY */ -{1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0}, /* LUA_T_FUNCTION */ -{1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0}, /* LUA_T_CFUNCTION */ +{1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0}, /* LUA_T_PROTO */ +{1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0}, /* LUA_T_CPROTO */ {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1} /* LUA_T_NIL */ }; @@ -145,14 +145,19 @@ void luaT_realtag (int tag) int luaT_efectivetag (TObject *o) { - lua_Type t = ttype(o); - if (t == LUA_T_USERDATA) { - int tag = o->value.ts->u.d.tag; - return (tag >= 0) ? LUA_T_USERDATA : tag; + int t; + switch (t = ttype(o)) { + case LUA_T_USERDATA: { + int tag = o->value.ts->u.d.tag; + return (tag >= 0) ? LUA_T_USERDATA : tag; + } + case LUA_T_ARRAY: + return o->value.a->htag; + case LUA_T_FUNCTION: case LUA_T_MARK: + return o->value.cl->consts[0].ttype; + default: + return t; } - else if (t == LUA_T_ARRAY) - return o->value.a->htag; - else return t; } @@ -163,7 +168,7 @@ TObject *luaT_gettagmethod (int t, char *event) if (validevent(t, e)) return luaT_getim(t,e); else - return luaT_getim(LUA_T_CMARK, IM_GETTABLE); /* always nil */ + return luaT_getim(LUA_T_NUMBER, IM_ADD); /* always nil */ } -- cgit v1.2.3-55-g6feb