diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1994-11-17 19:23:43 -0200 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1994-11-17 19:23:43 -0200 |
| commit | 1929ddcf49b948ed8082cd375f7f7bf0b8a15bee (patch) | |
| tree | 9578d04056107bea60dee410d3889d7745d8764d /hash.c | |
| parent | aa4cd37adfdeb84b8137d3fccdb28a49a3b6d9e5 (diff) | |
| download | lua-1929ddcf49b948ed8082cd375f7f7bf0b8a15bee.tar.gz lua-1929ddcf49b948ed8082cd375f7f7bf0b8a15bee.tar.bz2 lua-1929ddcf49b948ed8082cd375f7f7bf0b8a15bee.zip | |
userdata can have different tags
Diffstat (limited to 'hash.c')
| -rw-r--r-- | hash.c | 10 |
1 files changed, 5 insertions, 5 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.17 1994/11/16 17:38:08 roberto Exp roberto $"; | 6 | char *rcs_hash="$Id: hash.c,v 2.18 1994/11/17 13:58:57 roberto Exp roberto $"; |
| 7 | 7 | ||
| 8 | #include "mem.h" | 8 | #include "mem.h" |
| 9 | #include "opcode.h" | 9 | #include "opcode.h" |
| @@ -49,6 +49,9 @@ static int hashindex (Hash *t, Object *ref) /* hash function */ | |||
| 49 | { | 49 | { |
| 50 | switch (tag(ref)) | 50 | switch (tag(ref)) |
| 51 | { | 51 | { |
| 52 | case LUA_T_NIL: | ||
| 53 | lua_reportbug ("unexpected type to index table"); | ||
| 54 | return -1; /* UNREACHEABLE */ | ||
| 52 | case LUA_T_NUMBER: | 55 | case LUA_T_NUMBER: |
| 53 | return (((int)nvalue(ref))%nhash(t)); | 56 | return (((int)nvalue(ref))%nhash(t)); |
| 54 | case LUA_T_STRING: | 57 | case LUA_T_STRING: |
| @@ -69,11 +72,8 @@ static int hashindex (Hash *t, Object *ref) /* hash function */ | |||
| 69 | return (((int)fvalue(ref))%nhash(t)); | 72 | return (((int)fvalue(ref))%nhash(t)); |
| 70 | case LUA_T_ARRAY: | 73 | case LUA_T_ARRAY: |
| 71 | return (((int)avalue(ref))%nhash(t)); | 74 | return (((int)avalue(ref))%nhash(t)); |
| 72 | case LUA_T_USERDATA: | 75 | default: /* user data */ |
| 73 | return (((int)uvalue(ref))%nhash(t)); | 76 | return (((int)uvalue(ref))%nhash(t)); |
| 74 | default: | ||
| 75 | lua_reportbug ("unexpected type to index table"); | ||
| 76 | return -1; /* UNREACHEABLE */ | ||
| 77 | } | 77 | } |
| 78 | } | 78 | } |
| 79 | 79 | ||
