diff options
author | Leo Tenenbaum <pommicket@gmail.com> | 2020-03-03 17:19:25 -0500 |
---|---|---|
committer | Leo Tenenbaum <pommicket@gmail.com> | 2020-03-03 17:19:25 -0500 |
commit | abbd3d0e252d3694edb151ad2b5010cc2c5c4736 (patch) | |
tree | 536bac186cd5c354a17a090ef1ae9dea7cc47fe0 | |
parent | bb350dd63ae972e5e3513357d1a949b9e369b06a (diff) |
fixed array argument bug
-rw-r--r-- | cgen.c | 2 | ||||
-rw-r--r-- | parse.c | 4 | ||||
-rw-r--r-- | test.toc | 12 |
3 files changed, 4 insertions, 14 deletions
@@ -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; } } @@ -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; @@ -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 |