From ffa6ca22e3a6e009b43f90c0f9ddde49dbb7c595 Mon Sep 17 00:00:00 2001 From: CPunch Date: Wed, 4 Nov 2020 21:37:45 -0600 Subject: [PATCH] +NUM to getValueHash() --- src/ctable.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/ctable.c b/src/ctable.c index b88c67b..61b59fc 100644 --- a/src/ctable.c +++ b/src/ctable.c @@ -48,8 +48,15 @@ uint32_t getValueHash(CValue *val) { switch (val->type) { case COSMO_TOBJ: return getObjectHash(val->val.obj); - case COSMO_TNUMBER: - // how the fuck + case COSMO_TNUMBER: { + uint32_t buf[sizeof(cosmo_Number)/sizeof(uint32_t)]; + if (val->val.num == 0) + return 0; + memcpy(buf, &val->val.num, sizeof(buf)); + for (int i = 0; i < sizeof(cosmo_Number)/sizeof(uint32_t); i++) buf[0] += buf[i]; + return buf[0]; + } + // TODO: add support for other types default: return 0;