diff options
Diffstat (limited to 'hash.c')
-rw-r--r-- | hash.c | 18 |
1 files changed, 9 insertions, 9 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.31 1996/07/12 20:00:26 roberto Exp roberto $"; | 6 | char *rcs_hash="$Id: hash.c,v 2.32 1996/11/18 13:48:44 roberto Exp roberto $"; |
7 | 7 | ||
8 | 8 | ||
9 | #include "mem.h" | 9 | #include "mem.h" |
@@ -50,12 +50,9 @@ static int hashindex (Hash *t, Object *ref) /* hash function */ | |||
50 | { | 50 | { |
51 | long int h; | 51 | long int h; |
52 | switch (tag(ref)) { | 52 | switch (tag(ref)) { |
53 | case LUA_T_NIL: | ||
54 | lua_error ("unexpected type to index table"); | ||
55 | h = 0; /* UNREACHEABLE */ | ||
56 | case LUA_T_NUMBER: | 53 | case LUA_T_NUMBER: |
57 | h = (long int)nvalue(ref); break; | 54 | h = (long int)nvalue(ref); break; |
58 | case LUA_T_STRING: | 55 | case LUA_T_STRING: case LUA_T_USERDATA: |
59 | h = tsvalue(ref)->hash; break; | 56 | h = tsvalue(ref)->hash; break; |
60 | case LUA_T_FUNCTION: | 57 | case LUA_T_FUNCTION: |
61 | h = (IntPoint)ref->value.tf; break; | 58 | h = (IntPoint)ref->value.tf; break; |
@@ -63,8 +60,9 @@ static int hashindex (Hash *t, Object *ref) /* hash function */ | |||
63 | h = (IntPoint)fvalue(ref); break; | 60 | h = (IntPoint)fvalue(ref); break; |
64 | case LUA_T_ARRAY: | 61 | case LUA_T_ARRAY: |
65 | h = (IntPoint)avalue(ref); break; | 62 | h = (IntPoint)avalue(ref); break; |
66 | default: /* user data */ | 63 | default: |
67 | h = (IntPoint)uvalue(ref); break; | 64 | lua_error ("unexpected type to index table"); |
65 | h = 0; /* UNREACHEABLE */ | ||
68 | } | 66 | } |
69 | if (h < 0) h = -h; | 67 | if (h < 0) h = -h; |
70 | return h%nhash(t); /* make it a valid index */ | 68 | return h%nhash(t); /* make it a valid index */ |
@@ -77,11 +75,13 @@ int lua_equalObj (Object *t1, Object *t2) | |||
77 | { | 75 | { |
78 | case LUA_T_NIL: return 1; | 76 | case LUA_T_NIL: return 1; |
79 | case LUA_T_NUMBER: return nvalue(t1) == nvalue(t2); | 77 | case LUA_T_NUMBER: return nvalue(t1) == nvalue(t2); |
80 | case LUA_T_STRING: return svalue(t1) == svalue(t2); | 78 | case LUA_T_STRING: case LUA_T_USERDATA: return svalue(t1) == svalue(t2); |
81 | case LUA_T_ARRAY: return avalue(t1) == avalue(t2); | 79 | case LUA_T_ARRAY: return avalue(t1) == avalue(t2); |
82 | case LUA_T_FUNCTION: return t1->value.tf == t2->value.tf; | 80 | case LUA_T_FUNCTION: return t1->value.tf == t2->value.tf; |
83 | case LUA_T_CFUNCTION: return fvalue(t1) == fvalue(t2); | 81 | case LUA_T_CFUNCTION: return fvalue(t1) == fvalue(t2); |
84 | default: return uvalue(t1) == uvalue(t2); | 82 | default: |
83 | lua_error("internal error at `lua_equalObj'"); | ||
84 | return 0; /* UNREACHEABLE */ | ||
85 | } | 85 | } |
86 | } | 86 | } |
87 | 87 | ||