diff options
author | Leo Tenenbaum <pommicket@gmail.com> | 2019-10-31 17:54:29 -0400 |
---|---|---|
committer | Leo Tenenbaum <pommicket@gmail.com> | 2019-10-31 18:02:32 -0400 |
commit | 11c93eafd9b19546a1190a7cf8c9d5bf70a56e58 (patch) | |
tree | d9fd3169b8347871f9aab42e187fde5406354846 /cgen.c | |
parent | 9e55cdb1ea5cd8318a1a0b7a9f64f09e8d8ad692 (diff) |
discovered a bug where stuff isn't typed before being eval'd. trying to fix it.
Diffstat (limited to 'cgen.c')
-rw-r--r-- | cgen.c | 19 |
1 files changed, 4 insertions, 15 deletions
@@ -117,12 +117,7 @@ static void cgen_ident(CGenerator *g, Identifier i) { cgen_write(g, "main__"); } else { cgen_indent(g); - IdentDecl *idecl = ident_decl(i); - if (idecl && (idecl->flags & IDECL_FLAG_CGEN_PTR)) - cgen_write(g, "(*"); fprint_ident(cgen_writing_to(g), i); - if (idecl && (idecl->flags & IDECL_FLAG_CGEN_PTR)) - cgen_write(g, ")"); } } @@ -307,21 +302,17 @@ static bool cgen_fn_header(CGenerator *g, FnExpr *f, Location where) { } cgen_write(g, "("); arr_foreach(f->params, Declaration, d) { + long idx = 0; arr_foreach(d->idents, Identifier, i) { if (d != f->params || i != d->idents) cgen_write(g, ", "); + Type *type = d->type.kind == TYPE_TUPLE ? &d->type.tuple[idx++] : &d->type; any_params = true; - if (!cgen_type_pre(g, &d->type, where)) + if (!cgen_type_pre(g, type, where)) return false; cgen_write(g, " "); - bool ptr = cgen_uses_ptr(&d->type); - if (ptr) { - IdentDecl *idecl = ident_decl(*i); - assert(idecl); - idecl->flags |= IDECL_FLAG_CGEN_PTR; - } cgen_ident(g, *i); - if (!cgen_type_post(g, &d->type, where)) + if (!cgen_type_post(g, type, where)) return false; } } @@ -469,8 +460,6 @@ static bool cgen_set_tuple(CGenerator *g, Expression *exprs, Identifier *idents, arr_foreach(to->call.arg_exprs, Expression, arg) { if (arg != to->call.arg_exprs) cgen_write(g, ", "); - if (cgen_uses_ptr(&arg->type)) - cgen_write(g, "&"); if (!cgen_expr(g, arg)) return false; } |