diff options
author | pacien | 2018-06-05 13:07:41 +0200 |
---|---|---|
committer | pacien | 2018-06-05 13:07:41 +0200 |
commit | 7a966d25b34f4bd37f32a18f7e8a62b6f97186e6 (patch) | |
tree | ac35f879b4ce3b5a707d04d9adf380a298209eca | |
parent | fe36a92c2d22057e8bbbf4c248706984f06415c0 (diff) | |
download | tpc-compiler-7a966d25b34f4bd37f32a18f7e8a62b6f97186e6.tar.gz |
Handle function call
-rw-r--r-- | src/generator.c | 5 |
1 files changed, 4 insertions, 1 deletions
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, | |||
100 | void gen_function_end_declaration() { | 100 | void gen_function_end_declaration() { |
101 | fprintf(output, "mov rsp, rbp\npop rbp\nret\n"); | 101 | fprintf(output, "mov rsp, rbp\npop rbp\nret\n"); |
102 | } | 102 | } |
103 | |||
103 | int gen_function_call(const char name[], int nb_param) { | 104 | int gen_function_call(const char name[], int nb_param) { |
105 | Type return_type = fun_lookup(name, nb_param); | ||
104 | fprintf(output, "call %s\n", name); | 106 | fprintf(output, "call %s\n", name); |
105 | return fun_lookup(name, nb_param); | 107 | if (return_type != VOID) fprintf(output, "push rax\n"); |
108 | return return_type; | ||
106 | } | 109 | } |
107 | 110 | ||
108 | void gen_declaration(const char name[], int type, Scope scope) { | 111 | void gen_declaration(const char name[], int type, Scope scope) { |