Add io_reader.skip

This commit is contained in:
Nigel Tao committed 2020-01-16 22:15:33 +11:00
1 parent 09ed091fe3
commit 6ef3ffe6c8
5 files changed
+9 -8

No files matched your search

+1 -1
View File
@@ -583,7 +583,7 @@ func (g *gen) writeBuiltinQuestionCall(b *buffer, n *a.Expr, depth uint32) error
b.printf(" = *iop_a_src++;\n") b.printf(" = *iop_a_src++;\n")
return nil return nil
case t.IDSkip32: case t.IDSkip, t.IDSkip32:
x := n.Args()[0].AsArg().Value() x := n.Args()[0].AsArg().Value()
if cv := x.ConstValue(); cv != nil && cv.Cmp(one) == 0 { if cv := x.ConstValue(); cv != nil && cv.Cmp(one) == 0 {
if err := g.writeCoroSuspPoint(b, false); err != nil { if err := g.writeCoroSuspPoint(b, false); err != nil {
+1
View File
@@ -235,6 +235,7 @@ var Funcs = []string{
"io_reader.since(mark: u64) slice u8", "io_reader.since(mark: u64) slice u8",
"io_reader.take!(n: u64) slice u8", "io_reader.take!(n: u64) slice u8",
"io_reader.skip?(n: u64)",
"io_reader.skip32?(n: u32)", "io_reader.skip32?(n: u32)",
// TODO: this should have explicit pre-conditions "actual <= worst_case" // TODO: this should have explicit pre-conditions "actual <= worst_case"
+5 -3
View File
@@ -492,9 +492,10 @@ const (
IDMark = ID(0x163) IDMark = ID(0x163)
IDPosition = ID(0x164) IDPosition = ID(0x164)
IDSince = ID(0x165) IDSince = ID(0x165)
IDSkip32 = ID(0x166) IDSkip = ID(0x166)
IDSkip32Fast = ID(0x167) IDSkip32 = ID(0x167)
IDTake = ID(0x168) IDSkip32Fast = ID(0x168)
IDTake = ID(0x169)
IDCopyFromSlice = ID(0x170) IDCopyFromSlice = ID(0x170)
IDCopyN32FromHistory = ID(0x171) IDCopyN32FromHistory = ID(0x171)
@@ -834,6 +835,7 @@ var builtInsByID = [nBuiltInIDs]string{
IDMark: "mark", IDMark: "mark",
IDPosition: "position", IDPosition: "position",
IDSince: "since", IDSince: "since",
IDSkip: "skip",
IDSkip32: "skip32", IDSkip32: "skip32",
IDSkip32Fast: "skip32_fast", IDSkip32Fast: "skip32_fast",
IDTake: "take", IDTake: "take",
+1 -2
View File
@@ -13533,8 +13533,7 @@ wuffs_wbmp__decoder__skip_frame(wuffs_wbmp__decoder* self,
v_bytes_per_row = ((((uint64_t)(self->private_impl.f_width)) + 7) / 8); v_bytes_per_row = ((((uint64_t)(self->private_impl.f_width)) + 7) / 8);
v_total_bytes = v_total_bytes =
(v_bytes_per_row * ((uint64_t)(self->private_impl.f_height))); (v_bytes_per_row * ((uint64_t)(self->private_impl.f_height)));
self->private_data.s_skip_frame[0].scratch = self->private_data.s_skip_frame[0].scratch = v_total_bytes;
((uint32_t)((v_total_bytes & 4294967295)));
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
if (self->private_data.s_skip_frame[0].scratch > if (self->private_data.s_skip_frame[0].scratch >
((uint64_t)(io2_a_src - iop_a_src))) { ((uint64_t)(io2_a_src - iop_a_src))) {
+1 -2
View File
@@ -207,8 +207,7 @@ pri func decoder.skip_frame?(src: base.io_reader) {
bytes_per_row = ((this.width as base.u64) + 7) / 8 bytes_per_row = ((this.width as base.u64) + 7) / 8
total_bytes = bytes_per_row * (this.height as base.u64) total_bytes = bytes_per_row * (this.height as base.u64)
// TODO: total_bytes may be larger than UINT32_MAX. args.src.skip?(n: total_bytes)
args.src.skip32?(n: (total_bytes & 0xFFFFFFFF) as base.u32)
this.seen_frame = true this.seen_frame = true
this.call_sequence = 2 this.call_sequence = 2