refactor(ast): one file per ast_type -- FINISHED
This commit is contained in:
parent
38f5a35885
commit
30df2993ee
10 changed files with 85 additions and 51 deletions
|
|
@ -1,16 +1,33 @@
|
|||
#include "utils/ast/ast.h"
|
||||
|
||||
struct ast *ast_create_list(struct list *ast_list);
|
||||
struct ast *ast_create_list(struct list *list)
|
||||
{
|
||||
struct ast_list *ast_list = malloc(sizeof(struct ast_list));
|
||||
if (ast_list == NULL)
|
||||
return NULL;
|
||||
|
||||
struct ast_list *ast_get_list(struct ast *node);
|
||||
ast_list->list = list;
|
||||
|
||||
return ast_create(AST_LIST, ast_list);
|
||||
}
|
||||
|
||||
struct ast_list *ast_get_list(struct ast *node)
|
||||
{
|
||||
assert(node != NULL);
|
||||
return (struct ast_list*)node->data;
|
||||
}
|
||||
|
||||
bool ast_is_list(struct ast *node)
|
||||
|
||||
void ast_free_list(struct ast_list *ast_list)
|
||||
{
|
||||
if (ast_list == NULL)
|
||||
return node->type == AST_LIST;
|
||||
}
|
||||
|
||||
void ast_free_list(struct ast_list **ast_list)
|
||||
{
|
||||
if (*ast_list == NULL || ast_list == NULL)
|
||||
return;
|
||||
|
||||
list_deep_destroy(ast_list->children);
|
||||
free(ast_list);
|
||||
list_deep_destroy((*ast_list)->children);
|
||||
free(*ast_list);
|
||||
*ast_list = NULL;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue