diff --git a/internal/cgen/builtin.go b/internal/cgen/builtin.go index 596b4aa2..37ffb5ef 100644 --- a/internal/cgen/builtin.go +++ b/internal/cgen/builtin.go @@ -328,7 +328,7 @@ func (g *gen) writeBuiltinIOWriter(b *buffer, recv *a.Expr, method t.ID, args [] b.printf(", ((uint64_t)(%s%s - %s%s)))", iopPrefix, name, io0Prefix, name) return nil - case t.IDHistoryAvailable, t.IDMark: + case t.IDHistoryLength, t.IDMark: b.printf("((uint64_t)(%s%s - %s%s))", iopPrefix, name, io0Prefix, name) return nil diff --git a/lang/builtin/builtin.go b/lang/builtin/builtin.go index c0e2d234..ed29f3ea 100644 --- a/lang/builtin/builtin.go +++ b/lang/builtin/builtin.go @@ -446,7 +446,7 @@ var Funcs = []string{ "io_writer.write_u64le_fast!(a: u64)", "io_writer.count_since(mark: u64) u64", - "io_writer.history_available() u64", + "io_writer.history_length() u64", "io_writer.length() u64", "io_writer.mark() u64", "io_writer.position() u64", diff --git a/lang/check/bounds.go b/lang/check/bounds.go index 13eacb1f..17b45099 100644 --- a/lang/check/bounds.go +++ b/lang/check/bounds.go @@ -1122,7 +1122,7 @@ func (q *checker) canLimitedCopyU32FromHistoryFast(recv *a.Expr, args []*a.Node) // As per cgen's io-private.h, there are three pre-conditions: // - n <= this.length() // - distance > 0 - // - distance <= this.history_available() + // - distance <= this.history_length() if len(args) != 2 { return fmt.Errorf("check: internal error: inconsistent copy_n_from_history_fast arguments") @@ -1180,7 +1180,7 @@ check1: return fmt.Errorf("check: could not prove distance > 0") } - // Check "distance <= this.history_available()". + // Check "distance <= this.history_length()". check2: for { for _, x := range q.facts { @@ -1198,9 +1198,9 @@ check2: continue } - // Check that the RHS is "recv.history_available()". + // Check that the RHS is "recv.history_length()". y, method, yArgs := splitReceiverMethodArgs(x.RHS().AsExpr()) - if method != t.IDHistoryAvailable || len(yArgs) != 0 { + if method != t.IDHistoryLength || len(yArgs) != 0 { continue } if !y.Eq(recv) { @@ -1209,7 +1209,7 @@ check2: break check2 } - return fmt.Errorf("check: could not prove distance <= %s.history_available()", recv.Str(q.tm)) + return fmt.Errorf("check: could not prove distance <= %s.history_length()", recv.Str(q.tm)) } return nil diff --git a/lang/token/list.go b/lang/token/list.go index e6a754e8..72a60ec6 100644 --- a/lang/token/list.go +++ b/lang/token/list.go @@ -503,19 +503,19 @@ const ( IDDecodeFrameOptions = ID(0x158) - IDCanUndoByte = ID(0x160) - IDCountSince = ID(0x161) - IDHistoryAvailable = ID(0x162) - IDIsClosed = ID(0x163) - IDMark = ID(0x164) - IDMatch15 = ID(0x165) - IDMatch31 = ID(0x166) - IDMatch7 = ID(0x167) - IDPosition = ID(0x168) - IDSince = ID(0x169) - IDSkip = ID(0x16A) - IDSkipU32 = ID(0x16B) - IDSkipU32Fast = ID(0x16C) + IDCanUndoByte = ID(0x160) + IDCountSince = ID(0x161) + IDHistoryLength = ID(0x162) + IDIsClosed = ID(0x163) + IDMark = ID(0x164) + IDMatch15 = ID(0x165) + IDMatch31 = ID(0x166) + IDMatch7 = ID(0x167) + IDPosition = ID(0x168) + IDSince = ID(0x169) + IDSkip = ID(0x16A) + IDSkipU32 = ID(0x16B) + IDSkipU32Fast = ID(0x16C) IDCopyFromSlice = ID(0x170) IDLimitedCopyU32FromHistory = ID(0x171) @@ -870,19 +870,19 @@ var builtInsByID = [nBuiltInIDs]string{ IDDecodeFrameOptions: "decode_frame_options", - IDCanUndoByte: "can_undo_byte", - IDCountSince: "count_since", - IDHistoryAvailable: "history_available", - IDIsClosed: "is_closed", - IDMark: "mark", - IDMatch15: "match15", - IDMatch31: "match31", - IDMatch7: "match7", - IDPosition: "position", - IDSince: "since", - IDSkip: "skip", - IDSkipU32: "skip_u32", - IDSkipU32Fast: "skip_u32_fast", + IDCanUndoByte: "can_undo_byte", + IDCountSince: "count_since", + IDHistoryLength: "history_length", + IDIsClosed: "is_closed", + IDMark: "mark", + IDMatch15: "match15", + IDMatch31: "match31", + IDMatch7: "match7", + IDPosition: "position", + IDSince: "since", + IDSkip: "skip", + IDSkipU32: "skip_u32", + IDSkipU32Fast: "skip_u32_fast", IDCopyFromSlice: "copy_from_slice", IDLimitedCopyU32FromHistory: "limited_copy_u32_from_history", diff --git a/std/deflate/decode_huffman_fast.wuffs b/std/deflate/decode_huffman_fast.wuffs index fce0b9c7..22260cbe 100644 --- a/std/deflate/decode_huffman_fast.wuffs +++ b/std/deflate/decode_huffman_fast.wuffs @@ -290,12 +290,12 @@ pri func decoder.decode_huffman_fast!(dst: base.io_writer, src: base.io_reader) pre args.dst.length() >= 258, { // Copy from this.history. - if ((dist_minus_1 + 1) as base.u64) > args.dst.history_available() { + if ((dist_minus_1 + 1) as base.u64) > args.dst.history_length() { // Set (hlen, hdist) to be the length-distance pair to copy // from this.history, and (length, distance) to be the // remaining length-distance pair to copy from args.dst. hlen = 0 - hdist = (((dist_minus_1 + 1) as base.u64) - args.dst.history_available()) as base.u32 + hdist = (((dist_minus_1 + 1) as base.u64) - args.dst.history_length()) as base.u32 if length > hdist { assert hdist < length via "a < b: b > a"() assert hdist < 0x8000 via "a < b: a < c; c <= b"(c: length) @@ -325,12 +325,12 @@ pri func decoder.decode_huffman_fast!(dst: base.io_writer, src: base.io_reader) continue.loop } - if ((dist_minus_1 + 1) as base.u64) > args.dst.history_available() { + if ((dist_minus_1 + 1) as base.u64) > args.dst.history_length() { return "#internal error: inconsistent distance" } } // Once again, redundant but explicit assertions. - assert ((dist_minus_1 + 1) as base.u64) <= args.dst.history_available() + assert ((dist_minus_1 + 1) as base.u64) <= args.dst.history_length() assert args.dst.length() >= 258 // We can therefore prove: diff --git a/std/deflate/decode_huffman_slow.wuffs b/std/deflate/decode_huffman_slow.wuffs index 044aa35e..48568b81 100644 --- a/std/deflate/decode_huffman_slow.wuffs +++ b/std/deflate/decode_huffman_slow.wuffs @@ -203,11 +203,11 @@ pri func decoder.decode_huffman_slow?(dst: base.io_writer, src: base.io_reader) while true { // Copy from this.history. - if ((dist_minus_1 + 1) as base.u64) > args.dst.history_available() { + if ((dist_minus_1 + 1) as base.u64) > args.dst.history_length() { // Set (hlen, hdist) to be the length-distance pair to copy // from this.history, and (length, distance) to be the // remaining length-distance pair to copy from args.dst. - hdist = (((dist_minus_1 + 1) as base.u64) - args.dst.history_available()) as base.u32 + hdist = (((dist_minus_1 + 1) as base.u64) - args.dst.history_length()) as base.u32 if length > hdist { assert hdist < length via "a < b: b > a"() assert hdist < 0x8000 via "a < b: a < c; c <= b"(c: length)