diff examples/c3/types.c3 @ 300:158068af716c

yafm
author Windel Bouwman
date Tue, 03 Dec 2013 18:00:22 +0100
parents test/c3examples/types.c3@d9df72971cbf
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/c3/types.c3	Tue Dec 03 18:00:22 2013 +0100
@@ -0,0 +1,40 @@
+
+/*
+ Demo of how to define types
+*/
+
+module typedemo;
+
+type int A;
+type int B;
+type struct {
+  int x, y;
+  A z;
+} C;
+type struct {
+  C x;
+  B y;
+  int z;
+} D;
+
+type D* E;
+
+function int testcast()
+{
+    var A a;
+    var B b;
+    a = 3;
+    b = a;
+    var C c;
+    c.x = a;
+    c.z = c.y;
+    var D d;
+    var E e;
+    var D* e2;
+    e = &d;
+    e2 = e;
+    e2->x.x = 22;
+    
+    return 0;
+}
+