From 7a966d25b34f4bd37f32a18f7e8a62b6f97186e6 Mon Sep 17 00:00:00 2001 From: pacien Date: Tue, 5 Jun 2018 13:07:41 +0200 Subject: Handle function call --- src/generator.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/generator.c b/src/generator.c index 0e79c07..7a960bf 100644 --- a/src/generator.c +++ b/src/generator.c @@ -100,9 +100,12 @@ void gen_function_declaration(const char name[], int return_type, void gen_function_end_declaration() { fprintf(output, "mov rsp, rbp\npop rbp\nret\n"); } + int gen_function_call(const char name[], int nb_param) { + Type return_type = fun_lookup(name, nb_param); fprintf(output, "call %s\n", name); - return fun_lookup(name, nb_param); + if (return_type != VOID) fprintf(output, "push rax\n"); + return return_type; } void gen_declaration(const char name[], int type, Scope scope) { -- cgit v1.2.3