From c1a1bd2320b4c1508c4ab20d23b7c193a94d8026 Mon Sep 17 00:00:00 2001 From: Carlos Maniero Date: Tue, 25 Apr 2023 03:52:59 -0300 Subject: parser: Add support for variables and identifiers in function body This commit adds support for variables and identifiers in the function body of the parser, stored as a vector. However, at this point, identifier resolution is not fully implemented, and we currently accept identifiers without checking if they can be resolved. This is a known limitation that will be addressed in a future commit once hash-tables are added to the parser. Signed-off-by: Carlos Maniero Reviewed-by: Johnny Richard --- src/gas_assembly_generator.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/gas_assembly_generator.c') diff --git a/src/gas_assembly_generator.c b/src/gas_assembly_generator.c index 10a67f3..5572cb7 100644 --- a/src/gas_assembly_generator.c +++ b/src/gas_assembly_generator.c @@ -54,7 +54,9 @@ gas_assembly_generator_visit_function(ast_visitor_t *visitor, ast_function_decla fprintf(gen->out,".text\n"); fprintf(gen->out,"_start:\n"); - ast_visitor_visit(visitor, func->body); + for (size_t i=0; i < func->body->size; i++) { + ast_visitor_visit(visitor, vector_at(func->body, i)); + } } static void -- cgit v1.2.3