diff options
| -rw-r--r-- | ldebug.c | 12 | ||||
| -rw-r--r-- | lobject.c | 4 | ||||
| -rw-r--r-- | lparser.c | 6 | ||||
| -rw-r--r-- | lstring.h | 9 | ||||
| -rw-r--r-- | ltable.c | 5 | ||||
| -rw-r--r-- | lvm.c | 3 |
6 files changed, 25 insertions, 14 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ldebug.c,v 2.66 2010/03/12 19:14:06 roberto Exp roberto $ | 2 | ** $Id: ldebug.c,v 2.67 2010/03/13 15:55:42 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 | */ |
| @@ -300,11 +300,11 @@ static const char *getobjname (lua_State *L, CallInfo *ci, int reg, | |||
| 300 | if (reg == a) { | 300 | if (reg == a) { |
| 301 | int k = GETARG_C(i); /* key index */ | 301 | int k = GETARG_C(i); /* key index */ |
| 302 | int t = GETARG_B(i); | 302 | int t = GETARG_B(i); |
| 303 | const char *tabname = (op == OP_GETTABLE) | 303 | const char *vn = (op == OP_GETTABLE) /* name of indexed variable */ |
| 304 | ? luaF_getlocalname(p, t + 1, pc) | 304 | ? luaF_getlocalname(p, t + 1, pc) |
| 305 | : getstr(p->upvalues[t].name); | 305 | : getstr(p->upvalues[t].name); |
| 306 | kname(p, k, a, what, name); | 306 | kname(p, k, a, what, name); |
| 307 | what = (tabname == getstr(G(L)->envn)) ? "global" : "field"; | 307 | what = (vn && strcmp(vn, "_ENV") == 0) ? "global" : "field"; |
| 308 | } | 308 | } |
| 309 | break; | 309 | break; |
| 310 | } | 310 | } |
| @@ -427,7 +427,7 @@ static const char *getupvalname (CallInfo *ci, const TValue *o, | |||
| 427 | LClosure *c = &ci_func(ci)->l; | 427 | LClosure *c = &ci_func(ci)->l; |
| 428 | int i; | 428 | int i; |
| 429 | for (i = 0; i < c->nupvalues; i++) { | 429 | for (i = 0; i < c->nupvalues; i++) { |
| 430 | if (c->upvals[i]->v == o) { | 430 | if (eqstr(c->upvals[i]->v, o)) { |
| 431 | *name = getstr(c->p->upvalues[i].name); | 431 | *name = getstr(c->p->upvalues[i].name); |
| 432 | return "upvalue"; | 432 | return "upvalue"; |
| 433 | } | 433 | } |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lobject.c,v 2.35 2010/02/05 19:09:09 roberto Exp roberto $ | 2 | ** $Id: lobject.c,v 2.36 2010/04/02 15:30:27 roberto Exp roberto $ |
| 3 | ** Some generic functions over Lua objects | 3 | ** Some generic functions over Lua objects |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -81,6 +81,8 @@ int luaO_rawequalObj (const TValue *t1, const TValue *t2) { | |||
| 81 | return bvalue(t1) == bvalue(t2); /* boolean true must be 1 !! */ | 81 | return bvalue(t1) == bvalue(t2); /* boolean true must be 1 !! */ |
| 82 | case LUA_TLIGHTUSERDATA: | 82 | case LUA_TLIGHTUSERDATA: |
| 83 | return pvalue(t1) == pvalue(t2); | 83 | return pvalue(t1) == pvalue(t2); |
| 84 | case LUA_TSTRING: | ||
| 85 | return rawtsvalue(t1) == rawtsvalue(t2); | ||
| 84 | default: | 86 | default: |
| 85 | lua_assert(iscollectable(t1)); | 87 | lua_assert(iscollectable(t1)); |
| 86 | return gcvalue(t1) == gcvalue(t2); | 88 | return gcvalue(t1) == gcvalue(t2); |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lparser.c,v 2.79 2010/03/12 19:14:06 roberto Exp roberto $ | 2 | ** $Id: lparser.c,v 2.80 2010/03/13 15:55:42 roberto Exp roberto $ |
| 3 | ** Lua Parser | 3 | ** Lua Parser |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -211,7 +211,7 @@ static int searchupvalue (FuncState *fs, TString *name) { | |||
| 211 | int i; | 211 | int i; |
| 212 | Upvaldesc *up = fs->f->upvalues; | 212 | Upvaldesc *up = fs->f->upvalues; |
| 213 | for (i = 0; i < fs->nups; i++) { | 213 | for (i = 0; i < fs->nups; i++) { |
| 214 | if (up[i].name == name) return i; | 214 | if (eqstr(up[i].name, name)) return i; |
| 215 | } | 215 | } |
| 216 | return -1; /* not found */ | 216 | return -1; /* not found */ |
| 217 | } | 217 | } |
| @@ -235,7 +235,7 @@ static int newupvalue (FuncState *fs, TString *name, expdesc *v) { | |||
| 235 | static int searchvar (FuncState *fs, TString *n) { | 235 | static int searchvar (FuncState *fs, TString *n) { |
| 236 | int i; | 236 | int i; |
| 237 | for (i=fs->nactvar-1; i >= 0; i--) { | 237 | for (i=fs->nactvar-1; i >= 0; i--) { |
| 238 | if (n == getlocvar(fs, i)->varname) | 238 | if (eqstr(n, getlocvar(fs, i)->varname)) |
| 239 | return i; | 239 | return i; |
| 240 | } | 240 | } |
| 241 | return -1; /* not found */ | 241 | return -1; /* not found */ |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lstring.h,v 1.44 2010/03/13 15:55:01 roberto Exp roberto $ | 2 | ** $Id: lstring.h,v 1.45 2010/04/03 20:24:18 roberto Exp roberto $ |
| 3 | ** String table (keep all strings handled by Lua) | 3 | ** String table (keep all strings handled by Lua) |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -21,6 +21,13 @@ | |||
| 21 | 21 | ||
| 22 | #define luaS_fix(s) l_setbit((s)->tsv.marked, FIXEDBIT) | 22 | #define luaS_fix(s) l_setbit((s)->tsv.marked, FIXEDBIT) |
| 23 | 23 | ||
| 24 | |||
| 25 | /* | ||
| 26 | ** as all string are internalized, string equality becomes | ||
| 27 | ** pointer equality | ||
| 28 | */ | ||
| 29 | #define eqstr(a,b) ((a) == (b)) | ||
| 30 | |||
| 24 | LUAI_FUNC void luaS_resize (lua_State *L, int newsize); | 31 | LUAI_FUNC void luaS_resize (lua_State *L, int newsize); |
| 25 | LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s, Table *e); | 32 | LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s, Table *e); |
| 26 | LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l); | 33 | LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l); |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ltable.c,v 2.46 2009/11/26 11:39:20 roberto Exp roberto $ | 2 | ** $Id: ltable.c,v 2.47 2009/12/17 15:46:44 roberto Exp roberto $ |
| 3 | ** Lua tables (hash) | 3 | ** Lua tables (hash) |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -31,6 +31,7 @@ | |||
| 31 | #include "lmem.h" | 31 | #include "lmem.h" |
| 32 | #include "lobject.h" | 32 | #include "lobject.h" |
| 33 | #include "lstate.h" | 33 | #include "lstate.h" |
| 34 | #include "lstring.h" | ||
| 34 | #include "ltable.h" | 35 | #include "ltable.h" |
| 35 | 36 | ||
| 36 | 37 | ||
| @@ -452,7 +453,7 @@ const TValue *luaH_getint (Table *t, int key) { | |||
| 452 | const TValue *luaH_getstr (Table *t, TString *key) { | 453 | const TValue *luaH_getstr (Table *t, TString *key) { |
| 453 | Node *n = hashstr(t, key); | 454 | Node *n = hashstr(t, key); |
| 454 | do { /* check whether `key' is somewhere in the chain */ | 455 | do { /* check whether `key' is somewhere in the chain */ |
| 455 | if (ttisstring(gkey(n)) && rawtsvalue(gkey(n)) == key) | 456 | if (ttisstring(gkey(n)) && eqstr(rawtsvalue(gkey(n)), key)) |
| 456 | return gval(n); /* that's it */ | 457 | return gval(n); /* that's it */ |
| 457 | else n = gnext(n); | 458 | else n = gnext(n); |
| 458 | } while (n); | 459 | } while (n); |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lvm.c,v 2.108 2010/03/29 20:45:49 roberto Exp roberto $ | 2 | ** $Id: lvm.c,v 2.109 2010/04/02 15:39:07 roberto Exp roberto $ |
| 3 | ** Lua virtual machine | 3 | ** Lua virtual machine |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -254,6 +254,7 @@ int luaV_equalval_ (lua_State *L, const TValue *t1, const TValue *t2) { | |||
| 254 | case LUA_TNUMBER: return luai_numeq(nvalue(t1), nvalue(t2)); | 254 | case LUA_TNUMBER: return luai_numeq(nvalue(t1), nvalue(t2)); |
| 255 | case LUA_TBOOLEAN: return bvalue(t1) == bvalue(t2); /* true must be 1 !! */ | 255 | case LUA_TBOOLEAN: return bvalue(t1) == bvalue(t2); /* true must be 1 !! */ |
| 256 | case LUA_TLIGHTUSERDATA: return pvalue(t1) == pvalue(t2); | 256 | case LUA_TLIGHTUSERDATA: return pvalue(t1) == pvalue(t2); |
| 257 | case LUA_TSTRING: return eqstr(rawtsvalue(t1), rawtsvalue(t2)); | ||
| 257 | case LUA_TUSERDATA: { | 258 | case LUA_TUSERDATA: { |
| 258 | if (uvalue(t1) == uvalue(t2)) return 1; | 259 | if (uvalue(t1) == uvalue(t2)) return 1; |
| 259 | tm = get_compTM(L, uvalue(t1)->metatable, uvalue(t2)->metatable, TM_EQ); | 260 | tm = get_compTM(L, uvalue(t1)->metatable, uvalue(t2)->metatable, TM_EQ); |
