From 00b8cb6be126d6cfeacf932b5595df9824cdf412 Mon Sep 17 00:00:00 2001 From: pacien Date: Wed, 6 Jun 2018 15:00:35 +0200 Subject: reformat and unify types --- src/generator.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'src/generator.c') diff --git a/src/generator.c b/src/generator.c index 1b11b67..553161a 100644 --- a/src/generator.c +++ b/src/generator.c @@ -12,9 +12,8 @@ void gen_prologue() { fprintf(output, "section .data\n"); } -void gen_prologue_continue(int *bss_done) { - if (*bss_done != 0) - return; +void gen_prologue_continue(bool *bss_done) { + if (!*bss_done) return; fprintf(output, "format_int db \"%%d\",10,0\n"); fprintf(output, "format_char db \"%%c\",10,0\n"); @@ -115,8 +114,7 @@ Type gen_function_declaration(const char name[], int return_type) { return return_type; } -void gen_function_end_declaration(const char name[], int return_type, - int nb_param) { +void gen_function_end_declaration(const char name[], Type return_type, int nb_param) { fun_add(name, return_type, nb_param); fprintf(output, "mov rax,-1\nmov rsp, rbp\npop rbp\nret\n"); } @@ -139,7 +137,7 @@ Type gen_function_call(const char name[], int nb_param) { return return_type; } -void gen_declaration(const char name[], int type, Scope scope) { +void gen_declaration(const char name[], Type type, Scope scope) { switch (scope) { case GLOBAL: glo_addVar(name, type); @@ -220,7 +218,7 @@ void gen_readc(const char name[], Scope scope) { fprintf(output, "mov rax,globals\nadd rax,%d\ncall readc\n", g_addr); } -void gen_print(int type) { +void gen_print(Type type) { // check if the name exists in both tables fprintf(output, "pop rax\n"); switch (type) { @@ -437,7 +435,7 @@ void gen_divstar(char op, int left, int right) { } } -int gen_signed_expr(char op, int type) { +int gen_signed_expr(char op, Type type) { check_expected_types(type, INT, TAB); switch (op) { case '+': @@ -453,7 +451,7 @@ int gen_signed_expr(char op, int type) { return type; } -int gen_negate_expr(int type) { +int gen_negate_expr(Type type) { check_expected_types(type, INT, TAB); fprintf(output, ";!F\npop rax\nxor rax,1\npush rax\n"); return type; -- cgit v1.2.3