aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2011-04-05 15:32:06 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2011-04-05 15:32:06 -0300
commit528665089402ea1fff2c36efb4c95c416f01c962 (patch)
tree869a5d408b21dbb86559e0ced98b39d507db2cc3
parent0fb1644c6070daada206fc091f45b4bc39381ea2 (diff)
downloadlua-528665089402ea1fff2c36efb4c95c416f01c962.tar.gz
lua-528665089402ea1fff2c36efb4c95c416f01c962.tar.bz2
lua-528665089402ea1fff2c36efb4c95c416f01c962.zip
new macro 'ttisequal'
-rw-r--r--lobject.c4
-rw-r--r--lvm.c4
-rw-r--r--lvm.h5
3 files changed, 6 insertions, 7 deletions
diff --git a/lobject.c b/lobject.c
index be00daf0..0fd44626 100644
--- a/lobject.c
+++ b/lobject.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lobject.c,v 2.45 2010/12/10 19:03:46 roberto Exp roberto $ 2** $Id: lobject.c,v 2.46 2011/02/07 19:15:24 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*/
@@ -71,7 +71,7 @@ int luaO_ceillog2 (unsigned int x) {
71 71
72 72
73int luaO_rawequalObj (const TValue *t1, const TValue *t2) { 73int luaO_rawequalObj (const TValue *t1, const TValue *t2) {
74 if (ttype(t1) != ttype(t2)) return 0; 74 if (!ttisequal(t1, t2)) return 0;
75 else switch (ttype(t1)) { 75 else switch (ttype(t1)) {
76 case LUA_TNIL: 76 case LUA_TNIL:
77 return 1; 77 return 1;
diff --git a/lvm.c b/lvm.c
index e245618c..03725eb7 100644
--- a/lvm.c
+++ b/lvm.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lvm.c,v 2.131 2011/02/07 19:15:24 roberto Exp roberto $ 2** $Id: lvm.c,v 2.132 2011/04/05 14:26:23 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*/
@@ -239,7 +239,7 @@ int luaV_lessequal (lua_State *L, const TValue *l, const TValue *r) {
239 239
240int luaV_equalval_ (lua_State *L, const TValue *t1, const TValue *t2) { 240int luaV_equalval_ (lua_State *L, const TValue *t1, const TValue *t2) {
241 const TValue *tm; 241 const TValue *tm;
242 lua_assert(ttype(t1) == ttype(t2)); 242 lua_assert(ttisequal(t1, t2));
243 switch (ttype(t1)) { 243 switch (ttype(t1)) {
244 case LUA_TNIL: return 1; 244 case LUA_TNIL: return 1;
245 case LUA_TNUMBER: return luai_numeq(nvalue(t1), nvalue(t2)); 245 case LUA_TNUMBER: return luai_numeq(nvalue(t1), nvalue(t2));
diff --git a/lvm.h b/lvm.h
index 23e50798..8e61cf34 100644
--- a/lvm.h
+++ b/lvm.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lvm.h,v 2.13 2009/11/19 19:04:58 roberto Exp roberto $ 2** $Id: lvm.h,v 2.14 2009/12/17 16:20:01 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*/
@@ -17,8 +17,7 @@
17 17
18#define tonumber(o,n) (ttisnumber(o) || (((o) = luaV_tonumber(o,n)) != NULL)) 18#define tonumber(o,n) (ttisnumber(o) || (((o) = luaV_tonumber(o,n)) != NULL))
19 19
20#define equalobj(L,o1,o2) \ 20#define equalobj(L,o1,o2) (ttisequal(o1, o2) && luaV_equalval_(L, o1, o2))
21 (ttype(o1) == ttype(o2) && luaV_equalval_(L, o1, o2))
22 21
23 22
24/* not to called directly */ 23/* not to called directly */