hare

[hare] The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit 8ae07061eb4cd68b0ef694da348ed523ae4929a9
parent 1cfd1318b941bceadfa8a24d7952c084ff6b07cd
Author: Sebastian <sebastian@sebsite.pw>
Date:   Sun, 23 Apr 2023 02:40:49 -0400

hare::types: platform-specific hash calculation

Signed-off-by: Sebastian <sebastian@sebsite.pw>

Diffstat:
Ahare/types/+aarch64/hash.ha | 3+++
Ahare/types/+riscv64/hash.ha | 3+++
Ahare/types/+x86_64/hash.ha | 3+++
Mhare/types/hash.ha | 6++----
Mscripts/gen-stdlib | 1+
Mstdlib.mk | 2++
6 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/hare/types/+aarch64/hash.ha b/hare/types/+aarch64/hash.ha @@ -0,0 +1,3 @@ +use hash; + +fn writesize(h: *hash::hash, u: size) void = write64(h, u); diff --git a/hare/types/+riscv64/hash.ha b/hare/types/+riscv64/hash.ha @@ -0,0 +1,3 @@ +use hash; + +fn writesize(h: *hash::hash, u: size) void = write64(h, u); diff --git a/hare/types/+x86_64/hash.ha b/hare/types/+x86_64/hash.ha @@ -0,0 +1,3 @@ +use hash; + +fn writesize(h: *hash::hash, u: size) void = write64(h, u); diff --git a/hare/types/hash.ha b/hare/types/hash.ha @@ -122,8 +122,7 @@ export fn hash(t: *_type) u32 = { }; case let a: array => write32(&id, hash(a.member)); - static assert(size(u64) == size(size)); // TODO - write64(&id, a.length); + writesize(&id, a.length); case builtin => void; case let e: _enum => write8(&id, builtin_storage(e.storage)); @@ -148,8 +147,7 @@ export fn hash(t: *_type) u32 = { const field = st.fields[i]; hash::write(&id, strings::toutf8(field.name)); write32(&id, hash(field._type)); - static assert(size(u64) == size(size)); // TODO - write64(&id, field.offs); + writesize(&id, field.offs); }; case let tu: tuple => for (let i = 0z; i < len(tu); i += 1) { diff --git a/scripts/gen-stdlib b/scripts/gen-stdlib @@ -712,6 +712,7 @@ hare_ast() { gensrcs_hare_types() { gen_srcs hare::types \ + '+$(ARCH)/hash.ha' \ arch.ha \ builtins.ha \ class.ha \ diff --git a/stdlib.mk b/stdlib.mk @@ -1338,6 +1338,7 @@ $(HARECACHE)/hare/parse/hare_parse-any.ssa: $(stdlib_hare_parse_any_srcs) $(stdl # hare::types (+any) stdlib_hare_types_any_srcs = \ + $(STDLIB)/hare/types/+$(ARCH)/hash.ha \ $(STDLIB)/hare/types/arch.ha \ $(STDLIB)/hare/types/builtins.ha \ $(STDLIB)/hare/types/class.ha \ @@ -3599,6 +3600,7 @@ $(TESTCACHE)/hare/parse/hare_parse-any.ssa: $(testlib_hare_parse_any_srcs) $(tes # hare::types (+any) testlib_hare_types_any_srcs = \ + $(STDLIB)/hare/types/+$(ARCH)/hash.ha \ $(STDLIB)/hare/types/arch.ha \ $(STDLIB)/hare/types/builtins.ha \ $(STDLIB)/hare/types/class.ha \