aboutsummaryrefslogtreecommitdiff
path: root/src/type.cff
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2022-08-19 20:09:54 +0200
committerlemon <lsof@mailbox.org>2022-08-19 20:09:54 +0200
commita136923427d52644a705c50585294035536677df (patch)
tree9464d5a5b691482a6dcb6020eaca3d4155898206 /src/type.cff
parent1391927ab44c40d45ee7825a4ce0a5d2b8394d72 (diff)
more miscellaneous fixes
Diffstat (limited to 'src/type.cff')
-rw-r--r--src/type.cff13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/type.cff b/src/type.cff
index dd59517..ddb4cd8 100644
--- a/src/type.cff
+++ b/src/type.cff
@@ -7,7 +7,7 @@ struct TypeTraits {
fn hash(ty *const Type) u32 {
let h = FNV1A_INI;
h = fnv1a_i(h, as(int)ty.u.#tag);
- h = fnv1a_i(h, ty.konst ? 1 : 0);
+ h *= as(int)ty.konst + 2;
switch ty.u {
case Void;
@@ -49,15 +49,18 @@ struct TypeTraits {
}
fn eq(a *const Type, b *const Type) bool {
- if a.u.#tag != b.u.#tag or a.size != b.size
- or a.align != b.align or a.konst != b.konst {
+ if a.u.#tag != b.u.#tag or a.konst != b.konst {
return #f;
}
switch a.u {
- case Void; case Bool; case Flo;
+ case Void;
+ case Bool;
+ return a.size == b.size;
+ case Flo;
+ return a.size == b.size;
case Int i;
- return i.sgn == b.u.Int.sgn;
+ return a.size == b.size and i.sgn == b.u.Int.sgn;
case Ptr child;
return child == b.u.Ptr;