aboutsummaryrefslogtreecommitdiff
path: root/src/type.cff
blob: a3c7021d0ab97a2eb35680875c3a972966d5301c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import "cffc.hff";
import "util.hff";

fn hashtype(ty *const Type) u32 {
   let h = FNV1A_INI;
   h = fnv1a_i(h, ty.konst ? 1 : 0);

   switch ty.u {
   case Void; case Bool;

   case Flo;
      h = fnv1a_i(h, ty.size);
      h = fnv1a_i(h, ty.align);

   case Int i;
      h = fnv1a_i(h, i.sgn ? 1 : 0);
      h = fnv1a_i(h, ty.size);
      h = fnv1a_i(h, ty.align);

   case Ptr child;
      h = fnv1a_i(h, child.id);

   case Arr arr;
      h = fnv1a_i(h, arr.child.id);
      h = fnv1a_i(h, arr.length);

   case Slice child;
      h = fnv1a_i(h, child.id);

   }
   return h;
}