mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-24 00:52:18 +01:00
Let ? methods return OK even without suspending
This commit is contained in:
1 parent
865275db75
commit
00203e564f
4 files changed
+17
-11
No files matched your search
@@ -40,6 +40,7 @@ type funk struct {
|
|||||||
public bool
|
public bool
|
||||||
suspendible bool
|
suspendible bool
|
||||||
usesScratch bool
|
usesScratch bool
|
||||||
|
hasGotoOK bool
|
||||||
shortReads []string
|
shortReads []string
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,6 +134,8 @@ func (g *gen) writeFuncImpl(b *buffer, n *a.Func) error {
|
|||||||
b.writex(k.bBody)
|
b.writex(k.bBody)
|
||||||
if k.suspendible && k.coroSuspPoint > 0 {
|
if k.suspendible && k.coroSuspPoint > 0 {
|
||||||
b.writex(k.bBodySuspend)
|
b.writex(k.bBodySuspend)
|
||||||
|
} else if k.hasGotoOK {
|
||||||
|
b.writes("\ngoto ok;ok:\n") // The goto avoids the "unused label" warning.
|
||||||
}
|
}
|
||||||
b.writex(k.bFooter)
|
b.writex(k.bFooter)
|
||||||
b.writes("}\n\n")
|
b.writes("}\n\n")
|
||||||
@@ -274,14 +277,12 @@ func (g *gen) writeFuncImplBodySuspend(b *buffer) error {
|
|||||||
// We've reached the end of the function body. Reset the coroutine
|
// We've reached the end of the function body. Reset the coroutine
|
||||||
// suspension point so that the next call to this function starts at
|
// suspension point so that the next call to this function starts at
|
||||||
// the top.
|
// the top.
|
||||||
b.writes("\ngoto ok;\n") // Avoid the "unused label" warning.
|
b.writes("\ngoto ok;ok:") // The goto avoids the "unused label" warning.
|
||||||
b.writes("ok:\n")
|
|
||||||
b.printf("self->private_impl.%s%s[0].coro_susp_point = 0;\n",
|
b.printf("self->private_impl.%s%s[0].coro_susp_point = 0;\n",
|
||||||
cPrefix, g.currFunk.astFunc.FuncName().Str(g.tm))
|
cPrefix, g.currFunk.astFunc.FuncName().Str(g.tm))
|
||||||
b.writes("goto exit; }\n\n") // Close the coroutine switch.
|
b.writes("goto exit; }\n\n") // Close the coroutine switch.
|
||||||
|
|
||||||
b.writes("goto suspend;\n") // Avoid the "unused label" warning.
|
b.writes("goto suspend;suspend:") // The goto avoids the "unused label" warning.
|
||||||
b.writes("suspend:\n")
|
|
||||||
|
|
||||||
b.printf("self->private_impl.%s%s[0].coro_susp_point = coro_susp_point;\n",
|
b.printf("self->private_impl.%s%s[0].coro_susp_point = coro_susp_point;\n",
|
||||||
cPrefix, g.currFunk.astFunc.FuncName().Str(g.tm))
|
cPrefix, g.currFunk.astFunc.FuncName().Str(g.tm))
|
||||||
@@ -295,8 +296,7 @@ func (g *gen) writeFuncImplBodySuspend(b *buffer) error {
|
|||||||
|
|
||||||
func (g *gen) writeFuncImplFooter(b *buffer) error {
|
func (g *gen) writeFuncImplFooter(b *buffer) error {
|
||||||
if g.currFunk.suspendible {
|
if g.currFunk.suspendible {
|
||||||
b.writes("goto exit;\n") // Avoid the "unused label" warning.
|
b.writes("goto exit;exit:") // The goto avoids the "unused label" warning.
|
||||||
b.writes("exit:")
|
|
||||||
|
|
||||||
for _, o := range g.currFunk.astFunc.In().Fields() {
|
for _, o := range g.currFunk.astFunc.In().Fields() {
|
||||||
o := o.Field()
|
o := o.Field()
|
||||||
|
|||||||
@@ -348,8 +348,10 @@ func (g *gen) writeStatementRet(b *buffer, n *a.Ret, depth uint32) error {
|
|||||||
case t.IDError:
|
case t.IDError:
|
||||||
b.writes("goto exit;")
|
b.writes("goto exit;")
|
||||||
case t.IDStatus:
|
case t.IDStatus:
|
||||||
|
g.currFunk.hasGotoOK = true
|
||||||
b.writes("goto ok;")
|
b.writes("goto ok;")
|
||||||
default:
|
default:
|
||||||
|
g.currFunk.hasGotoOK = true
|
||||||
b.printf("if (status == 0) { goto ok; } else if (status > 0) { "+
|
b.printf("if (status == 0) { goto ok; } else if (status > 0) { "+
|
||||||
"status = %sERROR_CANNOT_RETURN_A_SUSPENSION; } goto exit;", g.PKGPREFIX)
|
"status = %sERROR_CANNOT_RETURN_A_SUSPENSION; } goto exit;", g.PKGPREFIX)
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-2
@@ -3628,9 +3628,13 @@ static wuffs_gif__status wuffs_gif__decoder__copy_to_image_buffer(
|
|||||||
v_dst = wuffs_base__table_u8__linearize(v_tab);
|
v_dst = wuffs_base__table_u8__linearize(v_tab);
|
||||||
if (((uint64_t)(v_dst.len)) == 0) {
|
if (((uint64_t)(v_dst.len)) == 0) {
|
||||||
}
|
}
|
||||||
} else {
|
status = WUFFS_GIF__STATUS_OK;
|
||||||
v_dst = wuffs_base__table_u8__row(v_tab, self->private_impl.f_dst_y);
|
goto ok;
|
||||||
}
|
}
|
||||||
|
v_dst = wuffs_base__table_u8__row(v_tab, self->private_impl.f_dst_y);
|
||||||
|
|
||||||
|
goto ok;
|
||||||
|
ok:
|
||||||
goto exit;
|
goto exit;
|
||||||
exit:
|
exit:
|
||||||
return status;
|
return status;
|
||||||
|
|||||||
@@ -505,8 +505,8 @@ pri func decoder.copy_to_image_buffer?(ib ptr base.image_buffer)() {
|
|||||||
if dst.length() == 0 {
|
if dst.length() == 0 {
|
||||||
// TODO.
|
// TODO.
|
||||||
}
|
}
|
||||||
} else {
|
return
|
||||||
dst = tab.row(y:this.dst_y)
|
|
||||||
// TODO.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dst = tab.row(y:this.dst_y)
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user