summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cgen.c9
-rw-r--r--main.c1
-rw-r--r--out.c8
-rw-r--r--test.toc1
4 files changed, 17 insertions, 2 deletions
diff --git a/cgen.c b/cgen.c
index 615a3f0..4e6bcfc 100644
--- a/cgen.c
+++ b/cgen.c
@@ -179,7 +179,14 @@ static bool cgen_type_post(CGenerator *g, Type *t, Location where) {
return false;
break;
case TYPE_ARR:
- cgen_write(g, "[%lu])", (unsigned long)t->arr.n);
+ if (t->flags & TYPE_FLAG_RESOLVED)
+ cgen_write(g, "[%lu])", (unsigned long)t->arr.n);
+ else {
+ cgen_write(g, "[");
+ if (!cgen_expr(g, t->arr.n_expr))
+ return false;
+ cgen_write(g, "]");
+ }
if (!cgen_type_post(g, t->arr.of, where))
return false;
break;
diff --git a/main.c b/main.c
index f77e948..dfef286 100644
--- a/main.c
+++ b/main.c
@@ -1,5 +1,6 @@
/*
TODO:
+slices
new run-time type resolution
unicode variable names
make sure initializers for global variables are compile-time constants
diff --git a/out.c b/out.c
index 5fda332..4d1f4e1 100644
--- a/out.c
+++ b/out.c
@@ -49,6 +49,14 @@ void main__(void) {
a2_ = y;
}(puti(a2_));
};
+ i64( asdf[78636112]); {
+ i64( expr__[78636112]); {
+ size_t i;i64(*arr__in) = expr__; i64(*arr__out) = ((i64([78636112]))calloc(1, sizeof(i64([100])));
+ for (i = 0; i < 78636112; i++) arr__out[i] = arr__in[i];
+ }{
+ size_t i;i64(*arr__in) = asdf; i64(*arr__out) = expr__;
+ for (i = 0; i < 78636112; i++) arr__out[i] = arr__in[i];
+ }}
}}
diff --git a/test.toc b/test.toc
index d755af5..abb1623 100644
--- a/test.toc
+++ b/test.toc
@@ -13,5 +13,4 @@ main @= fn() {
while y < 10 {
puti({y = y + 1; y});
}
-
}; \ No newline at end of file