Update comments in tree.js for Babel compatibility

- Closes #261, #263, #262
This commit is contained in:
Vitaly Puzrin 2022-11-07 01:34:34 +02:00
parent 174a1d12b6
commit 23c773e31c

View file

@ -276,10 +276,10 @@ const bi_flush = (s) => {
* The length opt_len is updated; static_len is also updated if stree is * The length opt_len is updated; static_len is also updated if stree is
* not null. * not null.
*/ */
const gen_bitlen = (s, desc) => const gen_bitlen = (s, desc) => {
// deflate_state *s; // deflate_state *s;
// tree_desc *desc; /* the tree descriptor */ // tree_desc *desc; /* the tree descriptor */
{
const tree = desc.dyn_tree; const tree = desc.dyn_tree;
const max_code = desc.max_code; const max_code = desc.max_code;
const stree = desc.stat_desc.static_tree; const stree = desc.stat_desc.static_tree;
@ -373,11 +373,11 @@ const gen_bitlen = (s, desc) =>
* OUT assertion: the field code is set for all tree elements of non * OUT assertion: the field code is set for all tree elements of non
* zero code length. * zero code length.
*/ */
const gen_codes = (tree, max_code, bl_count) => const gen_codes = (tree, max_code, bl_count) => {
// ct_data *tree; /* the tree to decorate */ // ct_data *tree; /* the tree to decorate */
// int max_code; /* largest code with non zero frequency */ // int max_code; /* largest code with non zero frequency */
// ushf *bl_count; /* number of codes at each bit length */ // ushf *bl_count; /* number of codes at each bit length */
{
const next_code = new Array(MAX_BITS + 1); /* next code value for each bit length */ const next_code = new Array(MAX_BITS + 1); /* next code value for each bit length */
let code = 0; /* running code value */ let code = 0; /* running code value */
let bits; /* bit index */ let bits; /* bit index */
@ -565,11 +565,11 @@ const smaller = (tree, n, m, depth) => {
* when the heap property is re-established (each father smaller than its * when the heap property is re-established (each father smaller than its
* two sons). * two sons).
*/ */
const pqdownheap = (s, tree, k) => const pqdownheap = (s, tree, k) => {
// deflate_state *s; // deflate_state *s;
// ct_data *tree; /* the tree to restore */ // ct_data *tree; /* the tree to restore */
// int k; /* node to move down */ // int k; /* node to move down */
{
const v = s.heap[k]; const v = s.heap[k];
let j = k << 1; /* left son of k */ let j = k << 1; /* left son of k */
while (j <= s.heap_len) { while (j <= s.heap_len) {
@ -598,11 +598,11 @@ const pqdownheap = (s, tree, k) =>
/* =========================================================================== /* ===========================================================================
* Send the block data compressed using the given Huffman trees * Send the block data compressed using the given Huffman trees
*/ */
const compress_block = (s, ltree, dtree) => const compress_block = (s, ltree, dtree) => {
// deflate_state *s; // deflate_state *s;
// const ct_data *ltree; /* literal tree */ // const ct_data *ltree; /* literal tree */
// const ct_data *dtree; /* distance tree */ // const ct_data *dtree; /* distance tree */
{
let dist; /* distance of matched string */ let dist; /* distance of matched string */
let lc; /* match length or unmatched char (if dist == 0) */ let lc; /* match length or unmatched char (if dist == 0) */
let sx = 0; /* running index in sym_buf */ let sx = 0; /* running index in sym_buf */
@ -656,10 +656,10 @@ const compress_block = (s, ltree, dtree) =>
* and corresponding code. The length opt_len is updated; static_len is * and corresponding code. The length opt_len is updated; static_len is
* also updated if stree is not null. The field max_code is set. * also updated if stree is not null. The field max_code is set.
*/ */
const build_tree = (s, desc) => const build_tree = (s, desc) => {
// deflate_state *s; // deflate_state *s;
// tree_desc *desc; /* the tree descriptor */ // tree_desc *desc; /* the tree descriptor */
{
const tree = desc.dyn_tree; const tree = desc.dyn_tree;
const stree = desc.stat_desc.static_tree; const stree = desc.stat_desc.static_tree;
const has_stree = desc.stat_desc.has_stree; const has_stree = desc.stat_desc.has_stree;
@ -752,11 +752,11 @@ const build_tree = (s, desc) =>
* Scan a literal or distance tree to determine the frequencies of the codes * Scan a literal or distance tree to determine the frequencies of the codes
* in the bit length tree. * in the bit length tree.
*/ */
const scan_tree = (s, tree, max_code) => const scan_tree = (s, tree, max_code) => {
// deflate_state *s; // deflate_state *s;
// ct_data *tree; /* the tree to be scanned */ // ct_data *tree; /* the tree to be scanned */
// int max_code; /* and its largest code of non zero frequency */ // int max_code; /* and its largest code of non zero frequency */
{
let n; /* iterates over all tree elements */ let n; /* iterates over all tree elements */
let prevlen = -1; /* last emitted length */ let prevlen = -1; /* last emitted length */
let curlen; /* length of current code */ let curlen; /* length of current code */
@ -818,11 +818,11 @@ const scan_tree = (s, tree, max_code) =>
* Send a literal or distance tree in compressed form, using the codes in * Send a literal or distance tree in compressed form, using the codes in
* bl_tree. * bl_tree.
*/ */
const send_tree = (s, tree, max_code) => const send_tree = (s, tree, max_code) => {
// deflate_state *s; // deflate_state *s;
// ct_data *tree; /* the tree to be scanned */ // ct_data *tree; /* the tree to be scanned */
// int max_code; /* and its largest code of non zero frequency */ // int max_code; /* and its largest code of non zero frequency */
{
let n; /* iterates over all tree elements */ let n; /* iterates over all tree elements */
let prevlen = -1; /* last emitted length */ let prevlen = -1; /* last emitted length */
let curlen; /* length of current code */ let curlen; /* length of current code */
@ -926,10 +926,10 @@ const build_bl_tree = (s) => {
* lengths of the bit length codes, the literal tree and the distance tree. * lengths of the bit length codes, the literal tree and the distance tree.
* IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4. * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4.
*/ */
const send_all_trees = (s, lcodes, dcodes, blcodes) => const send_all_trees = (s, lcodes, dcodes, blcodes) => {
// deflate_state *s; // deflate_state *s;
// int lcodes, dcodes, blcodes; /* number of codes for each tree */ // int lcodes, dcodes, blcodes; /* number of codes for each tree */
{
let rank; /* index in bl_order */ let rank; /* index in bl_order */
//Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4, "not enough codes"); //Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4, "not enough codes");
@ -1027,12 +1027,12 @@ const _tr_init = (s) =>
/* =========================================================================== /* ===========================================================================
* Send a stored block * Send a stored block
*/ */
const _tr_stored_block = (s, buf, stored_len, last) => const _tr_stored_block = (s, buf, stored_len, last) => {
//DeflateState *s; //DeflateState *s;
//charf *buf; /* input block */ //charf *buf; /* input block */
//ulg stored_len; /* length of input block */ //ulg stored_len; /* length of input block */
//int last; /* one if this is the last block for a file */ //int last; /* one if this is the last block for a file */
{
send_bits(s, (STORED_BLOCK << 1) + (last ? 1 : 0), 3); /* send block type */ send_bits(s, (STORED_BLOCK << 1) + (last ? 1 : 0), 3); /* send block type */
bi_windup(s); /* align on byte boundary */ bi_windup(s); /* align on byte boundary */
put_short(s, stored_len); put_short(s, stored_len);
@ -1059,12 +1059,12 @@ const _tr_align = (s) => {
* Determine the best encoding for the current block: dynamic trees, static * Determine the best encoding for the current block: dynamic trees, static
* trees or store, and write out the encoded block. * trees or store, and write out the encoded block.
*/ */
const _tr_flush_block = (s, buf, stored_len, last) => const _tr_flush_block = (s, buf, stored_len, last) => {
//DeflateState *s; //DeflateState *s;
//charf *buf; /* input block, or NULL if too old */ //charf *buf; /* input block, or NULL if too old */
//ulg stored_len; /* length of input block */ //ulg stored_len; /* length of input block */
//int last; /* one if this is the last block for a file */ //int last; /* one if this is the last block for a file */
{
let opt_lenb, static_lenb; /* opt_len and static_len in bytes */ let opt_lenb, static_lenb; /* opt_len and static_len in bytes */
let max_blindex = 0; /* index of last bit length code of non zero freq */ let max_blindex = 0; /* index of last bit length code of non zero freq */
@ -1146,11 +1146,11 @@ const _tr_flush_block = (s, buf, stored_len, last) =>
* Save the match info and tally the frequency counts. Return true if * Save the match info and tally the frequency counts. Return true if
* the current block must be flushed. * the current block must be flushed.
*/ */
const _tr_tally = (s, dist, lc) => const _tr_tally = (s, dist, lc) => {
// deflate_state *s; // deflate_state *s;
// unsigned dist; /* distance of matched string */ // unsigned dist; /* distance of matched string */
// unsigned lc; /* match length-MIN_MATCH or unmatched char (if dist==0) */ // unsigned lc; /* match length-MIN_MATCH or unmatched char (if dist==0) */
{
s.pending_buf[s.sym_buf + s.sym_next++] = dist; s.pending_buf[s.sym_buf + s.sym_next++] = dist;
s.pending_buf[s.sym_buf + s.sym_next++] = dist >> 8; s.pending_buf[s.sym_buf + s.sym_next++] = dist >> 8;
s.pending_buf[s.sym_buf + s.sym_next++] = lc; s.pending_buf[s.sym_buf + s.sym_next++] = lc;