aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1994-11-14 16:41:15 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1994-11-14 16:41:15 -0200
commit3b7a36653b5da227502ec5a3c677b6a351af67be (patch)
tree5e6d9e0b5c169e29bf8fc9339c4699223b153546
parente1d91fd0e185e295fa15dd508580d3c8d4636960 (diff)
downloadlua-3b7a36653b5da227502ec5a3c677b6a351af67be.tar.gz
lua-3b7a36653b5da227502ec5a3c677b6a351af67be.tar.bz2
lua-3b7a36653b5da227502ec5a3c677b6a351af67be.zip
lua_equalObj now is global (and is used by opcode)
-rw-r--r--hash.c10
-rw-r--r--hash.h3
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 @@
3** hash manager for lua 3** hash manager for lua
4*/ 4*/
5 5
6char *rcs_hash="$Id: hash.c,v 2.14 1994/11/07 16:34:44 roberto Exp $"; 6char *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
85static int equalObj (Object *t1, Object *t2) 85int 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 }
diff --git a/hash.h b/hash.h
index 523ff918..ba94dd99 100644
--- a/hash.h
+++ b/hash.h
@@ -2,7 +2,7 @@
2** hash.h 2** hash.h
3** hash manager for lua 3** hash manager for lua
4** Luiz Henrique de Figueiredo - 17 Aug 90 4** Luiz Henrique de Figueiredo - 17 Aug 90
5** $Id: hash.h,v 2.3 1994/08/09 11:24:45 celes Exp celes $ 5** $Id: hash.h,v 2.4 1994/09/08 16:51:49 celes Exp roberto $
6*/ 6*/
7 7
8#ifndef hash_h 8#ifndef hash_h
@@ -24,6 +24,7 @@ typedef struct Hash
24} Hash; 24} Hash;
25 25
26 26
27int lua_equalObj (Object *t1, Object *t2);
27Hash *lua_createarray (int nhash); 28Hash *lua_createarray (int nhash);
28void lua_hashmark (Hash *h); 29void lua_hashmark (Hash *h);
29void lua_hashcollector (void); 30void lua_hashcollector (void);