aboutsummaryrefslogtreecommitdiff
path: root/src/compiler.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/compiler.c')
-rw-r--r--src/compiler.c12
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) {