mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-17 16:32:11 +01:00
Get "t0" temporary vars out of cgen's writeExpr
This commit is contained in:
1 parent
67acce83c7
commit
eddeebeb37
2 files changed
+8
-12
No files matched your search
@@ -27,15 +27,6 @@ func (g *gen) writeExpr(b *buffer, n *a.Expr, depth uint32) error {
|
||||
}
|
||||
depth++
|
||||
|
||||
if n.Effect().Coroutine() {
|
||||
if g.currFunk.tempR >= g.currFunk.tempW {
|
||||
return fmt.Errorf("internal error: temporary variable count out of sync")
|
||||
}
|
||||
b.printf("%s%d", tPrefix, g.currFunk.tempR)
|
||||
g.currFunk.tempR++
|
||||
return nil
|
||||
}
|
||||
|
||||
if cv := n.ConstValue(); cv != nil {
|
||||
if typ := n.MType(); typ.IsNumTypeOrIdeal() {
|
||||
b.writes(cv.String())
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in new issue
Block a user