summaryrefslogtreecommitdiff
path: root/tests/use.toc
blob: ec062c25524fdbcd102793c79d9bf924100b82c0 (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
#include "std/io.toc", io;
#include "std/mem.toc", mem;

use mem;

Point ::= struct {	
	x: int;
	y: int;
	a ::= 3;
}

Point3D ::= struct {
	use point: Point;
	z: int;

}

Point4D ::= struct {
	use p3: Point3D;
	w: int;
}

Foo ::= struct {
	f: f32;
}

Bar ::= struct {
	use foo: Foo;
	use p4: Point4D;
}



make_point ::= fn (x_: int, y_: int) use p: Point {
	x = x_+a;
	y = y_+a;
}

make_bar ::= fn (x_ := 0, y_ := 0, z_ := 0, w_ := 0, f_ := 0.0) use b: Bar {
	x = x_;
	y = y_;
	z = z_;
	b.p4.w = w_;
	b.f = f_;
}

main ::= fn() {

	use io;

	{
		use p: Point;
		use io;
		x = 5;
		puti(x);
	}



	ps := news(Point, 5);
	for p := &ps {
		*p = make_point(3, 5);
	}
	for use p, i := &ps {
		x += i;
		y += 2*i;
	}
	for use p := ps {
		writei(x);
		writes(" ");
		writei(y);
		puts("");
	}
	dels(ps);
	b := make_bar(5, 8, 13, 12);
	puti(b.x);
	puti(b.y);
	puti(b.z);
	puti(b.w);

}