diff options
Diffstat (limited to 'src/ast.c')
-rw-r--r-- | src/ast.c | 24 |
1 files changed, 22 insertions, 2 deletions
@@ -45,7 +45,10 @@ ast_node_destroy(ast_node_t *node) { switch (node->kind) { case AST_FUNCTION_DECLARATION: - ast_node_destroy_vector(node->data.function.body); + ast_node_destroy(node->data.function.body); + break; + case AST_BLOCK: + ast_node_destroy_vector(node->data.block.body); break; case AST_BINARY_OPERATION: ast_node_destroy(node->data.binary_operation.left); @@ -82,7 +85,7 @@ ast_node_new_return_stmt(ast_node_t *argument) } ast_node_t * -ast_node_new_function_declaration(string_view_t function_name, type_t return_type, vector_t *body) +ast_node_new_function_declaration(string_view_t function_name, type_t return_type, ast_node_t *body) { ast_node_t *node = ast_node_new(); @@ -101,6 +104,23 @@ ast_node_new_function_declaration(string_view_t function_name, type_t return_typ } ast_node_t * +ast_node_new_block(vector_t *body) +{ + ast_node_t *node = ast_node_new(); + + *node = (ast_node_t){ + .kind = AST_BLOCK, + .data = { + .block = { + .body = body, + } + }, + }; + + return node; +} + +ast_node_t * ast_node_new_literal_integer(uint32_t number) { ast_node_t *node = ast_node_new(); |