mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-23 08:47:56 +01:00
Rename [i:j] to [i .. j], the same as Rust
This commit is contained in:
1 parent
7872a8893b
commit
a9ea63ff06
16 files changed
+55
-50
No files matched your search
@@ -37,6 +37,7 @@ faster than Wuffs version 0.1 and about 2x faster than giflib (the C library).
|
|||||||
- Removed `&^`.
|
- Removed `&^`.
|
||||||
- Renamed `$(etc)` to `[etc]`.
|
- Renamed `$(etc)` to `[etc]`.
|
||||||
- Renamed `[i..j]` to `[i ..= j]`, consistent with Rust syntax.
|
- Renamed `[i..j]` to `[i ..= j]`, consistent with Rust syntax.
|
||||||
|
- Renamed `[i:j]` to `[i .. j]`, consistent with Rust syntax.
|
||||||
- Renamed `[N] T` and `[] T` types to `array[N] T` and `slice T`.
|
- Renamed `[N] T` and `[] T` types to `array[N] T` and `slice T`.
|
||||||
- Renamed `while:label` to `while.label`.
|
- Renamed `while:label` to `while.label`.
|
||||||
- Renamed `u32`, `buf1`, etc to `base.u32`, `base.io_buffer`, etc.
|
- Renamed `u32`, `buf1`, etc to `base.u32`, `base.io_buffer`, etc.
|
||||||
|
|||||||
@@ -434,7 +434,7 @@ func (g *gen) writeBuiltinSlice(b *buffer, recv *a.Expr, method t.ID, args []*a.
|
|||||||
|
|
||||||
// writeBuiltinSliceCopyFromSlice8 writes an optimized version of:
|
// writeBuiltinSliceCopyFromSlice8 writes an optimized version of:
|
||||||
//
|
//
|
||||||
// foo[fIndex:fIndex + 8].copy_from_slice!(s:bar[bIndex:bIndex + 8])
|
// foo[fIndex .. fIndex + 8].copy_from_slice!(s:bar[bIndex .. bIndex + 8])
|
||||||
func (g *gen) writeBuiltinSliceCopyFromSlice8(b *buffer, recv *a.Expr, method t.ID, args []*a.Node, depth uint32) error {
|
func (g *gen) writeBuiltinSliceCopyFromSlice8(b *buffer, recv *a.Expr, method t.ID, args []*a.Node, depth uint32) error {
|
||||||
if method != t.IDCopyFromSlice || len(args) != 1 {
|
if method != t.IDCopyFromSlice || len(args) != 1 {
|
||||||
return errOptimizationNotApplicable
|
return errOptimizationNotApplicable
|
||||||
@@ -475,10 +475,10 @@ func (g *gen) writeBuiltinSliceCopyFromSlice8(b *buffer, recv *a.Expr, method t.
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// matchFooIndexIndexPlus8 matches n with "foo[index:index + 8]" or "foo[:8]".
|
// matchFooIndexIndexPlus8 matches n with "foo[index .. index + 8]" or "foo[..
|
||||||
// It returns a nil foo if there isn't a match.
|
// 8]". It returns a nil foo if there isn't a match.
|
||||||
func matchFooIndexIndexPlus8(n *a.Expr) (foo *a.Expr, index *a.Expr) {
|
func matchFooIndexIndexPlus8(n *a.Expr) (foo *a.Expr, index *a.Expr) {
|
||||||
if n.Operator() != t.IDColon {
|
if n.Operator() != t.IDDotDot {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
foo = n.LHS().AsExpr()
|
foo = n.LHS().AsExpr()
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ func (g *gen) writeExprOther(b *buffer, n *a.Expr, depth uint32) error {
|
|||||||
b.writeb(']')
|
b.writeb(']')
|
||||||
return nil
|
return nil
|
||||||
|
|
||||||
case t.IDColon:
|
case t.IDDotDot:
|
||||||
// n is a slice.
|
// n is a slice.
|
||||||
lhs := n.LHS().AsExpr()
|
lhs := n.LHS().AsExpr()
|
||||||
mhs := n.MHS().AsExpr()
|
mhs := n.MHS().AsExpr()
|
||||||
|
|||||||
+2
-2
@@ -293,7 +293,7 @@ func (n *Raw) SetPackage(tm *t.Map, pkg t.ID) error {
|
|||||||
const MaxExprDepth = 255
|
const MaxExprDepth = 255
|
||||||
|
|
||||||
// Expr is an expression, such as "i", "+j" or "k + l[m(n, o)].p":
|
// Expr is an expression, such as "i", "+j" or "k + l[m(n, o)].p":
|
||||||
// - ID0: <0|operator|IDOpenParen|IDOpenBracket|IDColon|IDDot>
|
// - ID0: <0|operator|IDOpenParen|IDOpenBracket|IDDotDot|IDDot>
|
||||||
// - ID1: <0|pkg> (for statuses)
|
// - ID1: <0|pkg> (for statuses)
|
||||||
// - ID2: <0|literal|ident>
|
// - ID2: <0|literal|ident>
|
||||||
// - LHS: <nil|Expr>
|
// - LHS: <nil|Expr>
|
||||||
@@ -318,7 +318,7 @@ const MaxExprDepth = 255
|
|||||||
//
|
//
|
||||||
// For indexes, like "LHS[RHS]", ID0 is IDOpenBracket.
|
// For indexes, like "LHS[RHS]", ID0 is IDOpenBracket.
|
||||||
//
|
//
|
||||||
// For slices, like "LHS[MHS:RHS]", ID0 is IDColon.
|
// For slices, like "LHS[MHS .. RHS]", ID0 is IDDotDot.
|
||||||
//
|
//
|
||||||
// For selectors, like "LHS.ID2", ID0 is IDDot.
|
// For selectors, like "LHS.ID2", ID0 is IDDot.
|
||||||
//
|
//
|
||||||
|
|||||||
+10
-4
@@ -105,12 +105,18 @@ func (n *Expr) appendStr(buf []byte, tm *t.Map, parenthesize bool, depth uint32)
|
|||||||
buf = n.rhs.AsExpr().appendStr(buf, tm, false, depth)
|
buf = n.rhs.AsExpr().appendStr(buf, tm, false, depth)
|
||||||
buf = append(buf, ']')
|
buf = append(buf, ']')
|
||||||
|
|
||||||
case t.IDColon:
|
case t.IDDotDot:
|
||||||
buf = n.lhs.AsExpr().appendStr(buf, tm, true, depth)
|
buf = n.lhs.AsExpr().appendStr(buf, tm, true, depth)
|
||||||
buf = append(buf, '[')
|
buf = append(buf, '[')
|
||||||
buf = n.mhs.AsExpr().appendStr(buf, tm, false, depth)
|
if n.mhs != nil {
|
||||||
buf = append(buf, ':')
|
buf = n.mhs.AsExpr().appendStr(buf, tm, false, depth)
|
||||||
buf = n.rhs.AsExpr().appendStr(buf, tm, false, depth)
|
buf = append(buf, ' ')
|
||||||
|
}
|
||||||
|
buf = append(buf, ".."...)
|
||||||
|
if n.rhs != nil {
|
||||||
|
buf = append(buf, ' ')
|
||||||
|
buf = n.rhs.AsExpr().appendStr(buf, tm, false, depth)
|
||||||
|
}
|
||||||
buf = append(buf, ']')
|
buf = append(buf, ']')
|
||||||
|
|
||||||
case t.IDDot:
|
case t.IDDot:
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ func TestString(tt *testing.T) {
|
|||||||
|
|
||||||
"x[i]",
|
"x[i]",
|
||||||
"x[i][j]",
|
"x[i][j]",
|
||||||
"x[i:j]",
|
"x[i .. j]",
|
||||||
"x[i](arg:j)",
|
"x[i](arg:j)",
|
||||||
"x(arg:i)[j]",
|
"x(arg:i)[j]",
|
||||||
|
|
||||||
@@ -56,7 +56,7 @@ func TestString(tt *testing.T) {
|
|||||||
"x * ((a / b) - (i / j))",
|
"x * ((a / b) - (i / j))",
|
||||||
|
|
||||||
"x + y + z",
|
"x + y + z",
|
||||||
"x + (i * j.k[l] * (-m << 4) * (n & o(o0:p, o1:q[:r.s + 5]))) + z",
|
"x + (i * j.k[l] * (-m << 4) * (n & o(o0:p, o1:q[.. r.s + 5]))) + z",
|
||||||
|
|
||||||
"x as base.bool",
|
"x as base.bool",
|
||||||
"x as base.u32",
|
"x as base.u32",
|
||||||
|
|||||||
@@ -870,7 +870,7 @@ func (q *checker) bcheckExprOther(n *a.Expr, depth uint32) (bounds, error) {
|
|||||||
return bounds{}, err
|
return bounds{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
case t.IDColon:
|
case t.IDDotDot:
|
||||||
lhs := n.LHS().AsExpr()
|
lhs := n.LHS().AsExpr()
|
||||||
if _, err := q.bcheckExpr(lhs, depth); err != nil {
|
if _, err := q.bcheckExpr(lhs, depth); err != nil {
|
||||||
return bounds{}, err
|
return bounds{}, err
|
||||||
|
|||||||
+2
-2
@@ -434,9 +434,9 @@ func (q *checker) tcheckExprOther(n *a.Expr, depth uint32) error {
|
|||||||
n.SetMType(lTyp.Inner())
|
n.SetMType(lTyp.Inner())
|
||||||
return nil
|
return nil
|
||||||
|
|
||||||
case t.IDColon:
|
case t.IDDotDot:
|
||||||
// n is a slice.
|
// n is a slice.
|
||||||
// TODO: require that the i and j in a[i:j] are *unsigned* (or
|
// TODO: require that the i and j in a[i .. j] are *unsigned* (or
|
||||||
// non-negative constants)?
|
// non-negative constants)?
|
||||||
if mhs := n.MHS().AsExpr(); mhs != nil {
|
if mhs := n.MHS().AsExpr(); mhs != nil {
|
||||||
if err := q.tcheckExpr(mhs, depth); err != nil {
|
if err := q.tcheckExpr(mhs, depth); err != nil {
|
||||||
|
|||||||
+7
-7
@@ -441,10 +441,10 @@ func (p *parser) parseTypeExpr() (*a.TypeExpr, error) {
|
|||||||
return a.NewTypeExpr(0, pkg, name, lhs.AsNode(), mhs, nil), nil
|
return a.NewTypeExpr(0, pkg, name, lhs.AsNode(), mhs, nil), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// parseBracket parses "[i:j]", "[i:]", "[:j]" and "[:]". A "..=" replaces the
|
// parseBracket parses "[i .. j]", "[i ..]", "[.. j]" and "[..]". A "..="
|
||||||
// ":" if sep is t.IDDotDotEq instead of t.IDColon. If sep is t.IDColon, it
|
// replaces the ".." if sep is t.IDDotDotEq instead of t.IDDotDot. If sep is
|
||||||
// also parses "[x]". The returned op is sep for a range or refinement and
|
// t.IDDotDot, it also parses "[x]". The returned op is sep for a range or
|
||||||
// t.IDOpenBracket for an index.
|
// refinement and t.IDOpenBracket for an index.
|
||||||
func (p *parser) parseBracket(sep t.ID) (op t.ID, ei *a.Expr, ej *a.Expr, err error) {
|
func (p *parser) parseBracket(sep t.ID) (op t.ID, ei *a.Expr, ej *a.Expr, err error) {
|
||||||
if x := p.peek1(); x != t.IDOpenBracket {
|
if x := p.peek1(); x != t.IDOpenBracket {
|
||||||
got := p.tm.ByID(x)
|
got := p.tm.ByID(x)
|
||||||
@@ -463,13 +463,13 @@ func (p *parser) parseBracket(sep t.ID) (op t.ID, ei *a.Expr, ej *a.Expr, err er
|
|||||||
case x == sep:
|
case x == sep:
|
||||||
p.src = p.src[1:]
|
p.src = p.src[1:]
|
||||||
|
|
||||||
case x == t.IDCloseBracket && sep == t.IDColon:
|
case x == t.IDCloseBracket && sep == t.IDDotDot:
|
||||||
p.src = p.src[1:]
|
p.src = p.src[1:]
|
||||||
return t.IDOpenBracket, nil, ei, nil
|
return t.IDOpenBracket, nil, ei, nil
|
||||||
|
|
||||||
default:
|
default:
|
||||||
extra := ``
|
extra := ``
|
||||||
if sep == t.IDColon {
|
if sep == t.IDDotDot {
|
||||||
extra = ` or "]"`
|
extra = ` or "]"`
|
||||||
}
|
}
|
||||||
got := p.tm.ByID(x)
|
got := p.tm.ByID(x)
|
||||||
@@ -1177,7 +1177,7 @@ func (p *parser) parseOperand() (*a.Expr, error) {
|
|||||||
lhs = a.NewExpr(flags, t.IDOpenParen, 0, 0, lhs.AsNode(), nil, nil, args)
|
lhs = a.NewExpr(flags, t.IDOpenParen, 0, 0, lhs.AsNode(), nil, nil, args)
|
||||||
|
|
||||||
case t.IDOpenBracket:
|
case t.IDOpenBracket:
|
||||||
id0, mhs, rhs, err := p.parseBracket(t.IDColon)
|
id0, mhs, rhs, err := p.parseBracket(t.IDDotDot)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1172,7 +1172,6 @@ var isTightLeft = [...]bool{
|
|||||||
IDCloseBracket: true,
|
IDCloseBracket: true,
|
||||||
|
|
||||||
IDDot: true,
|
IDDot: true,
|
||||||
IDDotDot: true,
|
|
||||||
IDComma: true,
|
IDComma: true,
|
||||||
IDExclam: true,
|
IDExclam: true,
|
||||||
IDQuestion: true,
|
IDQuestion: true,
|
||||||
@@ -1184,7 +1183,6 @@ var isTightRight = [...]bool{
|
|||||||
IDOpenBracket: true,
|
IDOpenBracket: true,
|
||||||
|
|
||||||
IDDot: true,
|
IDDot: true,
|
||||||
IDDotDot: true,
|
|
||||||
IDExclam: true,
|
IDExclam: true,
|
||||||
IDQuestion: true,
|
IDQuestion: true,
|
||||||
IDColon: true,
|
IDColon: true,
|
||||||
|
|||||||
@@ -36,10 +36,10 @@ pub func hasher.update!(x slice base.u8) base.u32 {
|
|||||||
s2 = this.state.high_bits(n:16)
|
s2 = this.state.high_bits(n:16)
|
||||||
|
|
||||||
while args.x.length() > 0 {
|
while args.x.length() > 0 {
|
||||||
remaining = args.x[:0]
|
remaining = args.x[.. 0]
|
||||||
if args.x.length() > 5552 {
|
if args.x.length() > 5552 {
|
||||||
remaining = args.x[5552:]
|
remaining = args.x[5552 ..]
|
||||||
args.x = args.x[:5552]
|
args.x = args.x[.. 5552]
|
||||||
}
|
}
|
||||||
|
|
||||||
iterate (p = args.x)(length:1, unroll:8) {
|
iterate (p = args.x)(length:1, unroll:8) {
|
||||||
|
|||||||
@@ -144,12 +144,12 @@ pub func decoder.add_history!(hist slice base.u8) {
|
|||||||
// If s is longer than the ringbuffer, we can ignore the previous value
|
// If s is longer than the ringbuffer, we can ignore the previous value
|
||||||
// of history_index, as we will overwrite the whole ringbuffer.
|
// of history_index, as we will overwrite the whole ringbuffer.
|
||||||
s = s.suffix(up_to:0x8000)
|
s = s.suffix(up_to:0x8000)
|
||||||
this.history[:].copy_from_slice!(s:s)
|
this.history[..].copy_from_slice!(s:s)
|
||||||
this.history_index = 0x8000
|
this.history_index = 0x8000
|
||||||
} else {
|
} else {
|
||||||
// Otherwise, append s to the history ringbuffer starting at the
|
// Otherwise, append s to the history ringbuffer starting at the
|
||||||
// previous history_index (modulo 0x8000).
|
// previous history_index (modulo 0x8000).
|
||||||
n_copied = this.history[this.history_index & 0x7FFF:].copy_from_slice!(s:s)
|
n_copied = this.history[this.history_index & 0x7FFF ..].copy_from_slice!(s:s)
|
||||||
if n_copied < s.length() {
|
if n_copied < s.length() {
|
||||||
// a_slice.copy_from(s:b_slice) returns the minimum of the two
|
// a_slice.copy_from(s:b_slice) returns the minimum of the two
|
||||||
// slice lengths. If that value is less than b_slice.length(), then
|
// slice lengths. If that value is less than b_slice.length(), then
|
||||||
@@ -158,8 +158,8 @@ pub func decoder.add_history!(hist slice base.u8) {
|
|||||||
// In terms of the history ringbuffer, that means that we have to
|
// In terms of the history ringbuffer, that means that we have to
|
||||||
// wrap around and copy the remainder of s over the start of the
|
// wrap around and copy the remainder of s over the start of the
|
||||||
// history ringbuffer.
|
// history ringbuffer.
|
||||||
s = s[n_copied:]
|
s = s[n_copied ..]
|
||||||
n_copied = this.history[:].copy_from_slice!(s:s)
|
n_copied = this.history[..].copy_from_slice!(s:s)
|
||||||
// Set history_index (modulo 0x8000) to the length of this
|
// Set history_index (modulo 0x8000) to the length of this
|
||||||
// remainder. The &0x7FFF is redundant, but proves to the compiler
|
// remainder. The &0x7FFF is redundant, but proves to the compiler
|
||||||
// that the conversion to u32 will not overflow. The +0x8000 is to
|
// that the conversion to u32 will not overflow. The +0x8000 is to
|
||||||
|
|||||||
@@ -331,12 +331,12 @@ pri func decoder.decode_huffman_fast!(dst base.io_writer, src base.io_reader) ba
|
|||||||
// "args.dst.available() >= 258" fact. It should certainly
|
// "args.dst.available() >= 258" fact. It should certainly
|
||||||
// invalidate any fact that was "<=" instead of ">=".
|
// invalidate any fact that was "<=" instead of ">=".
|
||||||
n_copied = args.dst.copy_n_from_slice!(
|
n_copied = args.dst.copy_n_from_slice!(
|
||||||
n:hlen, s:this.history[hdist & 0x7FFF:])
|
n:hlen, s:this.history[hdist & 0x7FFF ..])
|
||||||
if hlen <= n_copied {
|
if hlen <= n_copied {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
hlen -= n_copied
|
hlen -= n_copied
|
||||||
args.dst.copy_n_from_slice!(n:hlen, s:this.history[:])
|
args.dst.copy_n_from_slice!(n:hlen, s:this.history[..])
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -227,7 +227,7 @@ pri func decoder.decode_huffman_slow?(dst base.io_writer, src base.io_reader) {
|
|||||||
// Copy from hdist to the end of this.history.
|
// Copy from hdist to the end of this.history.
|
||||||
while true {
|
while true {
|
||||||
n_copied = args.dst.copy_n_from_slice!(
|
n_copied = args.dst.copy_n_from_slice!(
|
||||||
n:hlen, s:this.history[hdist & 0x7FFF:])
|
n:hlen, s:this.history[hdist & 0x7FFF ..])
|
||||||
if hlen <= n_copied {
|
if hlen <= n_copied {
|
||||||
hlen = 0
|
hlen = 0
|
||||||
break
|
break
|
||||||
@@ -246,7 +246,7 @@ pri func decoder.decode_huffman_slow?(dst base.io_writer, src base.io_reader) {
|
|||||||
if hlen > 0 {
|
if hlen > 0 {
|
||||||
while true {
|
while true {
|
||||||
n_copied = args.dst.copy_n_from_slice!(
|
n_copied = args.dst.copy_n_from_slice!(
|
||||||
n:hlen, s:this.history[hdist & 0x7FFF:])
|
n:hlen, s:this.history[hdist & 0x7FFF ..])
|
||||||
if hlen <= n_copied {
|
if hlen <= n_copied {
|
||||||
hlen = 0
|
hlen = 0
|
||||||
break
|
break
|
||||||
|
|||||||
+11
-11
@@ -932,7 +932,7 @@ pri func decoder.decode_id_part1?(dst ptr base.pixel_buffer, src base.io_reader)
|
|||||||
} else if this.quirk_enabled_reject_empty_palette and (not this.has_global_palette) {
|
} else if this.quirk_enabled_reject_empty_palette and (not this.has_global_palette) {
|
||||||
return "#bad palette"
|
return "#bad palette"
|
||||||
} else if this.gc_has_transparent_index {
|
} else if this.gc_has_transparent_index {
|
||||||
this.palettes[1][:].copy_from_slice!(s:this.palettes[0][:])
|
this.palettes[1][..].copy_from_slice!(s:this.palettes[0][..])
|
||||||
} else {
|
} else {
|
||||||
which_palette = 0
|
which_palette = 0
|
||||||
}
|
}
|
||||||
@@ -947,7 +947,7 @@ pri func decoder.decode_id_part1?(dst ptr base.pixel_buffer, src base.io_reader)
|
|||||||
|
|
||||||
dst_palette = args.dst.palette()
|
dst_palette = args.dst.palette()
|
||||||
if dst_palette.length() == 0 {
|
if dst_palette.length() == 0 {
|
||||||
dst_palette = this.dst_palette[:]
|
dst_palette = this.dst_palette[..]
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: a Wuffs (not just C) name for the
|
// TODO: a Wuffs (not just C) name for the
|
||||||
@@ -956,7 +956,7 @@ pri func decoder.decode_id_part1?(dst ptr base.pixel_buffer, src base.io_reader)
|
|||||||
dst_pixfmt:args.dst.pixel_format(),
|
dst_pixfmt:args.dst.pixel_format(),
|
||||||
dst_palette:dst_palette,
|
dst_palette:dst_palette,
|
||||||
src_pixfmt:0x47040008,
|
src_pixfmt:0x47040008,
|
||||||
src_palette:this.palettes[which_palette][:])
|
src_palette:this.palettes[which_palette][..])
|
||||||
if not status.is_ok() {
|
if not status.is_ok() {
|
||||||
return status
|
return status
|
||||||
}
|
}
|
||||||
@@ -1026,7 +1026,7 @@ pri func decoder.decode_id_part2?(dst ptr base.pixel_buffer, src base.io_reader,
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
compressed = args.src.take!(n:n_compressed)
|
compressed = args.src.take!(n:n_compressed)
|
||||||
this.compressed[this.compressed_wi:].copy_from_slice!(s:compressed)
|
this.compressed[this.compressed_wi ..].copy_from_slice!(s:compressed)
|
||||||
this.compressed_wi ~sat+= n_compressed
|
this.compressed_wi ~sat+= n_compressed
|
||||||
block_size ~sat-= n_compressed
|
block_size ~sat-= n_compressed
|
||||||
if block_size > 0 {
|
if block_size > 0 {
|
||||||
@@ -1048,7 +1048,7 @@ pri func decoder.decode_id_part2?(dst ptr base.pixel_buffer, src base.io_reader,
|
|||||||
if (this.compressed_ri > this.compressed_wi) or (this.compressed_wi > 4096) {
|
if (this.compressed_ri > this.compressed_wi) or (this.compressed_wi > 4096) {
|
||||||
return "#internal error: inconsistent ri/wi"
|
return "#internal error: inconsistent ri/wi"
|
||||||
}
|
}
|
||||||
io_bind (io:r, data:this.compressed[this.compressed_ri:this.compressed_wi]) {
|
io_bind (io:r, data:this.compressed[this.compressed_ri .. this.compressed_wi]) {
|
||||||
mark = r.mark()
|
mark = r.mark()
|
||||||
lzw_status =? this.lzw.decode_io_writer?(
|
lzw_status =? this.lzw.decode_io_writer?(
|
||||||
dst:this.util.empty_io_writer(), src:r, workbuf:this.util.empty_slice_u8())
|
dst:this.util.empty_io_writer(), src:r, workbuf:this.util.empty_slice_u8())
|
||||||
@@ -1125,7 +1125,7 @@ pri func decoder.copy_to_image_buffer!(pb ptr base.pixel_buffer, src slice base.
|
|||||||
width_in_bytes = (this.width as base.u64) * (bytes_per_pixel as base.u64)
|
width_in_bytes = (this.width as base.u64) * (bytes_per_pixel as base.u64)
|
||||||
tab = args.pb.plane(p:0)
|
tab = args.pb.plane(p:0)
|
||||||
while src_ri < args.src.length() {
|
while src_ri < args.src.length() {
|
||||||
src = args.src[src_ri:]
|
src = args.src[src_ri ..]
|
||||||
|
|
||||||
if this.dst_y >= this.frame_rect_y1 {
|
if this.dst_y >= this.frame_rect_y1 {
|
||||||
if this.quirk_enabled_ignore_too_much_pixel_data {
|
if this.quirk_enabled_ignore_too_much_pixel_data {
|
||||||
@@ -1139,21 +1139,21 @@ pri func decoder.copy_to_image_buffer!(pb ptr base.pixel_buffer, src slice base.
|
|||||||
|
|
||||||
dst = tab.row(y:this.dst_y)
|
dst = tab.row(y:this.dst_y)
|
||||||
if this.dst_y >= this.height {
|
if this.dst_y >= this.height {
|
||||||
dst = dst[:0]
|
dst = dst[.. 0]
|
||||||
} else if width_in_bytes < dst.length() {
|
} else if width_in_bytes < dst.length() {
|
||||||
dst = dst[:width_in_bytes]
|
dst = dst[.. width_in_bytes]
|
||||||
}
|
}
|
||||||
|
|
||||||
i = (this.dst_x as base.u64) * (bytes_per_pixel as base.u64)
|
i = (this.dst_x as base.u64) * (bytes_per_pixel as base.u64)
|
||||||
if i < dst.length() {
|
if i < dst.length() {
|
||||||
j = (this.frame_rect_x1 as base.u64) * (bytes_per_pixel as base.u64)
|
j = (this.frame_rect_x1 as base.u64) * (bytes_per_pixel as base.u64)
|
||||||
if (i <= j) and (j <= dst.length()) {
|
if (i <= j) and (j <= dst.length()) {
|
||||||
dst = dst[i:j]
|
dst = dst[i .. j]
|
||||||
} else {
|
} else {
|
||||||
dst = dst[i:]
|
dst = dst[i ..]
|
||||||
}
|
}
|
||||||
n = this.swizzler.swizzle_interleaved!(
|
n = this.swizzler.swizzle_interleaved!(
|
||||||
dst:dst, dst_palette:this.dst_palette[:], src:src)
|
dst:dst, dst_palette:this.dst_palette[..], src:src)
|
||||||
|
|
||||||
src_ri ~sat+= n
|
src_ri ~sat+= n
|
||||||
this.dst_x ~sat+= (n & 0xFFFFFFFF) as base.u32
|
this.dst_x ~sat+= (n & 0xFFFFFFFF) as base.u32
|
||||||
|
|||||||
@@ -254,7 +254,7 @@ pri func decoder.read_from!(src base.io_reader) {
|
|||||||
// The final "8" is redundant semantically, but helps the
|
// The final "8" is redundant semantically, but helps the
|
||||||
// wuffs-c code generator recognize that both slices have the
|
// wuffs-c code generator recognize that both slices have the
|
||||||
// same constant length, and hence produce efficient C code.
|
// same constant length, and hence produce efficient C code.
|
||||||
this.output[o:o + 8].copy_from_slice!(s:this.suffixes[c][:8])
|
this.output[o .. o + 8].copy_from_slice!(s:this.suffixes[c][.. 8])
|
||||||
|
|
||||||
if steps <= 0 {
|
if steps <= 0 {
|
||||||
break
|
break
|
||||||
@@ -338,7 +338,7 @@ pri func decoder.write_to?(dst base.io_writer) {
|
|||||||
if this.output_ri > this.output_wi {
|
if this.output_ri > this.output_wi {
|
||||||
return "#internal error: inconsistent I/O"
|
return "#internal error: inconsistent I/O"
|
||||||
}
|
}
|
||||||
s = this.output[this.output_ri:this.output_wi]
|
s = this.output[this.output_ri .. this.output_wi]
|
||||||
n = args.dst.copy_from_slice!(s:s)
|
n = args.dst.copy_from_slice!(s:s)
|
||||||
if n == s.length() {
|
if n == s.length() {
|
||||||
this.output_ri = 0
|
this.output_ri = 0
|
||||||
@@ -354,7 +354,7 @@ pub func decoder.flush!() slice base.u8 {
|
|||||||
var s slice base.u8
|
var s slice base.u8
|
||||||
|
|
||||||
if this.output_ri <= this.output_wi {
|
if this.output_ri <= this.output_wi {
|
||||||
s = this.output[this.output_ri:this.output_wi]
|
s = this.output[this.output_ri .. this.output_wi]
|
||||||
}
|
}
|
||||||
this.output_ri = 0
|
this.output_ri = 0
|
||||||
this.output_wi = 0
|
this.output_wi = 0
|
||||||
|
|||||||
Reference in new issue
Block a user