diff options
author | Carlos Maniero <carlos@maniero.me> | 2023-05-10 16:53:05 -0300 |
---|---|---|
committer | Carlos Maniero <carlos@maniero.me> | 2023-05-10 19:23:52 -0300 |
commit | 3129b741064c2b4f2c6c2408bd42cc83f7341ea8 (patch) | |
tree | ec499cf238b266f963f8b6524b4b96190ccac9bf /src/ast.c | |
parent | 75639fbf01bd6ae1212521b6cf822025eb8b598d (diff) |
gas: Generate function call
This is an initial commit that enables function calls. At this point
only functions with no parameters is going to work.
Signed-off-by: Carlos Maniero <carlos@maniero.me>
Diffstat (limited to 'src/ast.c')
-rw-r--r-- | src/ast.c | 27 |
1 files changed, 27 insertions, 0 deletions
@@ -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) { |