aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorpacien2018-06-05 13:07:41 +0200
committerpacien2018-06-05 13:07:41 +0200
commit7a966d25b34f4bd37f32a18f7e8a62b6f97186e6 (patch)
treeac35f879b4ce3b5a707d04d9adf380a298209eca /src
parentfe36a92c2d22057e8bbbf4c248706984f06415c0 (diff)
downloadtpc-compiler-7a966d25b34f4bd37f32a18f7e8a62b6f97186e6.tar.gz
Handle function call
Diffstat (limited to 'src')
-rw-r--r--src/generator.c5
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,
100void gen_function_end_declaration() { 100void 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
103int gen_function_call(const char name[], int nb_param) { 104int 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
108void gen_declaration(const char name[], int type, Scope scope) { 111void gen_declaration(const char name[], int type, Scope scope) {