src/gzip.bend checks
raw source on the hub · import bend-kube-runtime@0.10.0.0/src/gzip.bend as Gzip
1 import
import Base
Types
type LD source · line 16 · raw
Data
The base and extra bits of a length (257..285) or distance code.
LD@base:U32 -> @extra:U32 -> LD
type Hd source · line 22 · raw
Data
A Huffman decode in progress (puff's decode()): the code so far, the first code of its length, the index of that length's first symbol, and the counts of the lengths not yet tried.
Hd@code:U32 -> @first:U32 -> @index:U32 -> @left:List<&2, U32> -> Hd
type HStep source · line 25 · raw
Data
HSym@i:U32 -> HStep
HMore@h:Hd -> HStep
HFailHStep
type IM source · line 32 · raw
Data
Where the decoder is. Each mode reading n bits keeps k, the bits read, and v, their value so far (least significant first).
IHead@k:U32 -> @v:U32 -> IM
IAlignIM
ISLen@k:U32 -> @v:U32 -> IM
IStored@left:U32 -> IM
IDyn@k:U32 -> @v:U32 -> IM
ICl@hlit:U32 -> @hdist:U32 -> @left:U32 -> @k:U32 -> @v:U32 -> @lens:List<&2, U32> -> IM
ILens@hlit:U32 -> @hdist:U32 -> @got:List<&2, U32> -> @n:U32 -> @h:Hd -> IM
IRep@hlit:U32 -> @hdist:U32 -> @got:List<&2, U32> -> @n:U32 -> @need:U32 -> @k:U32 -> @v:U32 -> @base:U32 -> @val:U32 -> IM
IBlock@h:Hd -> IM
ILenX@base:U32 -> @need:U32 -> @k:U32 -> @v:U32 -> IM
IDist@len:U32 -> @h:Hd -> IM
IDistX@len:U32 -> @base:U32 -> @need:U32 -> @k:U32 -> @v:U32 -> IM
IDoneIM
IBad@why:String -> IM
type Inf source · line 54 · raw
Type
The decoder: its mode, the window and the next place in it, how much has come out (up to 32 KiB, for distances), the literal/length (or code length) table and the distance table (the counts of each code length from 1, and the symbols in canonical order), whether this block is the last, the CRC-32 so far and its table, the bytes out, reversed, and the member's size so far (mod 2^32, as gzip's ISIZE).
Inf@m:IM -> @win:Array<U32> -> @pos:U32 -> @total:U32 -> @c1:List<&2, U32> -> @s1:Array<U32> -> @c2:List<&2, U32> -> @s2:Array<U32> -> @last:Bool -> @crc:U32 -> @ct:Array<U32> -> @out:List<&2, U32> -> @size:U32 -> Inf
type TP source · line 240 · raw
Type
TP@a:Array<U32> -> @k:U32 -> TP
type TB source · line 265 · raw
Type
TB@counts:List<&2, U32> -> @syms:Array<U32> -> @ok:Bool -> TB
type IC source · line 325 · raw
Type
IC@st:Inf -> @cs:List<&2, U32> -> IC
type IP source · line 771 · raw
Type
The decoder with its mode beside it.
IP@st:Inf -> @m:IM -> IP
type GzM source · line 851 · raw
Data
Where the wrapper is: GH: in the 10-byte header (n read; flg its flags) GXLen: in FEXTRA's length; GX: in FEXTRA's data GZero: in FNAME (comment: False) or FCOMMENT (True), up to a 0 byte GHcrc: in FHCRC GBody: in the DEFLATE data GTrail: in the CRC-32 and ISIZE, acc reversed GNext: between members GBad: refused; it stays here
GH@n:U32 -> @flg:U32 -> GzM
GXLen@k:U32 -> @v:U32 -> @flg:U32 -> GzM
GX@left:U32 -> @flg:U32 -> GzM
GZero@comment:Bool -> @flg:U32 -> GzM
GHcrc@left:U32 -> GzM
GBodyGzM
GTrail@n:U32 -> @acc:List<&2, U32> -> GzM
GNextGzM
GBad@why:String -> GzM
type Gz source · line 862 · raw
Type
Gz@m:GzM -> @inf:Inf -> Gz
type GzOut source · line 1023 · raw
Type
GzOut@g:Gz -> @out:List<&2, U32> -> GzOut
Definitions
def Crc.one source · line 61 · raw
@n:Nat -> @+c:U32 -> U32
def Crc.fill source · line 68 · raw
@n:Nat -> @a:Array<U32> -> @+i:U32 -> Array<U32>
def Crc.table source · line 76 · raw
Array<U32>
The CRC-32 table (the reflected polynomial 0xEDB88320).
def Inf.len_base source · line 82 · raw
@i:U32 -> LD
def Inf.dist_base source · line 145 · raw
@i:U32 -> LD
def Inf.order source · line 211 · raw
List<&2, U32>
The code length code's lengths come in this order.
def Tb.count source · line 217 · raw
@lens:List<&2, U32> -> @+l:U32 -> U32
def Tb.counts source · line 224 · raw
@n:Nat -> @+lens:List<&2, U32> -> @+l:U32 -> List<&2, U32>
def Tb.ok source · line 233 · raw
@cs:List<&2, U32> -> @+left:U32 -> Bool
Whether no length has more codes than the lengths before it leave room for (an over-subscribed code cannot be decoded).
def Tb.put source · line 243 · raw
@a:Array<U32> -> @+k:U32 -> @+sym:U32 -> @hit:Bool -> TP
def Tb.place source · line 251 · raw
@lens:List<&2, U32> -> @+l:U32 -> @ev:TP -> @+sym:U32 -> TP
Puts the symbols of length l, in order, from the next free place.
def Tb.all source · line 258 · raw
@n:Nat -> @+lens:List<&2, U32> -> @+l:U32 -> @ev:TP -> TP
def Tb.done source · line 268 · raw
@cs:List<&2, U32> -> @ev:TP -> TB
def Tb.build source · line 276 · raw
@+lens:List<&2, U32> -> @syms:Array<U32> -> TB
A canonical code from each symbol's code length (0: unused): the count of each length from 1 to 15, and the symbols by length, then value.
def Tb.fixed_lit source · line 279 · raw
List<&2, U32>
def Tb.fixed_dist source · line 283 · raw
List<&2, U32>
def Inf.hd source · line 289 · raw
@cs:List<&2, U32> -> Hd
def Inf.hbit.go source · line 292 · raw
@+c:U32 -> @+first:U32 -> @+index:U32 -> @+count:U32 -> @rest:List<&2, U32> -> @hit:Bool -> HStep
def Inf.hbit source · line 299 · raw
@h:Hd -> @+bit:U32 -> HStep
def Inf.mode source · line 312 · raw
@st:Inf -> @nm:IM -> Inf
def Inf.bad source · line 317 · raw
@st:Inf -> @why:String -> Inf
def Inf.c1_of source · line 320 · raw
@st:Inf -> Pair(Inf, List<&2, U32>)
def IC.of source · line 328 · raw
@p:Pair(Inf, List<&2, U32>) -> IC
def Inf.c2_of source · line 333 · raw
@st:Inf -> Pair(Inf, List<&2, U32>)
def Inf.last_of source · line 338 · raw
@st:Inf -> Pair(Inf, Bool)
def Inf.put.go source · line 343 · raw
@p:Pair(Array<U32>, U32) -> @m:IM -> @win:Array<U32> -> @+pos:U32 -> @+total:U32 -> @c1:List<&2, U32> -> @s1:Array<U32> -> @c2:List<&2, U32> -> @s2:Array<U32> -> @last:Bool -> @+crc:U32 -> @out:List<&2, U32> -> @+size:U32 -> @+b:U32 -> Inf
def Inf.put source · line 351 · raw
@st:Inf -> @+b:U32 -> Inf
One byte out: into the window, the CRC and the output.
def Inf.copy1.go source · line 356 · raw
@p:Pair(Array<U32>, U32) -> @m:IM -> @+pos:U32 -> @+total:U32 -> @c1:List<&2, U32> -> @s1:Array<U32> -> @c2:List<&2, U32> -> @s2:Array<U32> -> @last:Bool -> @+crc:U32 -> @ct:Array<U32> -> @out:List<&2, U32> -> @size:U32 -> Inf
def Inf.copy1 source · line 362 · raw
@st:Inf -> @+dist:U32 -> Inf
def Inf.copy source · line 367 · raw
@n:Nat -> @+dist:U32 -> @st:Inf -> Inf
def Inf.total_of source · line 374 · raw
@st:Inf -> Pair(Inf, U32)
def Inf.sym1.go source · line 379 · raw
@p:Pair(Array<U32>, U32) -> @m:IM -> @win:Array<U32> -> @pos:U32 -> @total:U32 -> @c1:List<&2, U32> -> @c2:List<&2, U32> -> @s2:Array<U32> -> @last:Bool -> @crc:U32 -> @ct:Array<U32> -> @out:List<&2, U32> -> @size:U32 -> Pair(Inf, U32)
def Inf.sym2.go source · line 385 · raw
@p:Pair(Array<U32>, U32) -> @m:IM -> @win:Array<U32> -> @pos:U32 -> @total:U32 -> @c1:List<&2, U32> -> @s1:Array<U32> -> @c2:List<&2, U32> -> @last:Bool -> @crc:U32 -> @ct:Array<U32> -> @out:List<&2, U32> -> @size:U32 -> Pair(Inf, U32)
def Inf.block source · line 392 · raw
@st:Inf -> Inf
Back to reading literals and lengths, with the block's table.
def Inf.dist source · line 398 · raw
@st:Inf -> @+len:U32 -> Inf
On to a distance, with the block's distance table.
def Inf.copy.go source · line 403 · raw
@st:Inf -> @+len:U32 -> @+dist:U32 -> @far:Bool -> Inf
def Inf.match source · line 411 · raw
@p:Pair(Inf, U32) -> @+len:U32 -> @+dist:U32 -> Inf
Copies len bytes from dist back.
def Inf.end_block.go source · line 417 · raw
@p:Pair(Inf, Bool) -> Inf
The block ended: the next, or the end.
def Inf.end_block source · line 424 · raw
@st:Inf -> Inf
def Inf.set_t1 source · line 427 · raw
@st:Inf -> @t:TB -> Pair(Inf, Bool)
def Inf.set_t2 source · line 432 · raw
@st:Inf -> @t:TB -> Pair(Inf, Bool)
def Inf.s1_take source · line 437 · raw
@st:Inf -> Pair(Inf, Array<U32>)
def Inf.s2_take source · line 442 · raw
@st:Inf -> Pair(Inf, Array<U32>)
def Inf.t1.go source · line 447 · raw
@p:Pair(Inf, Array<U32>) -> @+lens:List<&2, U32> -> Pair(Inf, Bool)
def Inf.t2.go source · line 452 · raw
@p:Pair(Inf, Array<U32>) -> @+lens:List<&2, U32> -> Pair(Inf, Bool)
def Inf.t1 source · line 459 · raw
@st:Inf -> @+lens:List<&2, U32> -> Pair(Inf, Bool)
The first table from lens (reusing its symbols' array); and whether the code is sound.
def Inf.t2 source · line 462 · raw
@st:Inf -> @+lens:List<&2, U32> -> Pair(Inf, Bool)
def Inf.tables.fin source · line 465 · raw
@st:Inf -> @ok:Bool -> Inf
def Inf.tables.two source · line 472 · raw
@p:Pair(Inf, Bool) -> @ok1:Bool -> Inf
def Inf.tables.one source · line 477 · raw
@p:Pair(Inf, Bool) -> @+dist:List<&2, U32> -> Inf
def Inf.tables source · line 483 · raw
@st:Inf -> @+lit:List<&2, U32> -> @+dist:List<&2, U32> -> Inf
A block's literal/length and distance tables, then its data.
def Inf.sym1 source · line 486 · raw
@st:Inf -> @+i:U32 -> Pair(Inf, U32)
def Inf.sym2 source · line 491 · raw
@st:Inf -> @+i:U32 -> Pair(Inf, U32)
def Inf.set_last source · line 499 · raw
@st:Inf -> @l:Bool -> Inf
def Inf.head.go source · line 504 · raw
@st:Inf -> @ty:U32 -> Inf
def Inf.head source · line 515 · raw
@st:Inf -> @+v:U32 -> Inf
def Inf.slen.go source · line 518 · raw
@st:Inf -> @+len:U32 -> @ok:Bool -> @empty:Bool -> Inf
def Inf.slen source · line 527 · raw
@st:Inf -> @+v:U32 -> Inf
def Inf.pick.go source · line 531 · raw
@+l:U32 -> @rest:U32 -> @hit:Bool -> U32
def Inf.pick source · line 538 · raw
@+i:U32 -> @ps:List<&2, U32> -> @ls:List<&2, U32> -> U32
def Inf.cl_lens source · line 545 · raw
@n:Nat -> @+i:U32 -> @+lens:List<&2, U32> -> List<&2, U32>
def Inf.lens_start source · line 552 · raw
@st:Inf -> @+hlit:U32 -> @+hdist:U32 -> Inf
def Inf.cl_built source · line 557 · raw
@p:Pair(Inf, Bool) -> @+hlit:U32 -> @+hdist:U32 -> Inf
def Inf.cl_done source · line 565 · raw
@st:Inf -> @+hlit:U32 -> @+hdist:U32 -> @+lens:List<&2, U32> -> Inf
The code length code is whole: its table, then the code lengths.
def Inf.lens_done.go source · line 568 · raw
@st:Inf -> @+all:List<&2, U32> -> @+hlit:U32 -> @eob:Bool -> Inf
def Inf.lens_done source · line 575 · raw
@st:Inf -> @+hlit:U32 -> @got:List<&2, U32> -> Inf
def Inf.lens_more source · line 579 · raw
@st:Inf -> @+hlit:U32 -> @+hdist:U32 -> @got:List<&2, U32> -> @+n:U32 -> Inf
def Inf.lens_add.go source · line 584 · raw
@st:Inf -> @+hlit:U32 -> @+hdist:U32 -> @got:List<&2, U32> -> @+n:U32 -> @over:Bool -> @done:Bool -> Inf
def Inf.lens_add source · line 593 · raw
@st:Inf -> @+hlit:U32 -> @+hdist:U32 -> @got:List<&2, U32> -> @+n:U32 -> Inf
def Inf.cl_sym.go source · line 596 · raw
@st:Inf -> @lit:Bool -> @+sym:U32 -> @+hlit:U32 -> @+hdist:U32 -> @+got:List<&2, U32> -> @+n:U32 -> Inf
def Inf.cl_sym source · line 613 · raw
@p:Pair(Inf, U32) -> @+hlit:U32 -> @+hdist:U32 -> @+got:List<&2, U32> -> @+n:U32 -> Inf
def Inf.len.go source · line 618 · raw
@st:Inf -> @ld:LD -> Inf
def Inf.lit.go source · line 629 · raw
@st:Inf -> @+sym:U32 -> @lit:Bool -> @eob:Bool -> Inf
def Inf.lit source · line 638 · raw
@p:Pair(Inf, U32) -> Inf
def Inf.dsym.go source · line 643 · raw
@st:Inf -> @+len:U32 -> @ld:LD -> Inf
def Inf.dsym source · line 654 · raw
@p:Pair(Inf, U32) -> @+len:U32 -> Inf
def Inf.got source · line 659 · raw
@+k:U32 -> @+v:U32 -> @+bit:U32 -> U32
def Inf.step.head source · line 662 · raw
@st:Inf -> @+k:U32 -> @+v:U32 -> @done:Bool -> Inf
def Inf.step.slen source · line 669 · raw
@st:Inf -> @+k:U32 -> @+v:U32 -> @done:Bool -> Inf
def Inf.step.dyn source · line 676 · raw
@st:Inf -> @+k:U32 -> @+v:U32 -> @done:Bool -> Inf
def Inf.step.cl source · line 684 · raw
@st:Inf -> @+hlit:U32 -> @+hdist:U32 -> @+left:U32 -> @+k:U32 -> @+v:U32 -> @lens:List<&2, U32> -> @done:Bool -> @last:Bool -> Inf
def Inf.step.rep source · line 693 · raw
@st:Inf -> @+hlit:U32 -> @+hdist:U32 -> @got:List<&2, U32> -> @+n:U32 -> @+need:U32 -> @+k:U32 -> @+v:U32 -> @+base:U32 -> @+val:U32 -> @done:Bool -> Inf
def Inf.step.lenx source · line 702 · raw
@st:Inf -> @+base:U32 -> @+need:U32 -> @+k:U32 -> @+v:U32 -> @done:Bool -> Inf
def Inf.step.distx source · line 709 · raw
@st:Inf -> @+len:U32 -> @+base:U32 -> @+need:U32 -> @+k:U32 -> @+v:U32 -> @done:Bool -> Inf
def Inf.step.huff source · line 716 · raw
@st:Inf -> @r:HStep -> @+which:U32 -> @+hlit:U32 -> @+hdist:U32 -> @+got:List<&2, U32> -> @+n:U32 -> @+len:U32 -> Inf
def Inf.step source · line 734 · raw
@m:IM -> @st:Inf -> @+bit:U32 -> Inf
One bit in mode m (st's own mode is a placeholder).
def Inf.bit source · line 765 · raw
@st:Inf -> @+bit:U32 -> Inf
def Inf.peek source · line 774 · raw
@st:Inf -> IP
def Inf.bits source · line 781 · raw
@i:Nat -> @+b:U32 -> @ev:IP -> Inf
The bits of a byte, least significant first; a stored block's alignment drops the rest, and the end of the stream ignores them.
def Inf.stored source · line 794 · raw
@st:Inf -> @+left:U32 -> @last:Bool -> Inf
def Inf.byte.go source · line 801 · raw
@ev:IP -> @+b:U32 -> Inf
def Inf.byte source · line 813 · raw
@st:Inf -> @+b:U32 -> Inf
One byte of a DEFLATE stream.
def Inf.new source · line 818 · raw
Inf
A new DEFLATE stream (the window is kept, but nothing reaches before the start).
def Inf.restart source · line 822 · raw
@st:Inf -> Inf
def Inf.take source · line 828 · raw
@st:Inf -> Pair(Inf, List<&2, U32>)
The bytes out since the last take, in order.
def Inf.sums source · line 834 · raw
@st:Inf -> Pair(Inf, Pair(U32, U32))
The member's CRC-32 and size.
def Gz.new source · line 866 · raw
Gz
A decoder for a gzip stream of one or more members.
def Gz.bit source · line 869 · raw
@+flg:U32 -> @+b:U32 -> Bool
def Gz.after.go source · line 872 · raw
@+flg:U32 -> @x:Bool -> @n:Bool -> @c:Bool -> @h:Bool -> GzM
def Gz.after source · line 887 · raw
@+flg:U32 -> @+from:U32 -> GzM
What follows a part of the header (from: 0 the fixed part, 1 FEXTRA, 2 FNAME, 3 FCOMMENT), by its flags.
def Gz.expect source · line 891 · raw
@inf:Inf -> @ok:Bool -> @next:GzM -> @why:String -> Gz
def Gz.hdr source · line 898 · raw
@inf:Inf -> @n:U32 -> @+flg:U32 -> @+b:U32 -> Gz
def Gz.xlen source · line 913 · raw
@inf:Inf -> @+k:U32 -> @+v:U32 -> @+flg:U32 -> @last:Bool -> @none:Bool -> Gz
def Gz.extra source · line 922 · raw
@inf:Inf -> @+left:U32 -> @+flg:U32 -> @last:Bool -> Gz
def Gz.zero source · line 929 · raw
@inf:Inf -> @+flg:U32 -> @end:Bool -> @comment:Bool -> Gz
def Gz.hcrc source · line 938 · raw
@inf:Inf -> @+left:U32 -> @last:Bool -> Gz
def Gz.body source · line 945 · raw
@ev:IP -> Gz
def Gz.le32 source · line 954 · raw
@bs:List<&2, U32> -> U32
def Gz.trail.go source · line 961 · raw
@st:Inf -> @crc_ok:Bool -> @size_ok:Bool -> Gz
def Gz.trail source · line 970 · raw
@p:Pair(Inf, Pair(U32, U32)) -> @+tr:List<&2, U32> -> Gz
def Gz.trailer source · line 975 · raw
@inf:Inf -> @+n:U32 -> @acc:List<&2, U32> -> @last:Bool -> Gz
def Gz.next source · line 982 · raw
@inf:Inf -> @magic:Bool -> Gz
def Gz.step source · line 989 · raw
@m:GzM -> @inf:Inf -> @+b:U32 -> Gz
def Gz.byte source · line 1011 · raw
@g:Gz -> @+b:U32 -> Gz
def Gz.feed.go source · line 1016 · raw
@bs:List<&2, U32> -> @g:Gz -> Gz
def Gz.out.go source · line 1026 · raw
@m:GzM -> @p:Pair(Inf, List<&2, U32>) -> GzOut
def Gz.out source · line 1031 · raw
@g:Gz -> GzOut
def Gz.feed source · line 1037 · raw
@g:Gz -> @bs:List<&2, U32> -> GzOut
Feeds compressed bytes: the decoder, and the bytes they decompress to.
def Gz.finish source · line 1041 · raw
@g:Gz -> Result<&2, &2, String, Unit>
Whether the stream ended whole: every member's data, CRC and size.
def Gz.whole.go source · line 1050 · raw
@r:Result<&2, &2, String, Unit> -> @out:List<&2, U32> -> Result<&2, &2, String, List<&2, U32>>
def Gz.whole source · line 1057 · raw
@o:GzOut -> Result<&2, &2, String, List<&2, U32>>
def Gz.inflate source · line 1063 · raw
@bs:List<&2, U32> -> Result<&2, &2, String, List<&2, U32>>
A whole gzip stream, decompressed.