Remove the !? effect, leaving only ! and !??

This commit is contained in:
Nigel Tao committed 2018-12-29 13:36:38 +11:00
1 parent d4be1fdf72
commit 1ea32b3745
7 files changed
+20 -28

No files matched your search

+6 -6
View File
@@ -87,7 +87,7 @@ func (g *gen) writeFuncSignature(b *buffer, n *a.Func, cpp uint32) error {
}
// TODO: write n's return values.
if n.Effect().Optional() {
if n.Effect().Coroutine() {
b.writes("wuffs_base__status ")
} else if out := n.Out(); out == nil {
b.writes("wuffs_base__empty_struct ")
@@ -178,7 +178,7 @@ func (g *gen) gatherFuncImpl(_ *buffer, n *a.Func) error {
astFunc: n,
cName: g.funcCName(n),
returnsStatus: n.Effect().Optional() ||
returnsStatus: n.Effect().Coroutine() ||
((n.Out() != nil) && n.Out().IsStatus()),
}
@@ -258,7 +258,7 @@ func (g *gen) writeFuncImplPrologue(b *buffer) error {
}
}
if g.currFunk.astFunc.Effect().Optional() ||
if g.currFunk.astFunc.Effect().Coroutine() ||
(g.currFunk.returnsStatus && (len(g.currFunk.derivedVars) > 0)) {
// TODO: rename the "status" variable to "ret"?
b.printf("wuffs_base__status status = NULL;\n")
@@ -334,7 +334,7 @@ func (g *gen) writeFuncImplBodySuspend(b *buffer) error {
}
func (g *gen) writeFuncImplEpilogue(b *buffer) error {
if g.currFunk.astFunc.Effect().Optional() ||
if g.currFunk.astFunc.Effect().Coroutine() ||
(g.currFunk.returnsStatus && (len(g.currFunk.derivedVars) > 0)) {
b.writes("goto exit;exit:") // The goto avoids the "unused label" warning.
@@ -350,7 +350,7 @@ func (g *gen) writeFuncImplEpilogue(b *buffer) error {
b.writes("\n")
}
if g.currFunk.astFunc.Effect().Optional() ||
if g.currFunk.astFunc.Effect().Coroutine() ||
(g.currFunk.returnsStatus && (len(g.currFunk.derivedVars) > 0)) {
if g.currFunk.astFunc.Public() {
@@ -424,7 +424,7 @@ func (g *gen) writeFuncImplArgChecks(b *buffer, n *a.Func) error {
}
b.writes(") {")
b.writes("self->private_impl.magic = WUFFS_BASE__DISABLED;\n")
if g.currFunk.astFunc.Effect().Optional() {
if g.currFunk.astFunc.Effect().Coroutine() {
b.writes("return wuffs_base__error__bad_argument;\n\n")
} else {
// TODO: don't assume that the return type is empty.
+5 -9
View File
@@ -103,7 +103,7 @@ func (g *gen) writeStatementAssign0(b *buffer, op t.ID, lhs *a.Expr, rhs *a.Expr
return false, err
}
doWork, hack := (lhs == nil) || rhs.Effect().Optional(), false
doWork, hack := (lhs == nil) || rhs.Effect().Coroutine(), false
if !doWork && (rhs.Operator() == t.IDOpenParen) && (len(g.currFunk.derivedVars) > 0) {
// TODO: tighten this heuristic for filtering out all but user-defined
// method receivers.
@@ -146,7 +146,7 @@ func (g *gen) writeStatementAssign0(b *buffer, op t.ID, lhs *a.Expr, rhs *a.Expr
return false, err
}
b.writes("status = ")
} else if rhs.Effect().Optional() {
} else if rhs.Effect().Coroutine() {
b.writes("status = ")
}
@@ -161,12 +161,8 @@ func (g *gen) writeStatementAssign0(b *buffer, op t.ID, lhs *a.Expr, rhs *a.Expr
}
}
if op != t.IDEqQuestion && rhs.Effect().Optional() {
target := "exit"
if rhs.Effect().Coroutine() {
target = "suspend"
}
b.printf("if (status) { goto %s; }\n", target)
if op != t.IDEqQuestion && rhs.Effect().Coroutine() {
b.writes("if (status) { goto suspend; }\n")
}
}
@@ -397,7 +393,7 @@ func (g *gen) writeStatementJump(b *buffer, n *a.Jump, depth uint32) error {
func (g *gen) writeStatementRet(b *buffer, n *a.Ret, depth uint32) error {
retExpr := n.Value()
if g.currFunk.astFunc.Effect().Optional() ||
if g.currFunk.astFunc.Effect().Coroutine() ||
(g.currFunk.returnsStatus && (len(g.currFunk.derivedVars) > 0)) {
isOK := false