-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathassigned
More file actions
68 lines (61 loc) · 1.25 KB
/
assigned
File metadata and controls
68 lines (61 loc) · 1.25 KB
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
@extern func print_integer(anon x: uint64);
@extern func putchar(c: char);
func fibonacci(count: uint64) {
mut a = 0; // set to const for error
mut b = 1;
mut i = 0;
'loop:
i = i + 1;
print_integer(*&const a);
putchar(' ');
const c = a + *&const b;
a = b;
b = c;
if (*&const i < *&const count) goto 'loop;
}
/*
func skip_vardecl() {
goto 'next;
'skip:
const a: uint8;
'next:
a = 3;
const q = a;
}
*/
struct Test { field: bool }
struct Jest { field: uint8; test: Test }
/*
func refs() {
const my_immutable = 3;
const mutable = &mut my_immutable;
const struct = Jest { field: 8, test: Test { field: false } };
const another = &mut struct.test.field;
mut actual = Test { field: false };
const cant = &mut *&const actual.field;
const cant = &mut (*&const actual).field;
}
*/
func move() {
const a = 3;
const b = a;
const q = a;
}
@extern
func print_bool(anon _: bool);
@extern
func main() {
const a: uint8 = 3;
const b = undefined;
b = 4;
const test = Test { field: false };
print_bool(*&const test.field);
mut jest = Jest { field: 32, test: test };
print_bool(jest.test.field);
jest.field = 64;
jest.test.field = true;
print_bool(jest.test.field);
jest.test.field = false;
(*&const jest.test).field = true;
print_bool(jest.test.field);
}