mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-19 16:47:28 +01:00
Fold Expr statements into Assign statements
This commit is contained in:
1 parent
796c8ccc30
commit
c9e6ee6fb3
6 files changed
+34
-38
No files matched your search
@@ -240,6 +240,10 @@ func (h *resumabilityHelper) doAssign(r resumabilities, n *a.Assign, depth uint3
|
||||
return err
|
||||
}
|
||||
|
||||
if n.LHS() == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
// If the LHS is not a local variable (e.g. "this.foo[bar] = etc", or if
|
||||
// the LHS is implicitly also on the RHS (e.g. for a += or *= operator),
|
||||
// walk the LHS Expr.
|
||||
|
||||
@@ -39,15 +39,7 @@ func (g *gen) writeStatement(b *buffer, n *a.Node, depth uint32) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
mightIntroduceTemporaries := false
|
||||
switch n.Kind() {
|
||||
case a.KAssign:
|
||||
n := n.AsAssign()
|
||||
mightIntroduceTemporaries = n.RHS().Effect().Coroutine()
|
||||
case a.KExpr:
|
||||
// TODO.
|
||||
}
|
||||
if mightIntroduceTemporaries {
|
||||
if (n.Kind() == a.KAssign) && (n.AsAssign().LHS() != nil) && n.AsAssign().RHS().Effect().Coroutine() {
|
||||
// Put n's code into its own block, to restrict the scope of the
|
||||
// tPrefix temporary variables. This helps avoid "jump bypasses
|
||||
// variable initialization" compiler warnings with the coroutine
|
||||
@@ -71,8 +63,6 @@ func (g *gen) writeStatement(b *buffer, n *a.Node, depth uint32) error {
|
||||
case a.KAssign:
|
||||
n := n.AsAssign()
|
||||
return g.writeStatementAssign(b, n.Operator(), n.LHS(), n.RHS(), depth)
|
||||
case a.KExpr:
|
||||
return g.writeStatementAssign(b, 0, nil, n.AsExpr(), depth)
|
||||
case a.KIOBind:
|
||||
return g.writeStatementIOBind(b, n.AsIOBind(), depth)
|
||||
case a.KIf:
|
||||
@@ -92,8 +82,6 @@ func (g *gen) writeStatement(b *buffer, n *a.Node, depth uint32) error {
|
||||
}
|
||||
|
||||
func (g *gen) writeStatementAssign(b *buffer, op t.ID, lhs *a.Expr, rhs *a.Expr, depth uint32) error {
|
||||
// TODO: clean this method body up.
|
||||
|
||||
if depth > a.MaxExprDepth {
|
||||
return fmt.Errorf("expression recursion depth too large")
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user