X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=gesamt%2Fparser.y;h=88b808e7cfc0155da7d18a3ff137644bc125e4f8;hb=e01d4b5591d2684af59e9dbb30330da9aa145794;hp=052e67faa178644c8da3d9724ea5699696259665;hpb=cba86813c2e4004a1fc73d7888b99998d18c3be7;p=uebersetzerbau-ss10.git diff --git a/gesamt/parser.y b/gesamt/parser.y index 052e67f..88b808e 100644 --- a/gesamt/parser.y +++ b/gesamt/parser.y @@ -49,7 +49,7 @@ @attributes { struct symbol *f; } Program Structdef; @attributes { struct symbol *f; int offsetcount; } FeldID @attributes { struct symbol *s; } Methoddef -@attributes { struct symbol *s; int gparamges; int vars_in; int paramcount; struct treenode *node; } Exprs +@attributes { struct symbol *s; int gparamges; int vars_in; int cnt; int paramcount; struct treenode *node; } Exprs @attributes { struct symbol *s; int gparamges; int lblcnt_in; int lblcnt_out; int vars_in; int vars_out; int call; } Statseq @attributes { struct symbol *s; int gparamges; int lblcnt_in; int lblcnt_out; int reallblcnt; int vars_in; int vars_out; int call; } Elsestat @attributes { struct symbol *s; int gparamges; int vars_in; struct treenode *node; short imm; int call; } Expr Minusterm Multerm Orterm Feld Term @@ -197,7 +197,12 @@ Statement: varsinout() lblcountinout() xxputsin(@Expr.s@,) - @i @Statement.node@ = TREENULL; + @i @Statement.node@ = new_node(O_EXPR, @Expr.node@, TREENULL); + @reg @Statement.node@->reg = @Expr.node@->reg = next_reg((char *)NULL, @Expr.gparamges@); + + @gen { + just_calls(@Statement.node@); + } @} | IF Expr THEN Statseq END @@ -556,12 +561,12 @@ Term: | IDENT '(' Exprs ')' @{ - /* TODO: soffset sollte eigentlich anzahl des paramcounts in Exprs + vars die existieren sein */ @i { - @Term.node@ = new_call(@IDENT.name@, new_arg(new_nothing(), new_nothing(), 0) /*this*/, - @Exprs.node@, @Term.gparamges@, @Term.vars_in@); - @Term.node@->soffset = @Exprs.paramcount@; + @Term.node@ = new_call(@IDENT.name@, new_arg(@Exprs.node@, new_nothing(), 0) /*this*/, + TREENULL, @Term.gparamges@, @Term.vars_in@); + @Term.node@->soffset = MAX(@Exprs.paramcount@, @Term.gparamges@); } + @i @Exprs.cnt@ = 1; @i @Term.imm@ = 0; @i @Term.call@ = 1; @reg @Exprs.node@->reg = @Term.node@->reg; @@ -569,9 +574,15 @@ Term: | Term '.' IDENT '(' Exprs ')' @{ - @i @Term.node@ = new_node(O_CALL, TREENULL, TREENULL); + @i { + @Term.node@ = new_call(@IDENT.name@, new_arg(@Exprs.node@, @Term.1.node@, 0) /*this*/, + TREENULL, @Term.gparamges@, @Term.vars_in@); + @Term.node@->soffset = MAX(@Exprs.paramcount@, @Term.gparamges@); + } + @i @Exprs.cnt@ = 1; @i @Term.imm@ = 0; @i @Term.call@ = 1; + @reg @Exprs.node@->reg = @Term.1.node@->reg = @Term.node@->kids[0]->reg = @Term.node@->reg; @} ; @@ -579,20 +590,21 @@ Term: Exprs: Expr ',' Exprs @{ - @i @Exprs.0.node@ = new_arg(@Expr.0.node@, @Exprs.1.node@, @Exprs.1.paramcount@); - @i @Exprs.0.paramcount@ = @Exprs.1.paramcount@ + 1; - @reg @Expr.node@->reg = @Exprs.1.node@->reg = @Exprs.0.node@->reg; + @i @Exprs.0.node@ = new_arg(@Expr.0.node@, @Exprs.1.node@, @Exprs.0.cnt@); + @i @Exprs.0.paramcount@ = @Exprs.1.paramcount@; + @i @Exprs.1.cnt@ = @Exprs.0.cnt@ + 1; + @reg @Expr.node@->reg = @Exprs.0.node@->reg; @Exprs.1.node@->reg = next_reg(@Exprs.0.node@->reg, @Exprs.gparamges@); @} | Expr @{ - @i @Exprs.0.node@ = new_arg(@Expr.0.node@, new_nothing(), 1); - @i @Exprs.paramcount@ = 2; + @i @Exprs.0.node@ = new_arg(@Expr.0.node@, new_nothing(), @Exprs.cnt@); + @i @Exprs.paramcount@ = @Exprs.cnt@ + 1; @reg @Expr.node@->reg = @Exprs.0.node@->reg; @} | @{ @i @Exprs.0.node@ = new_nothing(); - @i @Exprs.paramcount@ = 1; + @i @Exprs.paramcount@ = @Exprs.cnt@; @} ; %%