2026-01-17 17:33:22 +01:00
|
|
|
#include "utils/ast/ast_and_or.h"
|
2026-01-17 19:11:55 +01:00
|
|
|
|
2026-01-17 17:33:22 +01:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
|
|
bool ast_is_and_or(struct ast *node)
|
|
|
|
|
{
|
|
|
|
|
return node != NULL && node->type == AST_AND_OR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct ast_and_or *ast_get_and_or(struct ast *node)
|
|
|
|
|
{
|
|
|
|
|
if (ast_is_and_or(node))
|
|
|
|
|
return (struct ast_and_or *)node->data;
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-17 19:11:55 +01:00
|
|
|
struct ast *ast_create_and_or(struct ast *left, struct ast *right,
|
|
|
|
|
enum ast_and_or_type type)
|
2026-01-17 17:33:22 +01:00
|
|
|
{
|
|
|
|
|
struct ast_and_or *and_or = malloc(sizeof(struct ast_and_or));
|
|
|
|
|
if (!and_or)
|
|
|
|
|
return NULL;
|
|
|
|
|
and_or->left = left;
|
|
|
|
|
and_or->right = right;
|
|
|
|
|
and_or->type = type;
|
|
|
|
|
|
|
|
|
|
return ast_create(AST_AND_OR, and_or);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ast_free_and_or(struct ast_and_or *and_or)
|
|
|
|
|
{
|
|
|
|
|
if (!and_or)
|
|
|
|
|
return;
|
|
|
|
|
ast_free(&and_or->left);
|
|
|
|
|
ast_free(&and_or->right);
|
|
|
|
|
free(and_or);
|
|
|
|
|
}
|