diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1994-11-14 16:41:15 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1994-11-14 16:41:15 -0200 |
commit | 3b7a36653b5da227502ec5a3c677b6a351af67be (patch) | |
tree | 5e6d9e0b5c169e29bf8fc9339c4699223b153546 /hash.c | |
parent | e1d91fd0e185e295fa15dd508580d3c8d4636960 (diff) | |
download | lua-3b7a36653b5da227502ec5a3c677b6a351af67be.tar.gz lua-3b7a36653b5da227502ec5a3c677b6a351af67be.tar.bz2 lua-3b7a36653b5da227502ec5a3c677b6a351af67be.zip |
lua_equalObj now is global (and is used by opcode)
Diffstat (limited to 'hash.c')
-rw-r--r-- | hash.c | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -3,7 +3,7 @@ | |||
3 | ** hash manager for lua | 3 | ** hash manager for lua |
4 | */ | 4 | */ |
5 | 5 | ||
6 | char *rcs_hash="$Id: hash.c,v 2.14 1994/11/07 16:34:44 roberto Exp $"; | 6 | char *rcs_hash="$Id: hash.c,v 2.15 1994/11/10 17:36:54 roberto Exp $"; |
7 | 7 | ||
8 | #include <string.h> | 8 | #include <string.h> |
9 | #include <stdlib.h> | 9 | #include <stdlib.h> |
@@ -82,13 +82,17 @@ static int hashindex (Hash *t, Object *ref) /* hash function */ | |||
82 | } | 82 | } |
83 | } | 83 | } |
84 | 84 | ||
85 | static int equalObj (Object *t1, Object *t2) | 85 | int lua_equalObj (Object *t1, Object *t2) |
86 | { | 86 | { |
87 | if (tag(t1) != tag(t2)) return 0; | 87 | if (tag(t1) != tag(t2)) return 0; |
88 | switch (tag(t1)) | 88 | switch (tag(t1)) |
89 | { | 89 | { |
90 | case LUA_T_NIL: return 1; | ||
90 | case LUA_T_NUMBER: return nvalue(t1) == nvalue(t2); | 91 | case LUA_T_NUMBER: return nvalue(t1) == nvalue(t2); |
91 | case LUA_T_STRING: return streq(svalue(t1), svalue(t2)); | 92 | case LUA_T_STRING: return streq(svalue(t1), svalue(t2)); |
93 | case LUA_T_ARRAY: return avalue(t1) == avalue(t2); | ||
94 | case LUA_T_FUNCTION: return bvalue(t1) == bvalue(t2); | ||
95 | case LUA_T_CFUNCTION: return fvalue(t1) == fvalue(t2); | ||
92 | default: return uvalue(t1) == uvalue(t2); | 96 | default: return uvalue(t1) == uvalue(t2); |
93 | } | 97 | } |
94 | } | 98 | } |
@@ -98,7 +102,7 @@ static int present (Hash *t, Object *ref) | |||
98 | int h = hashindex(t, ref); | 102 | int h = hashindex(t, ref); |
99 | while (tag(ref(node(t, h))) != LUA_T_NIL) | 103 | while (tag(ref(node(t, h))) != LUA_T_NIL) |
100 | { | 104 | { |
101 | if (equalObj(ref, ref(node(t, h)))) | 105 | if (lua_equalObj(ref, ref(node(t, h)))) |
102 | return h; | 106 | return h; |
103 | h = (h+1) % nhash(t); | 107 | h = (h+1) % nhash(t); |
104 | } | 108 | } |