diff options
Diffstat (limited to 'package.c')
-rw-r--r-- | package.c | 24 |
1 files changed, 15 insertions, 9 deletions
@@ -199,7 +199,7 @@ static void exptr_start(Exporter *ex, const char *pkg_name, size_t pkg_name_len) } } -/* where = where was this imported */ +/* where = where was this imported. don't free fname while imported stuff is in use. */ static bool import_pkg(Allocator *allocr, Package *p, FILE *f, const char *fname, Identifiers *parent_idents, ErrCtx *parent_ctx, Location where) { Importer i = {0}; ErrCtx *err_ctx = &i.err_ctx; @@ -246,11 +246,18 @@ static bool import_pkg(Allocator *allocr, Package *p, FILE *f, const char *fname return false; fseek(f, decls_offset, SEEK_SET); /* read declarations */ + Statement *stmts = NULL; while (import_u8(&i)) { - import_decl(&i, arr_add(&i.decls)); + Statement *s = arr_add(&stmts); + s->kind = STMT_DECL; + import_decl(&i, &s->decl); } free(i.ident_map); + /* TOOD: LEAK! exit at some point */ + if (!block_enter(NULL, stmts, 0)) + return false; + return true; } @@ -960,14 +967,12 @@ static void import_decl(Importer *im, Declaration *d) { } if (d->flags & DECL_FOUND_VAL) { d->val = import_val(im, &d->type); - printf("TYPE: "); - print_type(&d->type); - printf("VALUE: "); - print_val(d->val, &d->type); + if (d->flags & DECL_HAS_EXPR) { + d->expr.kind = EXPR_VAL; + d->expr.val = d->val; + } } else if (d->flags & DECL_HAS_EXPR) { import_expr(im, &d->expr); - printf("EXPRESSION: "); - print_expr(&d->expr); } } @@ -1182,8 +1187,9 @@ static bool import_footer(Importer *im) { import_struct(im, s); import_arr(im, &im->fns); - arr_foreach(im->fns, FnExpr, f) + arr_foreach(im->fns, FnExpr, f) { import_fn(im, f); + } if (ferror(im->in)) { warn_print(im->import_location, "An error occured while reading the package. It may be incorrect."); |