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")
return nil
case t.IDSkip32:
case t.IDSkip, t.IDSkip32:
x := n.Args()[0].AsArg().Value()
if cv := x.ConstValue(); cv != nil && cv.Cmp(one) == 0 {
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.take!(n: u64) slice u8",
"io_reader.skip?(n: u64)",
"io_reader.skip32?(n: u32)",
// TODO: this should have explicit pre-conditions "actual <= worst_case"
+5 -3
View File
@@ -492,9 +492,10 @@ const (
IDMark = ID(0x163)
IDPosition = ID(0x164)
IDSince = ID(0x165)
IDSkip32 = ID(0x166)
IDSkip32Fast = ID(0x167)
IDTake = ID(0x168)
IDSkip = ID(0x166)
IDSkip32 = ID(0x167)
IDSkip32Fast = ID(0x168)
IDTake = ID(0x169)
IDCopyFromSlice = ID(0x170)
IDCopyN32FromHistory = ID(0x171)
@@ -834,6 +835,7 @@ var builtInsByID = [nBuiltInIDs]string{
IDMark: "mark",
IDPosition: "position",
IDSince: "since",
IDSkip: "skip",
IDSkip32: "skip32",
IDSkip32Fast: "skip32_fast",
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_total_bytes =
(v_bytes_per_row * ((uint64_t)(self->private_impl.f_height)));
self->private_data.s_skip_frame[0].scratch =
((uint32_t)((v_total_bytes & 4294967295)));
self->private_data.s_skip_frame[0].scratch = v_total_bytes;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
if (self->private_data.s_skip_frame[0].scratch >
((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
total_bytes = bytes_per_row * (this.height as base.u64)
// TODO: total_bytes may be larger than UINT32_MAX.
args.src.skip32?(n: (total_bytes & 0xFFFFFFFF) as base.u32)
args.src.skip?(n: total_bytes)
this.seen_frame = true
this.call_sequence = 2