codebased/scirpt/ast.c
2023-04-14 02:17:45 +02:00

34 lines
820 B
C

#include "scirpt/ast.h"
#include <stdlib.h>
void scirpt_ast_expr_delete(ScirptAstExpr* expr)
{
switch (expr->type) {
case ScirptAstExprTypeEof:
break;
case ScirptAstExprTypeError:
break;
case ScirptAstExprTypeId:
heapstring_destroy(&expr->id_value);
break;
case ScirptAstExprTypeInt:
break;
case ScirptAstExprTypeString:
heapstring_destroy(&expr->string_value);
break;
case ScirptAstExprTypeBool:
break;
case ScirptAstExprTypeNull:
break;
case ScirptAstExprTypeBlock:
scirpt_ast_expr_array_destroy(&expr->block.statements);
scirpt_ast_expr_delete(expr->block.value);
break;
case ScirptAstExprTypeIf:
scirpt_ast_expr_delete(expr->if_expr.condition);
scirpt_ast_expr_delete(expr->if_expr.truthy);
scirpt_ast_expr_delete(expr->if_expr.falsy);
break;
}
}