aboutsummaryrefslogtreecommitdiff
path: root/bootstrap/test2.cff
blob: c0fafc524e6e20c2ea5ce4f635d172fd1efa0da7 (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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import "libc.hff";

struct Node<T> {
   link *Node,
   value T,

   fn ok(self Node) void {
   }
}

def X = 7 + 2;

struct Bit<T> {
   def Z = 3;
   fn foo(x T) T { return (~x ^ Z) + X; }
   !fn foo(x T) T { return ~x + Y; }
}

def Y = 3.3;

enum union Value {
   None,
   Int i32,
   Flo f32,
}

extern fn main() void {
   let n Node<int> = {#null, 0};
   let n Node<int> = {&n, 1};

   let x int #?;
   x = X + 1 + Y;

   let v= Value:None;
   v = :Int 3;
   switch (v) {
   case None;
   case Int i;
      i;
   case Flo *f;
      *f += 1.0f;
   }

   printf("n %d\n", n.value);
   printf("n link %d\n", n.link.value);

   let x Node<f32> = {};
   n->ok();
   x->ok();

   Bit<i32>:foo(3);
   Bit<i64>:foo(3);
}