Get "t0" temporary vars out of cgen's writeExpr

This commit is contained in:
Nigel Tao committed 2018-12-27 16:27:30 +11:00
1 parent 67acce83c7
commit eddeebeb37
2 files changed
+8 -12

No files matched your search

+8 -3
View File
@@ -141,8 +141,7 @@ func (g *gen) writeStatementAssign0(b *buffer, op t.ID, lhs *a.Expr, rhs *a.Expr
b.writes("status = ")
}
// TODO: drop the "Other" in writeExprOther.
if err := g.writeExprOther(b, rhs, 0); err != nil {
if err := g.writeExpr(b, rhs, 0); err != nil {
return err
}
b.writes(";\n")
@@ -198,7 +197,13 @@ func (g *gen) writeStatementAssign1(b *buffer, op t.ID, lhs *a.Expr, rhs *a.Expr
b.writex(lhsBuf)
b.writes(opName)
if err := g.writeExpr(b, rhs, 0); err != nil {
if rhs.Effect().Coroutine() {
if g.currFunk.tempR != (g.currFunk.tempW - 1) {
return fmt.Errorf("internal error: temporary variable count out of sync")
}
b.printf("%s%d", tPrefix, g.currFunk.tempR)
g.currFunk.tempR++
} else if err := g.writeExpr(b, rhs, 0); err != nil {
return err
}
b.writes(closer)