diff options
author | dec05eba <dec05eba@protonmail.com> | 2019-03-23 16:16:59 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-07-25 14:36:46 +0200 |
commit | dc90305a767feaacc3430aaee0928b745a8e5b0f (patch) | |
tree | 6d85df4245a84820dfdf6425f0aa095a563cabbe /src/compiler.c | |
parent | 4f308829ad0e81a59971e172284c018cf2bdca3d (diff) |
Use ast pointers to fix resolving, remove try/throwing macros
Diffstat (limited to 'src/compiler.c')
-rw-r--r-- | src/compiler.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/compiler.c b/src/compiler.c index 50678d8..cc35d1e 100644 --- a/src/compiler.c +++ b/src/compiler.c @@ -41,7 +41,7 @@ static usize strnlen(const char *str, usize max_length) { static CHECK_RESULT int create_default_type(amal_compiler *compiler, const char *name) { StructDecl *struct_decl; LhsExpr *lhs_expr; - Ast expr; + Ast *expr; return_if_error(scoped_allocator_alloc(&compiler->allocator, sizeof(StructDecl), (void**)&struct_decl)); return_if_error(structdecl_init(struct_decl, &compiler->root_scope, &compiler->allocator)); @@ -50,11 +50,11 @@ static CHECK_RESULT int create_default_type(amal_compiler *compiler, const char return_if_error(lhsexpr_init(lhs_expr, bool_true, bool_true, create_buffer_view(name, strnlen(name, PATH_MAX)), NULL)); - ast_init(&lhs_expr->rhs_expr, struct_decl, AST_STRUCT_DECL); - ast_init(&expr, lhs_expr, AST_LHS); - expr.resolved_type = lhs_expr; - expr.resolve_status = AST_RESOLVED; - return scope_add_child(&compiler->root_scope, &expr); + return_if_error(ast_create(&compiler->allocator, struct_decl, AST_STRUCT_DECL, &lhs_expr->rhs_expr)); + return_if_error(ast_create(&compiler->allocator, lhs_expr, AST_LHS, &expr)); + expr->resolve_data.type = lhs_expr; + expr->resolve_data.status = AST_RESOLVED; + return scope_add_child(&compiler->root_scope, expr); } static CHECK_RESULT int init_default_types(amal_compiler *compiler) { |