From 325a27ceb2b75d460fe6e191915db568d7a3edbb Mon Sep 17 00:00:00 2001 From: Bernhard Urban Date: Sun, 30 May 2010 00:06:42 +0200 Subject: [PATCH] codeb: labels werden nun auch fuer 'IF expr THEN statseq ELSE statseq END' richtig beschriftet --- codeb/parser.y | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/codeb/parser.y b/codeb/parser.y index 7d9af97..7e354ce 100644 --- a/codeb/parser.y +++ b/codeb/parser.y @@ -46,7 +46,8 @@ @attributes { struct symbol *f; int offsetcount; } FeldID @attributes { struct symbol *s; } Methoddef @attributes { struct symbol *s; int gparamges; } Exprs -@attributes { struct symbol *s; int gparamges; int lblcnt_in; int lblcnt_out; } Statseq Elsestat +@attributes { struct symbol *s; int gparamges; int lblcnt_in; int lblcnt_out; } Statseq +@attributes { struct symbol *s; int gparamges; int lblcnt_in; int lblcnt_out; int reallblcnt; } Elsestat @attributes { struct symbol *s; int gparamges; struct treenode *node; short imm; } Expr Minusterm Multerm Orterm Feld Term @attributes { struct symbol *s; int gparamges; struct treenode *node; } Lexpr @attributes { struct symbol *sin; int gparamges; struct symbol *sout; struct treenode *node; int vars; int lblcnt_in; int lblcnt_out; } Statement @@ -206,10 +207,12 @@ Statement: | IF Expr THEN Statseq Elsestat END @{ statinout() - @i @Statseq.0.lblcnt_in@ = @Statement.lblcnt_in@ + 1; - @i @Elsestat.lblcnt_in@ = @Statement.lblcnt_in@; - /* TODO: welchen wert lblcnt_out zuweisen? :/ */ - @i @Statement.lblcnt_out@ = @Statseq.lblcnt_out@; + @i @Statseq.0.lblcnt_in@ = @Statement.lblcnt_in@ + 1; + @i @Elsestat.lblcnt_in@ = @Statseq.lblcnt_out@; + @i @Statement.lblcnt_out@ = @Elsestat.lblcnt_out@; + + /* im Elsestat muss noch ein label numeriert werden */ + @i @Elsestat.reallblcnt@ = @Statement.lblcnt_in@; xxputsin(@Expr.s@,) xxputsin(@Statseq.0.s@,) @@ -256,10 +259,10 @@ Statement: Elsestat: ELSE Statseq @{ - @i @Statseq.lblcnt_in@ = @Elsestat.lblcnt_in@ + 1; + @i @Statseq.lblcnt_in@ = @Elsestat.lblcnt_in@; @i @Elsestat.lblcnt_out@ = @Statseq.lblcnt_out@; - @gen printf("\tjmp %s_ifend_%d\n%s_ifelse_%d:\n", get_func_name(), @Elsestat.lblcnt_in@, get_func_name(), @Elsestat.lblcnt_in@); + @gen printf("\tjmp %s_ifend_%d\n%s_ifelse_%d:\n", get_func_name(), @Elsestat.reallblcnt@, get_func_name(), @Elsestat.reallblcnt@); @} Lexpr: -- 2.25.1