mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-21 00:47:28 +01:00
Remove the obsolete Effect.RootCause concept
This commit is contained in:
1 parent
9741eada02
commit
5cae1f8c82
6 files changed
+19
-60
No files matched your search
@@ -27,15 +27,10 @@ func (g *gen) writeExpr(b *buffer, n *a.Expr, rp replacementPolicy, depth uint32
|
||||
}
|
||||
depth++
|
||||
|
||||
if rp == replaceCallSuspendibles && n.Effect().RootCause() && n.Effect().Coroutine() {
|
||||
if rp == replaceCallSuspendibles && n.Effect().Coroutine() {
|
||||
if g.currFunk.tempR >= g.currFunk.tempW {
|
||||
return fmt.Errorf("internal error: temporary variable count out of sync")
|
||||
}
|
||||
// TODO: check that this works with nested call-suspendibles:
|
||||
// "foo?().bar().qux?()(p?(), q?())".
|
||||
//
|
||||
// Also be aware of evaluation order in the presence of side effects:
|
||||
// in "foo(a?(), b!(), c?())", b should be called between a and c.
|
||||
b.printf("%s%d", tPrefix, g.currFunk.tempR)
|
||||
g.currFunk.tempR++
|
||||
return nil
|
||||
|
||||
@@ -285,21 +285,16 @@ func (h *resumabilityHelper) doExpr1(r resumabilities, n *a.Expr, sef subExprFil
|
||||
|
||||
processOnlySubExprs := false
|
||||
if sef != subExprFilterNone {
|
||||
const mask = a.EffectCoroutine | a.EffectRootCause
|
||||
switch sef {
|
||||
case subExprFilterBeforeCoroutine:
|
||||
switch n.Effect() & mask {
|
||||
case a.EffectCoroutine | a.EffectRootCause:
|
||||
sef = subExprFilterNone
|
||||
case a.EffectCoroutine:
|
||||
// No-op.
|
||||
default:
|
||||
if !n.Effect().Coroutine() {
|
||||
return nil
|
||||
}
|
||||
sef = subExprFilterNone
|
||||
processOnlySubExprs = true
|
||||
|
||||
case subExprFilterDuringCoroutine:
|
||||
if n.Effect()&mask == mask {
|
||||
if n.Effect().Coroutine() {
|
||||
switch n.Operator() {
|
||||
case t.IDOpenParen:
|
||||
r.raiseNoneToWeak()
|
||||
@@ -311,7 +306,7 @@ func (h *resumabilityHelper) doExpr1(r resumabilities, n *a.Expr, sef subExprFil
|
||||
processOnlySubExprs = true
|
||||
|
||||
case subExprFilterAfterCoroutine:
|
||||
if n.Effect()&mask == mask {
|
||||
if n.Effect().Coroutine() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,7 +159,7 @@ func (g *gen) writeStatementExpr(b *buffer, n *a.Expr, depth uint32) error {
|
||||
// statements.
|
||||
//
|
||||
// TODO: clean up how this and writeSuspendibles interact.
|
||||
derived := n.Effect().RootCause() && n.Effect().Optional() && !n.Effect().Coroutine()
|
||||
derived := n.Effect().Optional() && !n.Effect().Coroutine()
|
||||
if derived {
|
||||
if err := g.writeSaveExprDerivedVars(b, n); err != nil {
|
||||
return err
|
||||
@@ -171,13 +171,11 @@ func (g *gen) writeStatementExpr(b *buffer, n *a.Expr, depth uint32) error {
|
||||
}
|
||||
|
||||
checkStatus := false
|
||||
if n.Effect().RootCause() {
|
||||
if n.Effect().Coroutine() {
|
||||
return nil
|
||||
} else if n.Effect().Optional() {
|
||||
b.writes("status = ")
|
||||
checkStatus = true
|
||||
}
|
||||
if effect := n.Effect(); effect.Coroutine() {
|
||||
return nil
|
||||
} else if effect.Optional() {
|
||||
b.writes("status = ")
|
||||
checkStatus = true
|
||||
}
|
||||
if err := g.writeExpr(b, n, replaceCallSuspendibles, depth); err != nil {
|
||||
return err
|
||||
@@ -531,26 +529,6 @@ func (g *gen) writeCallSuspendibles(b *buffer, n *a.Expr, depth uint32, eqQuesti
|
||||
}
|
||||
depth++
|
||||
|
||||
// The evaluation order for suspendible calls (which can have side effects)
|
||||
// is important here: LHS, MHS, RHS, Args and finally the node itself.
|
||||
if e := n.Effect(); !e.RootCause() || !e.Coroutine() {
|
||||
for _, o := range n.AsNode().AsRaw().SubNodes() {
|
||||
if o != nil && o.Kind() == a.KExpr {
|
||||
if err := g.writeCallSuspendibles(b, o.AsExpr(), depth, false); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, o := range n.Args() {
|
||||
if o != nil && o.Kind() == a.KExpr {
|
||||
if err := g.writeCallSuspendibles(b, o.AsExpr(), depth, false); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := g.writeSaveExprDerivedVars(b, n); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user