summaryrefslogtreecommitdiff
path: root/src/ast.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ast.c')
-rw-r--r--src/ast.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/ast.c b/src/ast.c
index 47d658d..e9aa677 100644
--- a/src/ast.c
+++ b/src/ast.c
@@ -72,6 +72,7 @@ ast_node_destroy(ast_node_t *node)
case AST_LITERAL:
case AST_UNKOWN_NODE:
case AST_VARIABLE:
+ case AST_FUNCTION_CALL:
break;
}
free(node);
@@ -276,6 +277,20 @@ ast_node_new_variable(ast_identifier_t *identifier, type_t result_type)
}
ast_node_t *
+ast_node_new_function_call(ast_identifier_t *identifier, type_t result_type)
+{
+ ast_node_t *node = ast_node_new();
+
+ *node = (ast_node_t){
+ .kind = AST_FUNCTION_CALL,
+ .result_type = result_type,
+ .data = { .function_call = { .identifier = identifier } },
+ };
+
+ return node;
+}
+
+ast_node_t *
ast_node_ns_get_function_node_by_sv(ast_node_t *ns, string_view_t name)
{
assert(ns->kind == AST_NAMESPACE);
@@ -296,6 +311,18 @@ ast_node_ns_get_function_node_by_name(ast_node_t *ns, char *function_name)
return ast_node_ns_get_function_node_by_sv(ns, string_view_from_str(function_name));
}
+bool
+ast_node_is_variable_declaration(ast_node_t *node)
+{
+ return node->kind == AST_VARIABLE_DECLARATION;
+}
+
+bool
+ast_node_is_function_declaration(ast_node_t *node)
+{
+ return node->kind == AST_FUNCTION_DECLARATION;
+}
+
char *
ast_type_to_str(type_t type)
{