summaryrefslogtreecommitdiff
path: root/ast.c
diff options
context:
space:
mode:
authorCarson Fleming <cflems@cflems.net>2026-07-17 03:20:34 -0700
committerCarson Fleming <cflems@cflems.net>2026-07-17 03:20:34 -0700
commit155d1971b7cd56d3206808c36c6b40357bc31cbb (patch)
treeb06b4c59d7eaa8084985b82e73b975d194eb8929 /ast.c
parent99af8891f6672493939bf3b43084082884e28d04 (diff)
downloadccc-155d1971b7cd56d3206808c36c6b40357bc31cbb.tar.gz
almost fibonacci but it needs the type checker
Diffstat (limited to 'ast.c')
-rw-r--r--ast.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/ast.c b/ast.c
index 44401cb..24a37cf 100644
--- a/ast.c
+++ b/ast.c
@@ -133,6 +133,17 @@ static void expr_destroy(struct expr_node* node) {
}
}
+static void if_destroy(struct if_node* node) {
+ expr_destroy(node->cond);
+ free(node->cond);
+ stmt_destroy(node->true_branch);
+ free(node->true_branch);
+ if (node->false_branch != NULL) {
+ stmt_destroy(node->false_branch);
+ free(node->false_branch);
+ }
+}
+
static void stmt_destroy(struct stmt_node* node) {
switch (node->type) {
case STMT_EMPTY:
@@ -148,6 +159,10 @@ static void stmt_destroy(struct stmt_node* node) {
break;
case STMT_GROUP:
group_destroy(&node->inner.group);
+ break;
+ case STMT_IF:
+ if_destroy(&node->inner.if_);
+ break;
}
}