aboutsummaryrefslogtreecommitdiff
path: root/lobject.c
diff options
context:
space:
mode:
Diffstat (limited to 'lobject.c')
-rw-r--r--lobject.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/lobject.c b/lobject.c
index ce3f757b..86d386df 100644
--- a/lobject.c
+++ b/lobject.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lobject.c,v 1.82 2002/06/03 14:08:43 roberto Exp roberto $ 2** $Id: lobject.c,v 1.83 2002/06/05 12:34:19 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*/
@@ -55,23 +55,28 @@ int luaO_log2 (unsigned int x) {
55} 55}
56 56
57 57
58/* 58int luaO_rawequalObj (const TObject *t1, const TObject *t2) {
59** warning: this function must return 1 for true (see opcode OP_TESTEQ)
60*/
61int luaO_equalObj (const TObject *t1, const TObject *t2) {
62 if (ttype(t1) != ttype(t2)) return 0; 59 if (ttype(t1) != ttype(t2)) return 0;
63 switch (ttype(t1)) { 60 switch (ttype(t1)) {
64 case LUA_TNUMBER: 61 case LUA_TNUMBER:
65 return nvalue(t1) == nvalue(t2); 62 return nvalue(t1) == nvalue(t2);
66 case LUA_TNIL: 63 case LUA_TNIL:
67 return 1; 64 return 1;
65 case LUA_TSTRING:
66 return tsvalue(t1) == tsvalue(t2);
68 case LUA_TBOOLEAN: 67 case LUA_TBOOLEAN:
69 return bvalue(t1) == bvalue(t2); /* boolean true must be 1 !! */ 68 return bvalue(t1) == bvalue(t2); /* boolean true must be 1 !! */
70 case LUA_TUDATAVAL: 69 case LUA_TUDATAVAL:
71 return pvalue(t1) == pvalue(t2); 70 return pvalue(t1) == pvalue(t2);
72 default: /* other types are equal if struct pointers are equal */ 71 case LUA_TUSERDATA:
73 return tsvalue(t1) == tsvalue(t2); 72 return uvalue(t1) == uvalue(t2);
73 case LUA_TTABLE:
74 return hvalue(t1) == hvalue(t2);
75 case LUA_TFUNCTION:
76 return clvalue(t1) == clvalue(t2);
74 } 77 }
78 lua_assert(0);
79 return 0; /* to avoid warnings */
75} 80}
76 81
77 82