diff options
author | pacien | 2018-06-05 14:35:02 +0200 |
---|---|---|
committer | pacien | 2018-06-05 14:35:02 +0200 |
commit | 13b4fc0a1e32008f125f73148d01f12bdac3a80e (patch) | |
tree | dd3dc79a76805220bcf825710e9e0c23f86a5d7f | |
parent | 53e859913d6eb7141dbd1ed48f28c336f1322534 (diff) | |
download | tpc-compiler-13b4fc0a1e32008f125f73148d01f12bdac3a80e.tar.gz |
Simplify return type state on call
-rw-r--r-- | src/generator.c | 2 | ||||
-rw-r--r-- | src/generator.h | 2 | ||||
-rw-r--r-- | 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) { | |||
110 | gen_function_end_declaration(); | 110 | gen_function_end_declaration(); |
111 | } | 111 | } |
112 | 112 | ||
113 | int gen_function_call(const char name[], int nb_param) { | 113 | Type gen_function_call(const char name[], int nb_param) { |
114 | Type return_type = fun_lookup(name, nb_param); | 114 | Type return_type = fun_lookup(name, nb_param); |
115 | fprintf(output, "call %s\n", name); | 115 | fprintf(output, "call %s\n", name); |
116 | if (return_type != VOID_T) fprintf(output, "push rax\n"); | 116 | 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(); | |||
24 | Type gen_function_declaration(const char name[], int return_type, int nb_param); | 24 | Type gen_function_declaration(const char name[], int return_type, int nb_param); |
25 | void gen_function_end_declaration(); | 25 | void gen_function_end_declaration(); |
26 | void gen_function_return(Type expect, Type actual); | 26 | void gen_function_return(Type expect, Type actual); |
27 | int gen_function_call(const char name[], int nb_param); | 27 | Type gen_function_call(const char name[], int nb_param); |
28 | void gen_declaration(const char name[], int type, Scope scope); | 28 | void gen_declaration(const char name[], int type, Scope scope); |
29 | void gen_check(const char name[], Scope scope); | 29 | void gen_check(const char name[], Scope scope); |
30 | 30 | ||
@@ -164,7 +164,7 @@ F: | |||
164 | | LValue { $$ = gen_value($<ident>1, scope); } | 164 | | LValue { $$ = gen_value($<ident>1, scope); } |
165 | | NUM { $$ = gen_num($1, scope); } | 165 | | NUM { $$ = gen_num($1, scope); } |
166 | | CARACTERE { $$ = gen_char($1, scope); } | 166 | | CARACTERE { $$ = gen_char($1, scope); } |
167 | | IDENT '(' Arguments ')' { return_type = fun_lookup($<ident>1,$<num>3);$$ = gen_function_call($<ident>1,$<num>3); } | 167 | | IDENT '(' Arguments ')' { $$ = (return_type = gen_function_call($<ident>1,$<num>3)); } |
168 | ; | 168 | ; |
169 | LValue: | 169 | LValue: |
170 | IDENT { gen_check($<ident>1, scope); } | 170 | IDENT { gen_check($<ident>1, scope); } |