From 9f034b4ebfe15844ea610ec2dd2fca1a9f7ce338 Mon Sep 17 00:00:00 2001 From: Carlos Maniero Date: Sat, 29 Apr 2023 15:55:39 -0300 Subject: ast: Introduce ast_identifier_t for named ast nodes Prior to this change, ast_variable_declaration_t and ast_function_declaration_t used a string_view as an identifier. However, to support scoped identifiers, it is more appropriate to use an ast_identifier_t as a reference. Signed-off-by: Carlos Maniero Co-authored-by: Johnny Richard --- src/ast.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/ast.c') diff --git a/src/ast.c b/src/ast.c index b2ce1bb..7bad020 100644 --- a/src/ast.c +++ b/src/ast.c @@ -77,10 +77,12 @@ ast_node_init_return_stmt(ast_node_t *node, ast_node_t *argument) } void -ast_node_init_function_declaration(ast_node_t *node, string_view_t name, type_t return_type, vector_t *body) +ast_node_init_function_declaration(ast_node_t *node, string_view_t function_name, type_t return_type, vector_t *body) { node->kind = AST_FUNCTION_DECLARATION; - node->data = (ast_node_data_t){ .function = { .name = name, .return_type = return_type, .body = body } }; + node->data = (ast_node_data_t){ + .function = { .identifier = { .name = function_name }, .return_type = return_type, .body = body } + }; } void @@ -101,7 +103,8 @@ void ast_node_init_variable_declaration(ast_node_t *node, string_view_t variable_name, type_t type, ast_node_t *value) { node->kind = AST_VARIABLE_DECLARATION; - node->data = (ast_node_data_t){ .variable = { .name = variable_name, .type = type, .value = value } }; + node->data = + (ast_node_data_t){ .variable = { .identifier = { .name = variable_name }, .type = type, .value = value } }; } void -- cgit v1.2.3