From 3fa41a742ef73439fac40da45356f0b20ef8d8fc Mon Sep 17 00:00:00 2001 From: Bernhard Urban Date: Mon, 7 Jun 2010 09:42:57 +0200 Subject: [PATCH] gesamt: bugfix fuer gen_id_eno() und vars von hinten belegen --- gesamt/code.bfe | 13 ++++++------- gesamt/parser.y | 4 ++-- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/gesamt/code.bfe b/gesamt/code.bfe index 1dc1e3f..68d6089 100644 --- a/gesamt/code.bfe +++ b/gesamt/code.bfe @@ -43,8 +43,11 @@ void gen_id_eno(struct treenode *bnode) { printf("\t//gen_id_eno\n"); KIDKIDREG2PARM(1,0); - printf("\taddq %%%s, %%%s\n", KIDKID_REG(1,0), KIDKID_REG(1,1)); + KIDKIDREG2PARM(1,1); + KIDREG2PARM(0); + move(KID_REG(0), BN_REG); printf("\tsubq %%%s, %%%s\n", KIDKID_REG(1,1), BN_REG); + printf("\tsubq %%%s, %%%s\n", KIDKID_REG(1,0), BN_REG); } void gen_e_field(struct treenode *bnode, char *instr) @@ -192,7 +195,7 @@ void make_call(struct treenode *bnode) printf("\txchg %%%s, %d(%%rsp)\n", param_reg(j), j*8); } /* vars pushen */ - for(j = bnode->paramges; j < bnode->paramges + bnode->vars; j++) { + for(j = 6; j > 6 - bnode->vars - 1; j--) { printf("\tpushq %%%s\n", param_reg(j)); } @@ -213,16 +216,12 @@ void make_call(struct treenode *bnode) } /* vars poppen */ - for(j = bnode->paramges + bnode->vars - 1; j >= bnode->paramges; j--) { + for(j = 6 - bnode->vars; j < 6+1; j++) { printf("\tpopq %%%s\n", param_reg(j)); } /* params poppen */ -#if 0 - for(j = bnode->soffset - 1; j >= 0; j--) { -#else for(j = 0; j < bnode->soffset; j++) { -#endif printf("\tpopq %%%s\n", param_reg(j)); } } diff --git a/gesamt/parser.y b/gesamt/parser.y index 20d0a51..2d42baa 100644 --- a/gesamt/parser.y +++ b/gesamt/parser.y @@ -178,14 +178,14 @@ Statement: @{ /* tab_clone ist hier noetig, vgl. folgendes statement * > var x := x - 1; */ - @i @Statement.sout@ = tab_add_symbol(tab_clone(@Statement.sin@), @IDENT.name@, S_VAR, 1, @Statement.gparamges@ + @Statement.vars_in@, -1); + @i @Statement.sout@ = tab_add_symbol(tab_clone(@Statement.sin@), @IDENT.name@, S_VAR, 1, 6 - @Statement.vars_in@, -1); lblcountinout() @i @Statement.vars_out@ = @Statement.vars_in@ + 1; xxputsin(@Expr.s@,) - @i @Statement.node@ = new_node(O_ASSIGN, @Expr.node@, new_param(O_ID, @IDENT.name@, TREENULL, TREENULL, @Statement.gparamges@ + @Statement.vars_in@)); + @i @Statement.node@ = new_node(O_ASSIGN, @Expr.node@, new_param(O_ID, @IDENT.name@, TREENULL, TREENULL, 6 - @Statement.vars_in@)); @reg @Statement.node@->reg = @Expr.node@->reg = next_reg((char *)NULL, @Expr.gparamges@); @gen write_tree(@Statement.node@, 0); burm_label(@Statement.node@); burm_reduce(@Statement.node@, 1); -- 2.25.1