diff options
| author | Russ Cox <rsc@golang.org> | 2009-01-26 09:56:42 -0800 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2009-01-26 09:56:42 -0800 |
| commit | a7f6d4066e871916931af4b99f1d5a9021dbfeb9 (patch) | |
| tree | 0527d7d0346358f9ef8027efed0a9c5fea057641 /src/runtime/runtime.c | |
| parent | 18b05c1a8d9fc3c14a384df4bd78063de3b1d61a (diff) | |
| download | go-a7f6d4066e871916931af4b99f1d5a9021dbfeb9.tar.xz | |
implement new restrictions on what
can be compared/hashed.
R=r
DELTA=351 (201 added, 80 deleted, 70 changed)
OCL=23423
CL=23481
Diffstat (limited to 'src/runtime/runtime.c')
| -rw-r--r-- | src/runtime/runtime.c | 57 |
1 files changed, 26 insertions, 31 deletions
diff --git a/src/runtime/runtime.c b/src/runtime/runtime.c index 29a67b190d..ce9349383c 100644 --- a/src/runtime/runtime.c +++ b/src/runtime/runtime.c @@ -328,57 +328,52 @@ strprint(uint32 s, string *a) sys·printstring(*a); } -static void -strcopy(uint32 s, string *a, string *b) +static uint64 +interhash(uint32 s, Iface *a) { USED(s); - if(b == nil) { - *a = nil; - return; - } - *a = *b; + return ifacehash(*a); } -static uint64 -ptrhash(uint32 s, void **a) +static void +interprint(uint32 s, Iface *a) { - return memhash(s, *a); + USED(s); + sys·printinter(*a); } static uint32 -ptrequal(uint32 s, void **a, void **b) +interequal(uint32 s, Iface *a, Iface *b) { - USED(s, a, b); - prints("ptrequal\n"); - return 0; + USED(s); + return ifaceeq(*a, *b); } -static void -ptrprint(uint32 s, void **a) +uint64 +nohash(uint32 s, void *a) { - USED(s, a); - prints("ptrprint\n"); + USED(s); + USED(a); + throw("hash of unhashable type"); + return 0; } -static void -ptrcopy(uint32 s, void **a, void **b) +uint32 +noequal(uint32 s, void *a, void *b) { USED(s); - if(b == nil) { - *a = nil; - return; - } - *a = *b; + USED(a); + USED(b); + throw("comparing uncomparable types"); + return 0; } Alg algarray[] = { -[ASIMP] { memhash, memequal, memprint, memcopy }, -[ASTRING] { strhash, strequal, strprint, strcopy }, -[APTR] { memhash, memequal, memprint, memcopy }, // TODO: ptr routines -[AINTER] { memhash, memequal, memprint, memcopy }, // TODO: interface routines -[ASTRUCT] { memhash, memequal, memprint, memcopy }, // TODO: what goes here? -[AARRAY] { memhash, memequal, memprint, memcopy }, // TODO: what goes here? +[AMEM] { memhash, memequal, memprint, memcopy }, +[ANOEQ] { nohash, noequal, memprint, memcopy }, +[ASTRING] { strhash, strequal, strprint, memcopy }, +[AINTER] { interhash, interequal, interprint, memcopy }, }; |
