diff --git a/lapi.c b/lapi.c index 07dbda85..c9b30ace 100644 --- a/lapi.c +++ b/lapi.c @@ -1,5 +1,5 @@ /* -** $Id: lapi.c,v 2.109 2010/01/08 15:16:56 roberto Exp roberto $ +** $Id: lapi.c,v 2.110 2010/01/11 17:38:30 roberto Exp roberto $ ** Lua API ** See Copyright Notice in lua.h */ @@ -255,7 +255,7 @@ LUA_API int lua_type (lua_State *L, int idx) { LUA_API const char *lua_typename (lua_State *L, int t) { UNUSED(L); - return (t == LUA_TNONE) ? "no value" : luaT_typenames[t]; + return typename(t); } diff --git a/ldebug.c b/ldebug.c index d5cdb868..6b15634e 100644 --- a/ldebug.c +++ b/ldebug.c @@ -1,5 +1,5 @@ /* -** $Id: ldebug.c,v 2.61 2010/01/06 14:42:35 roberto Exp roberto $ +** $Id: ldebug.c,v 2.62 2010/01/11 17:37:59 roberto Exp roberto $ ** Debug Interface ** See Copyright Notice in lua.h */ @@ -416,7 +416,7 @@ static int isinstack (CallInfo *ci, const TValue *o) { void luaG_typeerror (lua_State *L, const TValue *o, const char *op) { CallInfo *ci = L->ci; const char *name = NULL; - const char *t = luaT_typenames[ttype(o)]; + const char *t = typename(ttype(o)); const char *kind = (isLua(ci) && isinstack(ci, o)) ? getobjname(L, ci, cast_int(o - ci->u.l.base), &name) : NULL; @@ -444,9 +444,9 @@ void luaG_aritherror (lua_State *L, const TValue *p1, const TValue *p2) { int luaG_ordererror (lua_State *L, const TValue *p1, const TValue *p2) { - const char *t1 = luaT_typenames[ttype(p1)]; - const char *t2 = luaT_typenames[ttype(p2)]; - if (t1[2] == t2[2]) + const char *t1 = typename(ttype(p1)); + const char *t2 = typename(ttype(p2)); + if (t1 == t2) luaG_runerror(L, "attempt to compare two %s values", t1); else luaG_runerror(L, "attempt to compare %s with %s", t1, t2); diff --git a/ltests.c b/ltests.c index 01edb955..3d0fa117 100644 --- a/ltests.c +++ b/ltests.c @@ -1,5 +1,5 @@ /* -** $Id: ltests.c,v 2.85 2009/12/17 16:20:01 roberto Exp roberto $ +** $Id: ltests.c,v 2.86 2009/12/22 15:32:50 roberto Exp roberto $ ** Internal Module for Debugging of the Lua Implementation ** See Copyright Notice in lua.h */ @@ -190,7 +190,7 @@ static void printobj (global_State *g, GCObject *o) { GCObject *p; for (p = g->rootgc; p != o && p != NULL; p = gch(p)->next) i++; if (p == NULL) i = -1; - printf("%d:%s(%p)-%c(%02X)", i, luaT_typenames[gch(o)->tt], (void *)o, + printf("%d:%s(%p)-%c(%02X)", i, typename(gch(o)->tt), (void *)o, isdead(g,o)?'d':isblack(o)?'b':iswhite(o)?'w':'g', gch(o)->marked); } @@ -329,10 +329,7 @@ static void checkstack (global_State *g, lua_State *L1) { static void checkobject (global_State *g, GCObject *o) { if (isdead(g, o)) -/* lua_assert(issweep(g));*/ -{ if (!issweep(g)) -printf(">>> %d %s %02x\n", g->gcstate, luaT_typenames[gch(o)->tt], gch(o)->marked); -} + lua_assert(issweep(g)); else { if (g->gcstate == GCSfinalize) lua_assert(iswhite(o)); @@ -1141,10 +1138,6 @@ static int runC (lua_State *L, lua_State *L1, const char *pc) { else if EQ("type") { lua_pushstring(L1, luaL_typename(L1, getnum)); } -/* else if EQ("getn") { - int i = getindex; - lua_pushinteger(L1, lua_objlen(L1, i)); - } */ else if EQ("append") { int t = getindex; int i = lua_rawlen(L1, t); diff --git a/ltm.c b/ltm.c index 3495658a..b859164b 100644 --- a/ltm.c +++ b/ltm.c @@ -1,5 +1,5 @@ /* -** $Id: ltm.c,v 2.9 2007/09/10 17:59:32 roberto Exp roberto $ +** $Id: ltm.c,v 2.10 2009/11/19 19:06:52 roberto Exp roberto $ ** Tag methods ** See Copyright Notice in lua.h */ @@ -19,10 +19,12 @@ #include "ltm.h" +static const char udatatypename[] = "userdata"; -LUAI_DDEF const char *const luaT_typenames[] = { - "nil", "boolean", "userdata", "number", - "string", "table", "function", "userdata", "thread", +LUAI_DDEF const char *const luaT_typenames_[] = { + "no value", + "nil", "boolean", udatatypename, "number", + "string", "table", "function", udatatypename, "thread", "proto", "upval" }; diff --git a/ltm.h b/ltm.h index 64e867b8..adb1b2e3 100644 --- a/ltm.h +++ b/ltm.h @@ -1,5 +1,5 @@ /* -** $Id: ltm.h,v 2.7 2007/09/10 17:59:32 roberto Exp roberto $ +** $Id: ltm.h,v 2.8 2009/11/19 19:06:52 roberto Exp roberto $ ** Tag methods ** See Copyright Notice in lua.h */ @@ -43,7 +43,9 @@ typedef enum { #define fasttm(l,et,e) gfasttm(G(l), et, e) -LUAI_DDEC const char *const luaT_typenames[]; +#define typename(x) luaT_typenames_[(x) + 1] + +LUAI_DDEC const char *const luaT_typenames_[]; LUAI_FUNC const TValue *luaT_gettm (Table *events, TMS event, TString *ename);