summaryrefslogtreecommitdiff
path: root/test.toc
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2020-05-13 11:59:35 -0400
committerLeo Tenenbaum <pommicket@gmail.com>2020-05-13 11:59:35 -0400
commit2804529f75b149b579eb0f724358d519935ff08a (patch)
tree53d5826a4bdc7ee412ee4d1b045b92d07cb474e4 /test.toc
parentc466d81a2423d7122d7a0cbdc8059e69e88899f2 (diff)
fixed some problems with cgen_recurse_stuff
Diffstat (limited to 'test.toc')
-rw-r--r--test.toc74
1 files changed, 65 insertions, 9 deletions
diff --git a/test.toc b/test.toc
index 53a092c..af1c2fd 100644
--- a/test.toc
+++ b/test.toc
@@ -1,14 +1,70 @@
-Point ::= struct {
- #if 1 {
- #include "point.toc";
- } else {
- z: int;
+#include "tests/std/io.toc", io;
+#include "std/mem.toc";
+
+
+z ::= nms {
+ Foo ::= struct(f ::= fn() int { 7 }) {
+ x: int;
+ }
+
+ Bar ::= fn() &(struct { x, y: int; f ::= fn() int { 13 } } ) {
+ x : u64;
+ &x as &void
+ }
+
+
+ foo ::= fn() total : int = 0 {
+ f: Foo();
+ total += f.f();
+ total += Bar().f();
}
}
main ::= fn() {
- p : Point;
- p.x;
- p.y;
- p.z;
+ nums := news(int, 10);
+ for x, i := &nums {
+ *x = i*i;
+ }
+ l := slice_to_ll(nums);
+ p := &l;
+ while p {
+ io.puti(p.head);
+ p = p.tail;
+ }
+ f: Foo;
+ f.k = -173;
+ f.b = new(Bar);
+ f.b.f.b = new(Bar);
+ f.b.f.b.f.k = 9;
+ io.puti(f.k);
+ io.puti(f.b.f.k);
+ io.puti(f.b.f.b.f.k);
+ x := z.foo();
+ y ::= z.foo();
+ io.puti(x);
+ io.puti(y);
+}
+
+slice_to_ll ::= fn(t::=, slice: []t) use ll: LinkedList(t) {
+ head = slice[0];
+ if slice.len == 1 {
+ tail = null;
+ } else {
+ tail = new(LinkedList(t));
+ *tail = slice_to_ll(slice[1:]);
+ }
+}
+
+LinkedList ::= struct (of :: Type) {
+ head: of;
+ tail: &LinkedList(of);
+}
+
+Foo ::= struct {
+ k: int;
+ b: &Bar;
+}
+
+Bar ::= struct {
+ f: Foo;
}