From dc90305a767feaacc3430aaee0928b745a8e5b0f Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sat, 23 Mar 2019 16:16:59 +0100 Subject: Use ast pointers to fix resolving, remove try/throwing macros --- src/compiler.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/compiler.c') 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) { -- cgit v1.2.3