mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-18 00:32:11 +01:00
Drop duplicate CoroSuspPoint for io_reader.skip
This commit is contained in:
1 parent
eddeebeb37
commit
28366f744f
3 files changed
+19
-17
No files matched your search
@@ -538,7 +538,7 @@ func (g *gen) writeArgs(b *buffer, args []*a.Node, depth uint32) error {
|
||||
}
|
||||
|
||||
func (g *gen) writeBuiltinQuestionCall(b *buffer, n *a.Expr, depth uint32) error {
|
||||
// TODO: also handle (or reject??) t.IDTry.
|
||||
// TODO: also handle (or reject??) being on the RHS of an =? operator.
|
||||
if n.Operator() != t.IDOpenParen {
|
||||
return errNoSuchBuiltin
|
||||
}
|
||||
@@ -552,6 +552,9 @@ func (g *gen) writeBuiltinQuestionCall(b *buffer, n *a.Expr, depth uint32) error
|
||||
if recvTyp.QID()[1] == t.IDIOReader {
|
||||
switch method.Ident() {
|
||||
case t.IDReadU8, t.IDReadU8AsU32, t.IDReadU8AsU64:
|
||||
if err := g.writeCoroSuspPoint(b, false); err != nil {
|
||||
return err
|
||||
}
|
||||
if g.currFunk.tempW > maxTemp {
|
||||
return fmt.Errorf("too many temporary variables required")
|
||||
}
|
||||
@@ -572,11 +575,15 @@ func (g *gen) writeBuiltinQuestionCall(b *buffer, n *a.Expr, depth uint32) error
|
||||
case t.IDSkip:
|
||||
x := n.Args()[0].AsArg().Value()
|
||||
if cv := x.ConstValue(); cv != nil && cv.Cmp(one) == 0 {
|
||||
if err := g.writeCoroSuspPoint(b, false); err != nil {
|
||||
return err
|
||||
}
|
||||
b.printf("if (WUFFS_BASE__UNLIKELY(iop_a_src == io1_a_src)) {" +
|
||||
"status = wuffs_base__suspension__short_read; goto suspend; }")
|
||||
b.printf("iop_a_src++;\n")
|
||||
return nil
|
||||
}
|
||||
g.currFunk.coroSuspPoint++ // TEMPORARY, in order to minimize the diff.
|
||||
|
||||
g.currFunk.usesScratch = true
|
||||
// TODO: don't hard-code [0], and allow recursive coroutines.
|
||||
@@ -589,7 +596,6 @@ func (g *gen) writeBuiltinQuestionCall(b *buffer, n *a.Expr, depth uint32) error
|
||||
}
|
||||
b.writes(";\n")
|
||||
|
||||
// TODO: the CSP prior to this is probably unnecessary.
|
||||
if err := g.writeCoroSuspPoint(b, false); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -606,6 +612,9 @@ func (g *gen) writeBuiltinQuestionCall(b *buffer, n *a.Expr, depth uint32) error
|
||||
if method.Ident() >= readMethodsBase {
|
||||
if m := method.Ident() - readMethodsBase; m < t.ID(len(readMethods)) {
|
||||
if p := readMethods[m]; p.n != 0 {
|
||||
if err := g.writeCoroSuspPoint(b, false); err != nil {
|
||||
return err
|
||||
}
|
||||
return g.writeReadUxxAsUyy(b, n, "a_src", p.n, p.size, p.endianness)
|
||||
}
|
||||
}
|
||||
@@ -614,6 +623,9 @@ func (g *gen) writeBuiltinQuestionCall(b *buffer, n *a.Expr, depth uint32) error
|
||||
} else {
|
||||
switch method.Ident() {
|
||||
case t.IDWriteU8:
|
||||
if err := g.writeCoroSuspPoint(b, false); err != nil {
|
||||
return err
|
||||
}
|
||||
b.writes("if (iop_a_dst == io1_a_dst) {\n" +
|
||||
"status = wuffs_base__suspension__short_write; goto suspend; }\n" +
|
||||
"*iop_a_dst++ = ")
|
||||
|
||||
@@ -112,16 +112,16 @@ func (g *gen) writeStatementAssign(b *buffer, op t.ID, lhs *a.Expr, rhs *a.Expr,
|
||||
|
||||
func (g *gen) writeStatementAssign0(b *buffer, op t.ID, lhs *a.Expr, rhs *a.Expr) error {
|
||||
if rhs.Effect().Coroutine() {
|
||||
if op != t.IDEqQuestion {
|
||||
if err := g.writeCoroSuspPoint(b, false); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if err := g.writeBuiltinQuestionCall(b, rhs, 0); err == nil {
|
||||
return nil
|
||||
} else if err != errNoSuchBuiltin {
|
||||
return err
|
||||
}
|
||||
if op != t.IDEqQuestion {
|
||||
if err := g.writeCoroSuspPoint(b, false); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (lhs == nil) || rhs.Effect().Coroutine() {
|
||||
|
||||
@@ -7964,7 +7964,6 @@ wuffs_gif__decoder__skip_frame(wuffs_gif__decoder* self,
|
||||
v_flags = t_0;
|
||||
}
|
||||
if ((v_flags & 128) != 0) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(2);
|
||||
self->private_impl.c_skip_frame[0].scratch =
|
||||
(((uint32_t)(3)) << (1 + (v_flags & 7)));
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(3);
|
||||
@@ -8404,7 +8403,6 @@ wuffs_gif__decoder__decode_lsd(wuffs_gif__decoder* self,
|
||||
uint8_t t_2 = *iop_a_src++;
|
||||
v_flags = t_2;
|
||||
}
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(6);
|
||||
self->private_impl.c_decode_lsd[0].scratch = 2;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(7);
|
||||
if (self->private_impl.c_decode_lsd[0].scratch >
|
||||
@@ -8648,7 +8646,6 @@ wuffs_gif__decoder__skip_blocks(wuffs_gif__decoder* self,
|
||||
status = NULL;
|
||||
goto ok;
|
||||
}
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(2);
|
||||
self->private_impl.c_skip_blocks[0].scratch = ((uint32_t)(v_block_size));
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(3);
|
||||
if (self->private_impl.c_skip_blocks[0].scratch >
|
||||
@@ -8734,7 +8731,6 @@ wuffs_gif__decoder__decode_ae(wuffs_gif__decoder* self,
|
||||
goto ok;
|
||||
}
|
||||
if (v_block_size != 11) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(2);
|
||||
self->private_impl.c_decode_ae[0].scratch = ((uint32_t)(v_block_size));
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(3);
|
||||
if (self->private_impl.c_decode_ae[0].scratch >
|
||||
@@ -8779,7 +8775,6 @@ wuffs_gif__decoder__decode_ae(wuffs_gif__decoder* self,
|
||||
v_block_size = t_2;
|
||||
}
|
||||
if (v_block_size != 3) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(6);
|
||||
self->private_impl.c_decode_ae[0].scratch = ((uint32_t)(v_block_size));
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(7);
|
||||
if (self->private_impl.c_decode_ae[0].scratch >
|
||||
@@ -8802,7 +8797,6 @@ wuffs_gif__decoder__decode_ae(wuffs_gif__decoder* self,
|
||||
v_c = t_3;
|
||||
}
|
||||
if (v_c != 1) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(9);
|
||||
self->private_impl.c_decode_ae[0].scratch = 2;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(10);
|
||||
if (self->private_impl.c_decode_ae[0].scratch >
|
||||
@@ -9576,7 +9570,6 @@ wuffs_gif__decoder__decode_id_part2(wuffs_gif__decoder* self,
|
||||
if (wuffs_base__status__is_ok(v_z)) {
|
||||
self->private_impl.f_previous_lzw_decode_ended_abruptly = false;
|
||||
if (v_need_block_size || (v_block_size > 0)) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(3);
|
||||
self->private_impl.c_decode_id_part2[0].scratch =
|
||||
((uint32_t)(v_block_size));
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(4);
|
||||
@@ -9960,7 +9953,6 @@ wuffs_gzip__decoder__decode(wuffs_gzip__decoder* self,
|
||||
uint8_t t_3 = *iop_a_src++;
|
||||
v_flags = t_3;
|
||||
}
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(5);
|
||||
self->private_impl.c_decode[0].scratch = 6;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(6);
|
||||
if (self->private_impl.c_decode[0].scratch >
|
||||
@@ -10001,7 +9993,6 @@ wuffs_gzip__decoder__decode(wuffs_gzip__decoder* self,
|
||||
}
|
||||
v_xlen = t_4;
|
||||
}
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(9);
|
||||
self->private_impl.c_decode[0].scratch = ((uint32_t)(v_xlen));
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(10);
|
||||
if (self->private_impl.c_decode[0].scratch >
|
||||
@@ -10048,7 +10039,6 @@ wuffs_gzip__decoder__decode(wuffs_gzip__decoder* self,
|
||||
label_1_break:;
|
||||
}
|
||||
if ((v_flags & 2) != 0) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(13);
|
||||
self->private_impl.c_decode[0].scratch = 2;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(14);
|
||||
if (self->private_impl.c_decode[0].scratch >
|
||||
|
||||
Reference in new issue
Block a user