From 13b4fc0a1e32008f125f73148d01f12bdac3a80e Mon Sep 17 00:00:00 2001 From: pacien Date: Tue, 5 Jun 2018 14:35:02 +0200 Subject: Simplify return type state on call --- src/generator.c | 2 +- src/generator.h | 2 +- src/tpc.y | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/generator.c b/src/generator.c index d5df545..126d2b1 100644 --- a/src/generator.c +++ b/src/generator.c @@ -110,7 +110,7 @@ void gen_function_return(Type expect, Type actual) { gen_function_end_declaration(); } -int gen_function_call(const char name[], int nb_param) { +Type gen_function_call(const char name[], int nb_param) { Type return_type = fun_lookup(name, nb_param); fprintf(output, "call %s\n", name); if (return_type != VOID_T) fprintf(output, "push rax\n"); diff --git a/src/generator.h b/src/generator.h index 1f586c1..082e359 100644 --- a/src/generator.h +++ b/src/generator.h @@ -24,7 +24,7 @@ void gen_const_declaration(); Type gen_function_declaration(const char name[], int return_type, int nb_param); void gen_function_end_declaration(); void gen_function_return(Type expect, Type actual); -int gen_function_call(const char name[], int nb_param); +Type gen_function_call(const char name[], int nb_param); void gen_declaration(const char name[], int type, Scope scope); void gen_check(const char name[], Scope scope); diff --git a/src/tpc.y b/src/tpc.y index dc6bc4f..1173eb7 100644 --- a/src/tpc.y +++ b/src/tpc.y @@ -164,7 +164,7 @@ F: | LValue { $$ = gen_value($1, scope); } | NUM { $$ = gen_num($1, scope); } | CARACTERE { $$ = gen_char($1, scope); } -| IDENT '(' Arguments ')' { return_type = fun_lookup($1,$3);$$ = gen_function_call($1,$3); } +| IDENT '(' Arguments ')' { $$ = (return_type = gen_function_call($1,$3)); } ; LValue: IDENT { gen_check($1, scope); } -- cgit v1.2.3