2
0
Эх сурвалжийг харах

"no value" added to array luaT_typenames + occurrences of "userdata"
in that array unified in a single address

Roberto Ierusalimschy 15 жил өмнө
parent
commit
070d3743a7
5 өөрчлөгдсөн 20 нэмэгдсэн , 23 устгасан
  1. 2 2
      lapi.c
  2. 5 5
      ldebug.c
  3. 3 10
      ltests.c
  4. 6 4
      ltm.c
  5. 4 2
      ltm.h

+ 2 - 2
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
 ** Lua API
 ** See Copyright Notice in lua.h
 ** 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) {
 LUA_API const char *lua_typename (lua_State *L, int t) {
   UNUSED(L);
   UNUSED(L);
-  return (t == LUA_TNONE) ? "no value" : luaT_typenames[t];
+  return typename(t);
 }
 }
 
 
 
 

+ 5 - 5
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
 ** Debug Interface
 ** See Copyright Notice in lua.h
 ** 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) {
 void luaG_typeerror (lua_State *L, const TValue *o, const char *op) {
   CallInfo *ci = L->ci;
   CallInfo *ci = L->ci;
   const char *name = NULL;
   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)) ?
   const char *kind = (isLua(ci) && isinstack(ci, o)) ?
                          getobjname(L, ci, cast_int(o - ci->u.l.base), &name) :
                          getobjname(L, ci, cast_int(o - ci->u.l.base), &name) :
                          NULL;
                          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) {
 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);
     luaG_runerror(L, "attempt to compare two %s values", t1);
   else
   else
     luaG_runerror(L, "attempt to compare %s with %s", t1, t2);
     luaG_runerror(L, "attempt to compare %s with %s", t1, t2);

+ 3 - 10
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
 ** Internal Module for Debugging of the Lua Implementation
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -190,7 +190,7 @@ static void printobj (global_State *g, GCObject *o) {
   GCObject *p;
   GCObject *p;
   for (p = g->rootgc; p != o && p != NULL; p = gch(p)->next) i++;
   for (p = g->rootgc; p != o && p != NULL; p = gch(p)->next) i++;
   if (p == NULL) i = -1;
   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);
            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) {
 static void checkobject (global_State *g, GCObject *o) {
   if (isdead(g, 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 {
   else {
     if (g->gcstate == GCSfinalize)
     if (g->gcstate == GCSfinalize)
       lua_assert(iswhite(o));
       lua_assert(iswhite(o));
@@ -1141,10 +1138,6 @@ static int runC (lua_State *L, lua_State *L1, const char *pc) {
     else if EQ("type") {
     else if EQ("type") {
       lua_pushstring(L1, luaL_typename(L1, getnum));
       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") {
     else if EQ("append") {
       int t = getindex;
       int t = getindex;
       int i = lua_rawlen(L1, t);
       int i = lua_rawlen(L1, t);

+ 6 - 4
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
 ** Tag methods
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -19,10 +19,12 @@
 #include "ltm.h"
 #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"
   "proto", "upval"
 };
 };
 
 

+ 4 - 2
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
 ** Tag methods
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -43,7 +43,9 @@ typedef enum {
 
 
 #define fasttm(l,et,e)	gfasttm(G(l), et, e)
 #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);
 LUAI_FUNC const TValue *luaT_gettm (Table *events, TMS event, TString *ename);