lua_equalObj now is global (and is used by opcode)

This commit is contained in:
Roberto Ierusalimschy 1994-11-14 16:41:15 -02:00
parent e1d91fd0e1
commit 3b7a36653b
2 changed files with 9 additions and 4 deletions

10
hash.c
View File

@ -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 <string.h>
#include <stdlib.h>
@ -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);
}

3
hash.h
View File

@ -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);