+NUM to getValueHash()

This commit is contained in:
CPunch 2020-11-04 21:37:45 -06:00
parent 64c6914748
commit ffa6ca22e3

View File

@ -48,8 +48,15 @@ uint32_t getValueHash(CValue *val) {
switch (val->type) { switch (val->type) {
case COSMO_TOBJ: case COSMO_TOBJ:
return getObjectHash(val->val.obj); return getObjectHash(val->val.obj);
case COSMO_TNUMBER: case COSMO_TNUMBER: {
// how the fuck 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 // TODO: add support for other types
default: default:
return 0; return 0;