summaryrefslogtreecommitdiff
path: root/test.toc
blob: 1d21ead97ecc38e6598ca3e34e81ec36d69f7f00 (plain)
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#include "std/io.toc";

main ::= fn() {
	a : [5]int;
	for i ::= 1..10 {
		a : [i]int;
		a[0] = 7;
		for j ::= 0.,i {
			puti(a[j]);
		}
	}
}
main();



/*
#include "std/io.toc", io;
#include "std/types.toc";

print_type ::= fn(t :: Type) {
	k ::= t._kind;
	use TypeKind;
	#if k == UNKNOWN {
		io.puts("???");
	} elif k == BUILTIN {
		b ::= t._builtin;
		use BuiltinType;
		#if b == I8 {
			io.puts("i8");
		} elif b == U8 {
			io.puts("u8");
		} elif b == I16 {
			io.puts("i16");
		} elif b == U16 {
			io.puts("u16");
		} elif b == I32 {
			io.puts("i32");
		} elif b == U32 {
			io.puts("u32");
		} elif b == I64 {
			io.puts("i64");
		} elif b == U64 {
			io.puts("u64");
		} elif b == F32 {
			io.puts("f32");
		} elif b == F64 {
			io.puts("f64");
		} elif b == CHAR {
			io.puts("char");
		} elif b == BOOL {
			io.puts("bool");
		} elif b == TYPE {
			io.puts("Type");
		} elif b == VARARGS {
			io.puts("..");
		} elif b == NMS {
			io.puts("Namespace");
		} elif b == VOID {
			io.puts("void");
		} else {
			io.puts("<unknown builtin type>");
		}
	} elif k == FN {
		// @TODO
	} elif k == TUPLE {
		// @TODO
	} elif k == ARR {
		io.writes("[");
		io.writei(t._n);
		io.writes("]");
		print_type(t._of);
	} elif k == PTR {
		io.writes("&");
		print_type(t._of);
	} elif k == SLICE {
		io.writes("[]");
		print_type(t._of);
	} elif k == EXPR {
		io.puts("<type expression>");
	} elif k == STRUCT {
		// @TODO
	} else {
		io.puts("<unknown type kind>");
	}
}

print_typeof ::= fn (t ::=, x : t) {
	print_type(t);
}

main ::= fn() {
	foo0 := int == int;
	bar0 := int == float;
	foo1 := &&&int == &&&u8;
	bar1 := &&&int != &&&int;
	io.putb(foo0);
	io.putb(bar0);
	io.putb(foo1);
	io.putb(bar1);

	x ::= 4 as u64;
	y := 7.3432;
	z := "foo";
	w := &z;
	t : [x*x]int;
	u := &t;
	v : &void;

	print_typeof(x);
	print_typeof(y);
	print_typeof(z);
	print_typeof(w);
	print_typeof(t);
	print_typeof(u);
	print_typeof(v);
}
main();
*/