mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-20 00:47:28 +01:00
Don't skip derived I/O vars for !? methods
This commit is contained in:
1 parent
cf51406fcf
commit
ec0fd9649d
3 files changed
+84
-53
No files matched your search
@@ -252,7 +252,7 @@ func (g *gen) writeFuncImplPrologue(b *buffer) error {
|
||||
}
|
||||
}
|
||||
|
||||
if g.currFunk.astFunc.Effect().Coroutine() {
|
||||
if g.currFunk.astFunc.Effect().Optional() {
|
||||
b.printf("wuffs_base__status status = NULL;\n")
|
||||
}
|
||||
b.writes("\n")
|
||||
@@ -263,7 +263,7 @@ func (g *gen) writeFuncImplPrologue(b *buffer) error {
|
||||
}
|
||||
b.writes("\n")
|
||||
|
||||
if g.currFunk.astFunc.Effect().Coroutine() {
|
||||
if g.currFunk.astFunc.Effect().Optional() {
|
||||
g.findDerivedVars()
|
||||
for _, o := range g.currFunk.astFunc.In().Fields() {
|
||||
o := o.AsField()
|
||||
@@ -331,7 +331,7 @@ func (g *gen) writeFuncImplBodySuspend(b *buffer) error {
|
||||
}
|
||||
|
||||
func (g *gen) writeFuncImplEpilogue(b *buffer) error {
|
||||
if effect := g.currFunk.astFunc.Effect(); effect.Coroutine() {
|
||||
if g.currFunk.astFunc.Effect().Optional() {
|
||||
b.writes("goto exit;exit:") // The goto avoids the "unused label" warning.
|
||||
|
||||
for _, o := range g.currFunk.astFunc.In().Fields() {
|
||||
@@ -347,8 +347,6 @@ func (g *gen) writeFuncImplEpilogue(b *buffer) error {
|
||||
"self->private_impl.magic = WUFFS_BASE__DISABLED; }\n")
|
||||
}
|
||||
b.writes("return status;\n")
|
||||
} else if effect.Optional() {
|
||||
b.writes("return NULL;\n")
|
||||
} else if g.currFunk.astFunc.Out() == nil {
|
||||
b.writes("return ((wuffs_base__empty_struct){});\n")
|
||||
}
|
||||
|
||||
@@ -163,11 +163,7 @@ func (g *gen) writeStatementExpr(b *buffer, n *a.Expr, depth uint32) error {
|
||||
if n.Effect().Coroutine() {
|
||||
return nil
|
||||
} else if n.Effect().Optional() {
|
||||
if g.currFunk.astFunc.Effect().Coroutine() {
|
||||
b.writes("status = ")
|
||||
} else {
|
||||
b.writes("{ wuffs_base__status status = ")
|
||||
}
|
||||
b.writes("status = ")
|
||||
checkStatus = true
|
||||
}
|
||||
}
|
||||
@@ -176,11 +172,7 @@ func (g *gen) writeStatementExpr(b *buffer, n *a.Expr, depth uint32) error {
|
||||
}
|
||||
b.writes(";\n")
|
||||
if checkStatus {
|
||||
if g.currFunk.astFunc.Effect().Coroutine() {
|
||||
b.writes("if (status) { goto exit; }\n")
|
||||
} else {
|
||||
b.writes("if (status) { return status; }}\n")
|
||||
}
|
||||
b.writes("if (status) { goto exit; }\n")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -341,7 +333,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().Coroutine() {
|
||||
if g.currFunk.astFunc.Effect().Optional() {
|
||||
isError, isOK := false, false
|
||||
b.writes("status = ")
|
||||
if retExpr.Operator() == 0 && retExpr.Ident() == t.IDOk {
|
||||
@@ -381,7 +373,7 @@ func (g *gen) writeStatementRet(b *buffer, n *a.Ret, depth uint32) error {
|
||||
}
|
||||
|
||||
b.writes("return ")
|
||||
if g.currFunk.astFunc.Out() == nil && !g.currFunk.astFunc.Effect().Optional() {
|
||||
if g.currFunk.astFunc.Out() == nil {
|
||||
return fmt.Errorf("TODO: allow empty return type (when not suspendible)")
|
||||
} else if err := g.writeExpr(b, retExpr, replaceCallSuspendibles, depth); err != nil {
|
||||
return err
|
||||
|
||||
Reference in new issue
Block a user