annotate examples/c3/types.c3 @ 381:6df89163e114

Fix section and ldr pseudo instruction
author Windel Bouwman
date Sat, 26 Apr 2014 17:41:56 +0200
parents 158068af716c
children
rev   line source
237
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
1
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
2 /*
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
3 Demo of how to define types
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
4 */
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
5
286
d9df72971cbf Changed package to module
Windel Bouwman
parents: 284
diff changeset
6 module typedemo;
237
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
7
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
8 type int A;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
9 type int B;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
10 type struct {
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
11 int x, y;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
12 A z;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
13 } C;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
14 type struct {
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
15 C x;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
16 B y;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
17 int z;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
18 } D;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
19
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
20 type D* E;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
21
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
22 function int testcast()
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
23 {
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
24 var A a;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
25 var B b;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
26 a = 3;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
27 b = a;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
28 var C c;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
29 c.x = a;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
30 c.z = c.y;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
31 var D d;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
32 var E e;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
33 var D* e2;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
34 e = &d;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
35 e2 = e;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
36 e2->x.x = 22;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
37
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
38 return 0;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
39 }
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
40