summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lapi.c4
-rw-r--r--ldebug.c10
-rw-r--r--ltests.c13
-rw-r--r--ltm.c10
-rw-r--r--ltm.h6
5 files changed, 20 insertions, 23 deletions
diff --git a/lapi.c b/lapi.c
index 07dbda85..c9b30ace 100644
--- a/lapi.c
+++ b/lapi.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lapi.c,v 2.109 2010/01/08 15:16:56 roberto Exp roberto $ 2** $Id: lapi.c,v 2.110 2010/01/11 17:38:30 roberto Exp roberto $
3** Lua API 3** Lua API
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -255,7 +255,7 @@ LUA_API int lua_type (lua_State *L, int idx) {
255 255
256LUA_API const char *lua_typename (lua_State *L, int t) { 256LUA_API const char *lua_typename (lua_State *L, int t) {
257 UNUSED(L); 257 UNUSED(L);
258 return (t == LUA_TNONE) ? "no value" : luaT_typenames[t]; 258 return typename(t);
259} 259}
260 260
261 261
diff --git a/ldebug.c b/ldebug.c
index d5cdb868..6b15634e 100644
--- a/ldebug.c
+++ b/ldebug.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldebug.c,v 2.61 2010/01/06 14:42:35 roberto Exp roberto $ 2** $Id: ldebug.c,v 2.62 2010/01/11 17:37:59 roberto Exp roberto $
3** Debug Interface 3** Debug Interface
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -416,7 +416,7 @@ static int isinstack (CallInfo *ci, const TValue *o) {
416void luaG_typeerror (lua_State *L, const TValue *o, const char *op) { 416void luaG_typeerror (lua_State *L, const TValue *o, const char *op) {
417 CallInfo *ci = L->ci; 417 CallInfo *ci = L->ci;
418 const char *name = NULL; 418 const char *name = NULL;
419 const char *t = luaT_typenames[ttype(o)]; 419 const char *t = typename(ttype(o));
420 const char *kind = (isLua(ci) && isinstack(ci, o)) ? 420 const char *kind = (isLua(ci) && isinstack(ci, o)) ?
421 getobjname(L, ci, cast_int(o - ci->u.l.base), &name) : 421 getobjname(L, ci, cast_int(o - ci->u.l.base), &name) :
422 NULL; 422 NULL;
@@ -444,9 +444,9 @@ void luaG_aritherror (lua_State *L, const TValue *p1, const TValue *p2) {
444 444
445 445
446int luaG_ordererror (lua_State *L, const TValue *p1, const TValue *p2) { 446int luaG_ordererror (lua_State *L, const TValue *p1, const TValue *p2) {
447 const char *t1 = luaT_typenames[ttype(p1)]; 447 const char *t1 = typename(ttype(p1));
448 const char *t2 = luaT_typenames[ttype(p2)]; 448 const char *t2 = typename(ttype(p2));
449 if (t1[2] == t2[2]) 449 if (t1 == t2)
450 luaG_runerror(L, "attempt to compare two %s values", t1); 450 luaG_runerror(L, "attempt to compare two %s values", t1);
451 else 451 else
452 luaG_runerror(L, "attempt to compare %s with %s", t1, t2); 452 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 @@
1/* 1/*
2** $Id: ltests.c,v 2.85 2009/12/17 16:20:01 roberto Exp roberto $ 2** $Id: ltests.c,v 2.86 2009/12/22 15:32:50 roberto Exp roberto $
3** Internal Module for Debugging of the Lua Implementation 3** Internal Module for Debugging of the Lua Implementation
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -190,7 +190,7 @@ static void printobj (global_State *g, GCObject *o) {
190 GCObject *p; 190 GCObject *p;
191 for (p = g->rootgc; p != o && p != NULL; p = gch(p)->next) i++; 191 for (p = g->rootgc; p != o && p != NULL; p = gch(p)->next) i++;
192 if (p == NULL) i = -1; 192 if (p == NULL) i = -1;
193 printf("%d:%s(%p)-%c(%02X)", i, luaT_typenames[gch(o)->tt], (void *)o, 193 printf("%d:%s(%p)-%c(%02X)", i, typename(gch(o)->tt), (void *)o,
194 isdead(g,o)?'d':isblack(o)?'b':iswhite(o)?'w':'g', gch(o)->marked); 194 isdead(g,o)?'d':isblack(o)?'b':iswhite(o)?'w':'g', gch(o)->marked);
195} 195}
196 196
@@ -329,10 +329,7 @@ static void checkstack (global_State *g, lua_State *L1) {
329 329
330static void checkobject (global_State *g, GCObject *o) { 330static void checkobject (global_State *g, GCObject *o) {
331 if (isdead(g, o)) 331 if (isdead(g, o))
332/* lua_assert(issweep(g));*/ 332 lua_assert(issweep(g));
333{ if (!issweep(g))
334printf(">>> %d %s %02x\n", g->gcstate, luaT_typenames[gch(o)->tt], gch(o)->marked);
335}
336 else { 333 else {
337 if (g->gcstate == GCSfinalize) 334 if (g->gcstate == GCSfinalize)
338 lua_assert(iswhite(o)); 335 lua_assert(iswhite(o));
@@ -1141,10 +1138,6 @@ static int runC (lua_State *L, lua_State *L1, const char *pc) {
1141 else if EQ("type") { 1138 else if EQ("type") {
1142 lua_pushstring(L1, luaL_typename(L1, getnum)); 1139 lua_pushstring(L1, luaL_typename(L1, getnum));
1143 } 1140 }
1144/* else if EQ("getn") {
1145 int i = getindex;
1146 lua_pushinteger(L1, lua_objlen(L1, i));
1147 } */
1148 else if EQ("append") { 1141 else if EQ("append") {
1149 int t = getindex; 1142 int t = getindex;
1150 int i = lua_rawlen(L1, t); 1143 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 @@
1/* 1/*
2** $Id: ltm.c,v 2.9 2007/09/10 17:59:32 roberto Exp roberto $ 2** $Id: ltm.c,v 2.10 2009/11/19 19:06:52 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*/
@@ -19,10 +19,12 @@
19#include "ltm.h" 19#include "ltm.h"
20 20
21 21
22static const char udatatypename[] = "userdata";
22 23
23LUAI_DDEF const char *const luaT_typenames[] = { 24LUAI_DDEF const char *const luaT_typenames_[] = {
24 "nil", "boolean", "userdata", "number", 25 "no value",
25 "string", "table", "function", "userdata", "thread", 26 "nil", "boolean", udatatypename, "number",
27 "string", "table", "function", udatatypename, "thread",
26 "proto", "upval" 28 "proto", "upval"
27}; 29};
28 30
diff --git a/ltm.h b/ltm.h
index 64e867b8..adb1b2e3 100644
--- a/ltm.h
+++ b/ltm.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltm.h,v 2.7 2007/09/10 17:59:32 roberto Exp roberto $ 2** $Id: ltm.h,v 2.8 2009/11/19 19:06:52 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*/
@@ -43,7 +43,9 @@ typedef enum {
43 43
44#define fasttm(l,et,e) gfasttm(G(l), et, e) 44#define fasttm(l,et,e) gfasttm(G(l), et, e)
45 45
46LUAI_DDEC const char *const luaT_typenames[]; 46#define typename(x) luaT_typenames_[(x) + 1]
47
48LUAI_DDEC const char *const luaT_typenames_[];
47 49
48 50
49LUAI_FUNC const TValue *luaT_gettm (Table *events, TMS event, TString *ename); 51LUAI_FUNC const TValue *luaT_gettm (Table *events, TMS event, TString *ename);