summaryrefslogtreecommitdiff
path: root/src/ast.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ast.c')
-rw-r--r--src/ast.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/ast.c b/src/ast.c
index 1200e30..5790c05 100644
--- a/src/ast.c
+++ b/src/ast.c
@@ -47,6 +47,10 @@ ast_node_destroy(ast_node_t *node)
case AST_FUNCTION_DECLARATION:
ast_node_destroy(node->data.function.body);
break;
+ case AST_IF_STMT:
+ ast_node_destroy(node->data.if_stmt.condition);
+ ast_node_destroy(node->data.if_stmt.body);
+ break;
case AST_BLOCK:
ast_node_destroy_vector(node->data.block.body);
break;
@@ -140,6 +144,25 @@ ast_node_new_literal_integer(uint32_t number)
}
ast_node_t *
+ast_node_new_if_stmt(ast_node_t *condition, ast_node_t *body)
+{
+ ast_node_t *node = ast_node_new();
+
+ *node = (ast_node_t){
+ .kind = AST_IF_STMT,
+ .result_type = TYPE_VOID,
+ .data = {
+ .if_stmt = {
+ .condition = condition,
+ .body = body
+ },
+ },
+ };
+
+ return node;
+}
+
+ast_node_t *
ast_node_new_literal_bool(bool boolean)
{
ast_node_t *node = ast_node_new();