Rename [i..j] to [i ..= j], the same as Rust

This commit is contained in:
Nigel Tao committed 2019-10-12 18:40:53 +11:00
1 parent 18c6e5716a
commit d501daddc3
18 files changed
+219 -206

No files matched your search

+1 -1
View File
@@ -13,7 +13,7 @@
// limitations under the License.
// code_order is defined in the RFC section 3.2.7.
pri const code_order array[19] base.u8[..18] = [
pri const code_order array[19] base.u8[..= 18] = [
16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15,
]
+42 -40
View File
@@ -71,7 +71,7 @@ pub struct decoder?(
history_index base.u32,
// n_huffs_bits is discussed in the huffs field comment.
n_huffs_bits array[2] base.u32[..9],
n_huffs_bits array[2] base.u32[..= 9],
// end_of_block is whether decode_huffman_xxx saw an end-of-block code.
//
@@ -99,17 +99,19 @@ pub struct decoder?(
// less, then more source bytes are read and the table lookup re-tried.
//
// The table value's bits:
// - bit 31 indicates a literal.
// - bit 30 indicates a base number + extra bits.
// - bit 29 indicates end-of-block.
// - bit 28 indicates a redirect to another part of the table.
// - bit 27 indicates an invalid value.
// - bits 26 .. 24 are zero.
// - bits 23 .. 8 are the redirect offset, literal (in bits 15-8) or base number.
// - bits 7 .. 4 are the redirected table's bits or number of extra bits.
// - bits 3 .. 0 are the number of decoder.bits to consume.
// - bit 31 indicates a literal.
// - bit 30 indicates a base number + extra bits.
// - bit 29 indicates end-of-block.
// - bit 28 indicates a redirect to another part of the table.
// - bit 27 indicates an invalid value.
// - bits 24 ..= 26 are zero.
// - bits 8 ..= 23 are the redirect offset, literal (in bits [8 ..= 15])
// or base number.
// - bits 4 ..= 7 are the redirected table's size in bits or the number
// of extra bits.
// - bits 0 ..= 3 are the number of decoder.bits to consume.
//
// Exactly one of the eight bits 31-24 should be set.
// Exactly one of the eight bits [24 ..= 31] should be set.
huffs array[2] array[huffs_table_size] base.u32,
// history holds up to the last 32KiB of decoded output, if the decoding
@@ -135,7 +137,7 @@ pub struct decoder?(
pub func decoder.add_history!(hist slice base.u8) {
var s slice base.u8
var n_copied base.u64
var already_full base.u32[..0x8000]
var already_full base.u32[..= 0x8000]
s = args.hist
if s.length() >= 0x8000 {
@@ -201,7 +203,7 @@ pub func decoder.decode_io_writer?(dst base.io_writer, src base.io_reader, workb
pri func decoder.decode_blocks?(dst base.io_writer, src base.io_reader) {
var final base.u32
var b0 base.u32[..255]
var b0 base.u32[..= 255]
var type base.u32
var status base.status
@@ -330,21 +332,21 @@ pri func decoder.init_fixed_huffman!() base.status {
pri func decoder.init_dynamic_huffman?(src base.io_reader) {
var bits base.u32
var n_bits base.u32
var b0 base.u32[..255]
var n_lit base.u32[..288]
var n_dist base.u32[..32]
var n_clen base.u32[..19]
var b0 base.u32[..= 255]
var n_lit base.u32[..= 288]
var n_dist base.u32[..= 32]
var n_clen base.u32[..= 19]
var i base.u32
var b1 base.u32[..255]
var b1 base.u32[..= 255]
var status base.status
var mask base.u32[..511]
var mask base.u32[..= 511]
var table_entry base.u32
var table_entry_n_bits base.u32[..15]
var b2 base.u32[..255]
var n_extra_bits base.u32[..7]
var rep_symbol base.u8[..15]
var table_entry_n_bits base.u32[..= 15]
var b2 base.u32[..= 255]
var n_extra_bits base.u32[..= 7]
var rep_symbol base.u8[..= 15]
var rep_count base.u32
var b3 base.u32[..255]
var b3 base.u32[..= 255]
bits = this.bits
n_bits = this.n_bits
@@ -504,29 +506,29 @@ pri func decoder.init_dynamic_huffman?(src base.io_reader) {
// TODO: make named constants for 15, 19, 319, etc.
pri func decoder.init_huff!(which base.u32[..1], n_codes0 base.u32[..288], n_codes1 base.u32[..320], base_symbol base.u32) base.status {
var counts array[16] base.u16[..320]
pri func decoder.init_huff!(which base.u32[..= 1], n_codes0 base.u32[..= 288], n_codes1 base.u32[..= 320], base_symbol base.u32) base.status {
var counts array[16] base.u16[..= 320]
var i base.u32
var remaining base.u32
var offsets array[16] base.u16[..320]
var n_symbols base.u32[..320]
var count base.u32[..320]
var symbols array[320] base.u16[..319]
var min_cl base.u32[..9]
var max_cl base.u32[..15]
var offsets array[16] base.u16[..= 320]
var n_symbols base.u32[..= 320]
var count base.u32[..= 320]
var symbols array[320] base.u16[..= 319]
var min_cl base.u32[..= 9]
var max_cl base.u32[..= 15]
var initial_high_bits base.u32
var prev_cl base.u32[..15]
var prev_cl base.u32[..= 15]
var prev_redirect_key base.u32
var top base.u32[..huffs_table_size]
var next_top base.u32[..huffs_table_size]
var top base.u32[..= huffs_table_size]
var next_top base.u32[..= huffs_table_size]
var code base.u32
var key base.u32
var value base.u32
var cl base.u32[..15]
var redirect_key base.u32[..511]
var j base.u32[..16]
var reversed_key base.u32[..511]
var symbol base.u32[..319]
var cl base.u32[..= 15]
var redirect_key base.u32[..= 511]
var j base.u32[..= 16]
var reversed_key base.u32[..= 511]
var symbol base.u32[..= 319]
var high_bits base.u32
var delta base.u32
+8 -8
View File
@@ -23,15 +23,15 @@ pri func decoder.decode_huffman_fast!(dst base.io_writer, src base.io_reader) ba
var bits base.u32
var n_bits base.u32
var table_entry base.u32
var table_entry_n_bits base.u32[..15]
var lmask base.u32[..511]
var dmask base.u32[..511]
var redir_top base.u32[..0xFFFF]
var redir_mask base.u32[..0x7FFF]
var length base.u32[..258]
var dist_minus_1 base.u32[..0x7FFF]
var table_entry_n_bits base.u32[..= 15]
var lmask base.u32[..= 511]
var dmask base.u32[..= 511]
var redir_top base.u32[..= 0xFFFF]
var redir_mask base.u32[..= 0x7FFF]
var length base.u32[..= 258]
var dist_minus_1 base.u32[..= 0x7FFF]
var n_copied base.u32
var hlen base.u32[..0x7FFF]
var hlen base.u32[..= 0x7FFF]
var hdist base.u32
if (this.n_bits >= 8) or ((this.bits >> (this.n_bits & 7)) <> 0) {
+14 -14
View File
@@ -16,21 +16,21 @@ pri func decoder.decode_huffman_slow?(dst base.io_writer, src base.io_reader) {
var bits base.u32
var n_bits base.u32
var table_entry base.u32
var table_entry_n_bits base.u32[..15]
var lmask base.u32[..511]
var dmask base.u32[..511]
var b0 base.u32[..255]
var redir_top base.u32[..0xFFFF]
var redir_mask base.u32[..0x7FFF]
var b1 base.u32[..255]
var length base.u32[..258]
var b2 base.u32[..255]
var b3 base.u32[..255]
var b4 base.u32[..255]
var dist_minus_1 base.u32[..0x7FFF]
var b5 base.u32[..255]
var table_entry_n_bits base.u32[..= 15]
var lmask base.u32[..= 511]
var dmask base.u32[..= 511]
var b0 base.u32[..= 255]
var redir_top base.u32[..= 0xFFFF]
var redir_mask base.u32[..= 0x7FFF]
var b1 base.u32[..= 255]
var length base.u32[..= 258]
var b2 base.u32[..= 255]
var b3 base.u32[..= 255]
var b4 base.u32[..= 255]
var dist_minus_1 base.u32[..= 0x7FFF]
var b5 base.u32[..= 255]
var n_copied base.u32
var hlen base.u32[..0x7FFF]
var hlen base.u32[..= 0x7FFF]
var hdist base.u32
// When editing this function, consider making the equivalent change to the
+9 -9
View File
@@ -184,7 +184,7 @@ pub struct decoder?(
has_global_palette base.bool,
// interlace indexes the interlace_start and interlace_delta arrays.
interlace base.u8[..4],
interlace base.u8[..= 4],
// Absent an ANIMEXTS1.0 or NETSCAPE2.0 extension, the implicit number of
// animation loops is 1.
@@ -198,7 +198,7 @@ pub struct decoder?(
gc_transparent_index base.u8,
gc_disposal base.u8,
// There are 7056000 flicks per centisecond.
gc_duration base.u64[..0xFFFF * 7056000],
gc_duration base.u64[..= 0xFFFF * 7056000],
frame_config_io_position base.u64,
num_decoded_frame_configs_value base.u64,
@@ -582,9 +582,9 @@ pri func decoder.decode_header?(src base.io_reader) {
pri func decoder.decode_lsd?(src base.io_reader) {
var flags base.u8
var background_color_index base.u8
var num_palette_entries base.u32[..256]
var num_palette_entries base.u32[..= 256]
var i base.u32
var j base.u32[..1020]
var j base.u32[..= 1020]
var argb base.u32
this.width = args.src.read_u16le_as_u32?()
@@ -828,7 +828,7 @@ pri func decoder.decode_gc?(src base.io_reader) {
// Convert the disposal method from GIF's wire format to Wuffs constants.
//
// The GIF spec discusses the 3-bit flag value being 0, 1, 2 or 3. Values
// in the range [4..7] are "to be defined". In practice, some encoders also
// in the range [4 ..= 7] are "to be defined". In practice, some encoders also
// use 4 for "restore previous". See
// https://cs.chromium.org/chromium/src/third_party/blink/renderer/platform/image-decoders/gif/gif_image_reader.cc?rcl=5161173c43324da2b13e1aa45bbe69901daa1279&l=625
//
@@ -889,8 +889,8 @@ pri func decoder.decode_id_part0?(src base.io_reader) {
pri func decoder.decode_id_part1?(dst ptr base.pixel_buffer, src base.io_reader) {
var flags base.u8
var which_palette base.u8[..1]
var num_palette_entries base.u32[..256]
var which_palette base.u8[..= 1]
var num_palette_entries base.u32[..= 256]
var i base.u32
var argb base.u32
var dst_palette slice base.u8
@@ -993,7 +993,7 @@ pri func decoder.decode_id_part1?(dst ptr base.pixel_buffer, src base.io_reader)
}
pri func decoder.decode_id_part2?(dst ptr base.pixel_buffer, src base.io_reader, workbuf slice base.u8) {
var block_size base.u64[..255]
var block_size base.u64[..= 255]
var need_block_size base.bool
var n_compressed base.u64
var compressed slice base.u8
@@ -1099,7 +1099,7 @@ pri func decoder.copy_to_image_buffer!(pb ptr base.pixel_buffer, src slice base.
var width_in_bytes base.u64
var n base.u64
var src_ri base.u64
var bytes_per_pixel base.u32[..64]
var bytes_per_pixel base.u32[..= 64]
var pixfmt_channels base.u32
var tab table base.u8
var i base.u64
+25 -25
View File
@@ -31,21 +31,21 @@ pub struct decoder?(
// set_literal_width. This is assigned to the literal_width field at the
// start of decode_io_writer. During that method, calling set_literal_width
// will change set_literal_width_arg but not literal_width.
set_literal_width_arg base.u32[..9],
set_literal_width_arg base.u32[..= 9],
// read_from state that does not change during a decode call.
literal_width base.u32[..8],
clear_code base.u32[..256],
end_code base.u32[..257],
literal_width base.u32[..= 8],
clear_code base.u32[..= 256],
end_code base.u32[..= 257],
// read_from state that does change during a decode call.
save_code base.u32[..4096],
prev_code base.u32[..4095],
width base.u32[..12],
save_code base.u32[..= 4096],
prev_code base.u32[..= 4095],
width base.u32[..= 12],
bits base.u32,
n_bits base.u32[..31],
output_ri base.u32[..8191],
output_wi base.u32[..8191],
n_bits base.u32[..= 31],
output_ri base.u32[..= 8191],
output_wi base.u32[..= 8191],
// read_from return value. The read_from method effectively returns a
// base.u32 to show how decode should continue after calling write_to. That
@@ -54,7 +54,7 @@ pub struct decoder?(
read_from_return_value base.u32,
// read_from per-code state.
prefixes array[4096] base.u16[..4095],
prefixes array[4096] base.u16[..= 4095],
util base.utility,
)(
@@ -69,7 +69,7 @@ pub struct decoder?(
output array[8192 + 7] base.u8,
)
pub func decoder.set_literal_width!(lw base.u32[..8]) {
pub func decoder.set_literal_width!(lw base.u32[..= 8]) {
this.set_literal_width_arg = args.lw + 1
}
@@ -78,7 +78,7 @@ pub func decoder.workbuf_len() base.range_ii_u64 {
}
pub func decoder.decode_io_writer?(dst base.io_writer, src base.io_reader, workbuf slice base.u8) {
var i base.u32[..8191]
var i base.u32[..= 8191]
// Initialize read_from state.
this.literal_width = 8
@@ -124,23 +124,23 @@ pub func decoder.decode_io_writer?(dst base.io_writer, src base.io_reader, workb
}
pri func decoder.read_from!(src base.io_reader) {
var clear_code base.u32[..256]
var end_code base.u32[..257]
var clear_code base.u32[..= 256]
var end_code base.u32[..= 257]
var save_code base.u32[..4096]
var prev_code base.u32[..4095]
var width base.u32[..12]
var save_code base.u32[..= 4096]
var prev_code base.u32[..= 4095]
var width base.u32[..= 12]
var bits base.u32
var n_bits base.u32[..31]
var output_wi base.u32[..8191]
var n_bits base.u32[..= 31]
var output_wi base.u32[..= 8191]
var code base.u32[..4095]
var c base.u32[..4095]
var o base.u32[..8191]
var code base.u32[..= 4095]
var c base.u32[..= 4095]
var o base.u32[..= 8191]
var steps base.u32
var first_byte base.u8
var lm1_b base.u16[..4095]
var lm1_a base.u16[..4095]
var lm1_b base.u16[..= 4095]
var lm1_a base.u16[..= 4095]
clear_code = this.clear_code
end_code = this.end_code