Rename io_writer.history_available

This commit is contained in:
Nigel Tao committed 2020-08-13 23:29:59 +10:00
1 parent be8542e313
commit 3c3d58bfe7
6 files changed
+39 -39

No files matched your search

+1 -1
View File
@@ -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) b.printf(", ((uint64_t)(%s%s - %s%s)))", iopPrefix, name, io0Prefix, name)
return nil return nil
case t.IDHistoryAvailable, t.IDMark: case t.IDHistoryLength, t.IDMark:
b.printf("((uint64_t)(%s%s - %s%s))", iopPrefix, name, io0Prefix, name) b.printf("((uint64_t)(%s%s - %s%s))", iopPrefix, name, io0Prefix, name)
return nil return nil
+1 -1
View File
@@ -446,7 +446,7 @@ var Funcs = []string{
"io_writer.write_u64le_fast!(a: u64)", "io_writer.write_u64le_fast!(a: u64)",
"io_writer.count_since(mark: u64) u64", "io_writer.count_since(mark: u64) u64",
"io_writer.history_available() u64", "io_writer.history_length() u64",
"io_writer.length() u64", "io_writer.length() u64",
"io_writer.mark() u64", "io_writer.mark() u64",
"io_writer.position() u64", "io_writer.position() u64",
+5 -5
View File
@@ -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: // As per cgen's io-private.h, there are three pre-conditions:
// - n <= this.length() // - n <= this.length()
// - distance > 0 // - distance > 0
// - distance <= this.history_available() // - distance <= this.history_length()
if len(args) != 2 { if len(args) != 2 {
return fmt.Errorf("check: internal error: inconsistent copy_n_from_history_fast arguments") 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") return fmt.Errorf("check: could not prove distance > 0")
} }
// Check "distance <= this.history_available()". // Check "distance <= this.history_length()".
check2: check2:
for { for {
for _, x := range q.facts { for _, x := range q.facts {
@@ -1198,9 +1198,9 @@ check2:
continue continue
} }
// Check that the RHS is "recv.history_available()". // Check that the RHS is "recv.history_length()".
y, method, yArgs := splitReceiverMethodArgs(x.RHS().AsExpr()) y, method, yArgs := splitReceiverMethodArgs(x.RHS().AsExpr())
if method != t.IDHistoryAvailable || len(yArgs) != 0 { if method != t.IDHistoryLength || len(yArgs) != 0 {
continue continue
} }
if !y.Eq(recv) { if !y.Eq(recv) {
@@ -1209,7 +1209,7 @@ check2:
break 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 return nil
+26 -26
View File
@@ -503,19 +503,19 @@ const (
IDDecodeFrameOptions = ID(0x158) IDDecodeFrameOptions = ID(0x158)
IDCanUndoByte = ID(0x160) IDCanUndoByte = ID(0x160)
IDCountSince = ID(0x161) IDCountSince = ID(0x161)
IDHistoryAvailable = ID(0x162) IDHistoryLength = ID(0x162)
IDIsClosed = ID(0x163) IDIsClosed = ID(0x163)
IDMark = ID(0x164) IDMark = ID(0x164)
IDMatch15 = ID(0x165) IDMatch15 = ID(0x165)
IDMatch31 = ID(0x166) IDMatch31 = ID(0x166)
IDMatch7 = ID(0x167) IDMatch7 = ID(0x167)
IDPosition = ID(0x168) IDPosition = ID(0x168)
IDSince = ID(0x169) IDSince = ID(0x169)
IDSkip = ID(0x16A) IDSkip = ID(0x16A)
IDSkipU32 = ID(0x16B) IDSkipU32 = ID(0x16B)
IDSkipU32Fast = ID(0x16C) IDSkipU32Fast = ID(0x16C)
IDCopyFromSlice = ID(0x170) IDCopyFromSlice = ID(0x170)
IDLimitedCopyU32FromHistory = ID(0x171) IDLimitedCopyU32FromHistory = ID(0x171)
@@ -870,19 +870,19 @@ var builtInsByID = [nBuiltInIDs]string{
IDDecodeFrameOptions: "decode_frame_options", IDDecodeFrameOptions: "decode_frame_options",
IDCanUndoByte: "can_undo_byte", IDCanUndoByte: "can_undo_byte",
IDCountSince: "count_since", IDCountSince: "count_since",
IDHistoryAvailable: "history_available", IDHistoryLength: "history_length",
IDIsClosed: "is_closed", IDIsClosed: "is_closed",
IDMark: "mark", IDMark: "mark",
IDMatch15: "match15", IDMatch15: "match15",
IDMatch31: "match31", IDMatch31: "match31",
IDMatch7: "match7", IDMatch7: "match7",
IDPosition: "position", IDPosition: "position",
IDSince: "since", IDSince: "since",
IDSkip: "skip", IDSkip: "skip",
IDSkipU32: "skip_u32", IDSkipU32: "skip_u32",
IDSkipU32Fast: "skip_u32_fast", IDSkipU32Fast: "skip_u32_fast",
IDCopyFromSlice: "copy_from_slice", IDCopyFromSlice: "copy_from_slice",
IDLimitedCopyU32FromHistory: "limited_copy_u32_from_history", IDLimitedCopyU32FromHistory: "limited_copy_u32_from_history",
+4 -4
View File
@@ -290,12 +290,12 @@ pri func decoder.decode_huffman_fast!(dst: base.io_writer, src: base.io_reader)
pre args.dst.length() >= 258, pre args.dst.length() >= 258,
{ {
// Copy from this.history. // 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 // Set (hlen, hdist) to be the length-distance pair to copy
// from this.history, and (length, distance) to be the // from this.history, and (length, distance) to be the
// remaining length-distance pair to copy from args.dst. // remaining length-distance pair to copy from args.dst.
hlen = 0 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 { if length > hdist {
assert hdist < length via "a < b: b > a"() assert hdist < length via "a < b: b > a"()
assert hdist < 0x8000 via "a < b: a < c; c <= b"(c: length) 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 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" return "#internal error: inconsistent distance"
} }
} }
// Once again, redundant but explicit assertions. // 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 assert args.dst.length() >= 258
// We can therefore prove: // We can therefore prove:
+2 -2
View File
@@ -203,11 +203,11 @@ pri func decoder.decode_huffman_slow?(dst: base.io_writer, src: base.io_reader)
while true { while true {
// Copy from this.history. // 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 // Set (hlen, hdist) to be the length-distance pair to copy
// from this.history, and (length, distance) to be the // from this.history, and (length, distance) to be the
// remaining length-distance pair to copy from args.dst. // 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 { if length > hdist {
assert hdist < length via "a < b: b > a"() assert hdist < length via "a < b: b > a"()
assert hdist < 0x8000 via "a < b: a < c; c <= b"(c: length) assert hdist < 0x8000 via "a < b: a < c; c <= b"(c: length)