mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-24 00:52:18 +01:00
Allow "assert foo", not just "assert foo < bar".
This commit is contained in:
1 parent
e2ce9f1b1d
commit
3bdd515e47
3 files changed
+13
-5
No files matched your search
+1
-1
@@ -2017,7 +2017,7 @@ static puffs_flate__status puffs_flate__flate_decoder__decode_huffman_fast(
|
|||||||
b_rend_src = b_rptr_src + len;
|
b_rend_src = b_rptr_src + len;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((a_dst.private_impl.mark != NULL) != true) {
|
if (!(a_dst.private_impl.mark != NULL)) {
|
||||||
status = PUFFS_FLATE__ERROR_BAD_ARGUMENT;
|
status = PUFFS_FLATE__ERROR_BAD_ARGUMENT;
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -310,8 +310,15 @@ func (q *checker) bcheckStatement(n *a.Node) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (q *checker) bcheckAssert(n *a.Assert) error {
|
func (q *checker) bcheckAssert(n *a.Assert) error {
|
||||||
|
// TODO: check, here or elsewhere, that the condition is pure.
|
||||||
condition := n.Condition()
|
condition := n.Condition()
|
||||||
|
for _, x := range q.facts {
|
||||||
|
if x.Eq(condition) {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
err := errFailed
|
err := errFailed
|
||||||
|
|
||||||
if cv := condition.ConstValue(); cv != nil {
|
if cv := condition.ConstValue(); cv != nil {
|
||||||
if cv.Cmp(one) == 0 {
|
if cv.Cmp(one) == 0 {
|
||||||
err = nil
|
err = nil
|
||||||
@@ -325,6 +332,7 @@ func (q *checker) bcheckAssert(n *a.Assert) error {
|
|||||||
} else if condition.ID0().IsBinaryOp() && condition.ID0().Key() != t.KeyAs {
|
} else if condition.ID0().IsBinaryOp() && condition.ID0().Key() != t.KeyAs {
|
||||||
err = q.proveBinaryOp(condition.ID0().Key(), condition.LHS().Expr(), condition.RHS().Expr())
|
err = q.proveBinaryOp(condition.ID0().Key(), condition.LHS().Expr(), condition.RHS().Expr())
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == errFailed {
|
if err == errFailed {
|
||||||
return fmt.Errorf("check: cannot prove %q", condition.String(q.tm))
|
return fmt.Errorf("check: cannot prove %q", condition.String(q.tm))
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ pri func flate_decoder.decode_huffman_fast?(dst writer1, src reader1)() {
|
|||||||
// correctness and performance.
|
// correctness and performance.
|
||||||
|
|
||||||
// TODO: make this a func pre-condition.
|
// TODO: make this a func pre-condition.
|
||||||
if in.dst.is_marked() != true { // TODO: if not in.dst.is_marked() {
|
if not in.dst.is_marked() {
|
||||||
return error "bad argument"
|
return error "bad argument"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,7 +65,7 @@ pri func flate_decoder.decode_huffman_fast?(dst writer1, src reader1)() {
|
|||||||
// code requires up to 2 + 2 + 2 == 6 bytes, and there are two codes (one
|
// code requires up to 2 + 2 + 2 == 6 bytes, and there are two codes (one
|
||||||
// from H-L and one from H-D). Therefore, we check for at least 12 bytes.
|
// from H-L and one from H-D). Therefore, we check for at least 12 bytes.
|
||||||
while:loop(in.dst.available() >= 258) and (in.src.available() >= 12),
|
while:loop(in.dst.available() >= 258) and (in.src.available() >= 12),
|
||||||
inv in.dst.is_marked() == true, // TODO: remove the redundant "== true".
|
inv in.dst.is_marked(),
|
||||||
{
|
{
|
||||||
// Ensure that we have at least 15 bits of input.
|
// Ensure that we have at least 15 bits of input.
|
||||||
if n_bits < 15 {
|
if n_bits < 15 {
|
||||||
@@ -268,7 +268,7 @@ pri func flate_decoder.decode_huffman_fast?(dst writer1, src reader1)() {
|
|||||||
// its presence minimizes the diff between decode_huffman_fast and
|
// its presence minimizes the diff between decode_huffman_fast and
|
||||||
// decode_huffman_slow.
|
// decode_huffman_slow.
|
||||||
while true,
|
while true,
|
||||||
inv in.dst.is_marked() == true,
|
inv in.dst.is_marked(),
|
||||||
{
|
{
|
||||||
// Copy from this.history.
|
// Copy from this.history.
|
||||||
if (distance as u64) > in.dst.since_mark().length() {
|
if (distance as u64) > in.dst.since_mark().length() {
|
||||||
@@ -298,7 +298,7 @@ pri func flate_decoder.decode_huffman_fast?(dst writer1, src reader1)() {
|
|||||||
// "etc", but its presence minimizes the diff between
|
// "etc", but its presence minimizes the diff between
|
||||||
// decode_huffman_fast and decode_huffman_slow.
|
// decode_huffman_fast and decode_huffman_slow.
|
||||||
while true,
|
while true,
|
||||||
inv in.dst.is_marked() == true,
|
inv in.dst.is_marked(),
|
||||||
{
|
{
|
||||||
n_copied = in.dst.copy_from_slice32(s:this.history[hdist:], length:hlen)
|
n_copied = in.dst.copy_from_slice32(s:this.history[hdist:], length:hlen)
|
||||||
if hlen <= n_copied {
|
if hlen <= n_copied {
|
||||||
|
|||||||
Reference in new issue
Block a user