summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2020-03-03 17:19:25 -0500
committerLeo Tenenbaum <pommicket@gmail.com>2020-03-03 17:19:25 -0500
commitabbd3d0e252d3694edb151ad2b5010cc2c5c4736 (patch)
tree536bac186cd5c354a17a090ef1ae9dea7cc47fe0
parentbb350dd63ae972e5e3513357d1a949b9e369b06a (diff)
fixed array argument bug
-rw-r--r--cgen.c2
-rw-r--r--parse.c4
-rw-r--r--test.toc12
3 files changed, 4 insertions, 14 deletions
diff --git a/cgen.c b/cgen.c
index a3903a8..36fdddd 100644
--- a/cgen.c
+++ b/cgen.c
@@ -486,7 +486,6 @@ static inline void cgen_arg_pre(CGenerator *g, Expression *arg) {
if (arg->type.kind == TYPE_ARR) {
/* create copy of array */
IdentID copy = ++g->ident_counter;
- arg->cgen.id = copy;
cgen_type_pre(g, &arg->type);
char s[CGEN_IDENT_ID_STR_SIZE];
cgen_ident_id_to_str(s, copy);
@@ -495,6 +494,7 @@ static inline void cgen_arg_pre(CGenerator *g, Expression *arg) {
cgen_type_post(g, &arg->type);
cgen_write(g, "; ");
cgen_set(g, NULL, s, arg, NULL);
+ arg->cgen.id = copy;
}
}
diff --git a/parse.c b/parse.c
index 39a3863..6a0ab41 100644
--- a/parse.c
+++ b/parse.c
@@ -405,14 +405,14 @@ static Token *expr_find_end(Parser *p, ExprEndFlags flags) {
}
if (token->kind == TOKEN_EOF) {
if (brace_level > 0) {
- tokr_err(t, "Opening brace { was never closed."); /* FEATURE: Find out where this is */
+ tokr_err(t, "Opening brace { was never closed."); /* TODO: Find out where this is */
} else if (paren_level > 0) {
tokr_err(t, "Opening parenthesis ( was never closed.");
} else if (square_level > 0) {
tokr_err(t, "Opening square bracket [ was never closed.");
} else {
tokr_err(t, "Could not find end of expression (did you forget a semicolon?).");
- /* FEATURE: improve err message */
+ /* TODO: ? improve err message */
}
t->token = token; /* don't try to continue */
return NULL;
diff --git a/test.toc b/test.toc
index d66972f..b4f3632 100644
--- a/test.toc
+++ b/test.toc
@@ -1,5 +1,3 @@
-#include "io.toc", io;
-
arr_sum ::= fn(n::=, t::=, a:[n]t) t {
total := 0 as t;
for x := a {
@@ -15,13 +13,5 @@ mk_arr ::= fn(x:int, y:int, z:int) a:[3]int {
};
main ::= fn() {
- x ::= 3;
- #if x > 2 {
- io.puts("Hello!");
- } else {
- foo("yes");
- }
- io.puti(arr_sum(mk_arr(5,89,22)));
- io.puti(arr_sum(mk_arr(1,2,3)));
- io.puti(arr_sum(mk_arr(z=0, 0, 0)));
+ arr_sum(mk_arr(1,2,3));
}; \ No newline at end of file