Add a writer1.length method.

This commit is contained in:
Nigel Tao committed 2017-10-06 14:17:01 +11:00
1 parent e9df25d599
commit d30d4c3dad
3 files changed
+16 -4

No files matched your search

+12 -4
View File
@@ -171,12 +171,20 @@ func (g *gen) writeExprOther(b *buffer, n *a.Expr, rp replacementPolicy, pp pare
if pp == parenthesesMandatory {
b.writeb('(')
}
b.writes("(uint64_t)(")
x := n.LHS().Expr().LHS().Expr()
if err := g.writeExpr(b, x, rp, parenthesesMandatory, depth); err != nil {
return err
if typ := x.MType(); typ.Decorator() == 0 && typ.Name().Key() == t.KeyWriter1 {
// TODO: don't hard-code dst.
const wName = "dst"
b.printf("(uint64_t)(%swptr_%s - %swstart_%s)", bPrefix, wName, bPrefix, wName)
} else {
b.writes("(uint64_t)(")
if err := g.writeExpr(b, x, rp, parenthesesMandatory, depth); err != nil {
return err
}
b.writes(".len)")
}
b.writes(".len)")
if pp == parenthesesMandatory {
b.writeb(')')
}
+2
View File
@@ -1314,6 +1314,8 @@ puffs_flate_status puffs_flate_decoder_decode_huffman(
v_distance += ((v_bits) & ((1 << (v_table_entry_n_bits)) - 1));
v_bits >>= v_table_entry_n_bits;
v_n_bits -= v_table_entry_n_bits;
if (((uint64_t)(v_distance)) > ((uint64_t)(b_wptr_dst - b_wstart_dst))) {
}
PUFFS_COROUTINE_SUSPENSION_POINT(8);
{
self->private_impl.c_decode_huffman[0].scratch =
+2
View File
@@ -341,6 +341,8 @@ pri func decoder.decode_huffman?(dst writer1, src reader1)() {
// TODO: copy_history32 should also take some notion of how much of dst
// is valid. When copying from a distance greater than that, we also
// need to keep a sliding window of previous history.
if (distance as u64) > in.dst.length() {
}
in.dst.copy_history32?(distance:distance, length:length)
}