-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest1.do
68 lines (60 loc) · 1.06 KB
/
test1.do
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
// TODO Why is this an i32?
n :: 1 + sizeof(p);
p : *T;
T :: struct
{
a: [n] int;
}
r := &tmp.a;
tmp: T;
s: [n+m]int = { 0, 1, 2 };
m :: sizeof(tmp.a);
sum := n + m;
q := ∑
sx :: sizeof(x);
x: R;
R :: struct
{
s: *S;
}
S :: struct
{
r: [sx] R;
}
// TODO Do we want to just ignore these?
//;
U :: struct
{
a: [3] int;
}
uu: U = { .a = { 0 } };
a, b, c :: 0;
//b := 1; // Redeclared
add :: (v: Vector, w: Vector) -> Vector { return { .x = v.x + w.x, .y = v.y + w.y }; }
vecResult := add_func( { .x = 1, .y = 2 }, { .x = 3, .y = 4 } );
add_func := add;
Vector :: struct { x, y: int; }
// TODO Check this actually works for all cond types
three := 1 ? 2 : 3;
ptr := &s[1 + 1];
// TODO Do we want to disallow indexing pointers (unchecked) so it feels less safe than indexing arrays (always checked)?
ptrItem := ptr - 1;
bin := 1000 / (2 + 3 * 5) << 10;
aptr: *int = <*int> &s[3];
f :: ()
{
sum += 1;
}
h :: (y: int) -> int
{
if(y)
{
return -y;
}
else
{
return 1;
}
}
main :: ()
{}