From 3b7a36653b5da227502ec5a3c677b6a351af67be Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Mon, 14 Nov 1994 16:41:15 -0200 Subject: [PATCH] lua_equalObj now is global (and is used by opcode) --- hash.c | 10 +++++++--- hash.h | 3 ++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/hash.c b/hash.c index 09ef8bcb..c3dfa160 100644 --- a/hash.c +++ b/hash.c @@ -3,7 +3,7 @@ ** hash manager for lua */ -char *rcs_hash="$Id: hash.c,v 2.14 1994/11/07 16:34:44 roberto Exp $"; +char *rcs_hash="$Id: hash.c,v 2.15 1994/11/10 17:36:54 roberto Exp $"; #include #include @@ -82,13 +82,17 @@ static int hashindex (Hash *t, Object *ref) /* hash function */ } } -static int equalObj (Object *t1, Object *t2) +int lua_equalObj (Object *t1, Object *t2) { if (tag(t1) != tag(t2)) return 0; switch (tag(t1)) { + case LUA_T_NIL: return 1; case LUA_T_NUMBER: return nvalue(t1) == nvalue(t2); case LUA_T_STRING: return streq(svalue(t1), svalue(t2)); + case LUA_T_ARRAY: return avalue(t1) == avalue(t2); + case LUA_T_FUNCTION: return bvalue(t1) == bvalue(t2); + case LUA_T_CFUNCTION: return fvalue(t1) == fvalue(t2); default: return uvalue(t1) == uvalue(t2); } } @@ -98,7 +102,7 @@ static int present (Hash *t, Object *ref) int h = hashindex(t, ref); while (tag(ref(node(t, h))) != LUA_T_NIL) { - if (equalObj(ref, ref(node(t, h)))) + if (lua_equalObj(ref, ref(node(t, h)))) return h; h = (h+1) % nhash(t); } diff --git a/hash.h b/hash.h index 523ff918..ba94dd99 100644 --- a/hash.h +++ b/hash.h @@ -2,7 +2,7 @@ ** hash.h ** hash manager for lua ** Luiz Henrique de Figueiredo - 17 Aug 90 -** $Id: hash.h,v 2.3 1994/08/09 11:24:45 celes Exp celes $ +** $Id: hash.h,v 2.4 1994/09/08 16:51:49 celes Exp roberto $ */ #ifndef hash_h @@ -24,6 +24,7 @@ typedef struct Hash } Hash; +int lua_equalObj (Object *t1, Object *t2); Hash *lua_createarray (int nhash); void lua_hashmark (Hash *h); void lua_hashcollector (void);