mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-24 00:52:18 +01:00
lang: let skip_u32_fast imply can_undo_byte
This commit is contained in:
1 parent
723c604a5b
commit
bedf2bd7c3
3 files changed
+30
-21
No files matched your search
+26
-9
@@ -1153,7 +1153,7 @@ func (q *checker) bcheckExprCallSpecialCases(n *a.Expr, depth uint32) (bounds, e
|
|||||||
recv := lhs.LHS().AsExpr()
|
recv := lhs.LHS().AsExpr()
|
||||||
method := lhs.Ident()
|
method := lhs.Ident()
|
||||||
|
|
||||||
advance, advanceExpr, update := (*big.Int)(nil), (*a.Expr)(nil), false
|
actualAdvanceIsAlwaysPositive, advance, advanceExpr, update := false, (*big.Int)(nil), (*a.Expr)(nil), false
|
||||||
|
|
||||||
if recvTyp := recv.MType(); recvTyp == nil {
|
if recvTyp := recv.MType(); recvTyp == nil {
|
||||||
return bounds{}, errNotASpecialCase
|
return bounds{}, errNotASpecialCase
|
||||||
@@ -1233,6 +1233,9 @@ func (q *checker) bcheckExprCallSpecialCases(n *a.Expr, depth uint32) (bounds, e
|
|||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
return bounds{}, err
|
return bounds{}, err
|
||||||
}
|
}
|
||||||
|
if cv := actual.ConstValue(); (cv != nil) && (cv.Sign() > 0) {
|
||||||
|
actualAdvanceIsAlwaysPositive = true
|
||||||
|
}
|
||||||
if cv := worstCase.ConstValue(); cv != nil {
|
if cv := worstCase.ConstValue(); cv != nil {
|
||||||
advance, update = cv, true
|
advance, update = cv, true
|
||||||
} else {
|
} else {
|
||||||
@@ -1298,6 +1301,9 @@ func (q *checker) bcheckExprCallSpecialCases(n *a.Expr, depth uint32) (bounds, e
|
|||||||
return bounds{}, fmt.Errorf("check: could not prove %s pre-condition: %s.length() >= %s",
|
return bounds{}, fmt.Errorf("check: could not prove %s pre-condition: %s.length() >= %s",
|
||||||
method.Str(q.tm), subject.Str(q.tm), adv)
|
method.Str(q.tm), subject.Str(q.tm), adv)
|
||||||
}
|
}
|
||||||
|
if actualAdvanceIsAlwaysPositive {
|
||||||
|
q.facts = append(q.facts, makeCanUndoByte(recv))
|
||||||
|
}
|
||||||
// TODO: drop other subject-related facts?
|
// TODO: drop other subject-related facts?
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1536,15 +1542,26 @@ func makeConstValueExpr(tm *t.Map, cv *big.Int) (*a.Expr, error) {
|
|||||||
return o, nil
|
return o, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// makeSliceLength returns "x.length()".
|
// makeCanUndoByte returns "x.can_undo_byte()".
|
||||||
func makeSliceLength(slice *a.Expr) *a.Expr {
|
func makeCanUndoByte(x *a.Expr) *a.Expr {
|
||||||
x := a.NewExpr(0, t.IDDot, t.IDLength, slice.AsNode(), nil, nil, nil)
|
ret := a.NewExpr(0, t.IDDot, t.IDCanUndoByte, x.AsNode(), nil, nil, nil)
|
||||||
x.SetMBounds(bounds{funcBounds, funcBounds})
|
ret.SetMBounds(bounds{funcBounds, funcBounds})
|
||||||
x.SetMType(a.NewTypeExpr(t.IDFunc, 0, t.IDLength, slice.MType().AsNode(), nil, nil))
|
ret.SetMType(a.NewTypeExpr(t.IDFunc, 0, t.IDCanUndoByte, x.MType().AsNode(), nil, nil))
|
||||||
x = a.NewExpr(0, t.IDOpenParen, 0, x.AsNode(), nil, nil, nil)
|
ret = a.NewExpr(0, t.IDOpenParen, 0, ret.AsNode(), nil, nil, nil)
|
||||||
// TODO: call SetMBounds?
|
// TODO: call SetMBounds?
|
||||||
x.SetMType(typeExprU64)
|
ret.SetMType(typeExprBool)
|
||||||
return x
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
|
// makeSliceLength returns "x.length()".
|
||||||
|
func makeSliceLength(x *a.Expr) *a.Expr {
|
||||||
|
ret := a.NewExpr(0, t.IDDot, t.IDLength, x.AsNode(), nil, nil, nil)
|
||||||
|
ret.SetMBounds(bounds{funcBounds, funcBounds})
|
||||||
|
ret.SetMType(a.NewTypeExpr(t.IDFunc, 0, t.IDLength, x.MType().AsNode(), nil, nil))
|
||||||
|
ret = a.NewExpr(0, t.IDOpenParen, 0, ret.AsNode(), nil, nil, nil)
|
||||||
|
// TODO: call SetMBounds?
|
||||||
|
ret.SetMType(typeExprU64)
|
||||||
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
// makeSliceLengthEqEq returns "x.length() == n".
|
// makeSliceLengthEqEq returns "x.length() == n".
|
||||||
|
|||||||
@@ -41424,14 +41424,10 @@ wuffs_jpeg__decoder__fill_bitstream(
|
|||||||
if (v_c < 255u) {
|
if (v_c < 255u) {
|
||||||
goto label__0__continue;
|
goto label__0__continue;
|
||||||
} else if (((uint64_t)(io2_a_src - iop_a_src)) <= 0u) {
|
} else if (((uint64_t)(io2_a_src - iop_a_src)) <= 0u) {
|
||||||
if (iop_a_src > io1_a_src) {
|
iop_a_src--;
|
||||||
iop_a_src--;
|
|
||||||
}
|
|
||||||
goto label__0__break;
|
goto label__0__break;
|
||||||
} else if (wuffs_base__peek_u8be__no_bounds_check(iop_a_src) > 0u) {
|
} else if (wuffs_base__peek_u8be__no_bounds_check(iop_a_src) > 0u) {
|
||||||
if (iop_a_src > io1_a_src) {
|
iop_a_src--;
|
||||||
iop_a_src--;
|
|
||||||
}
|
|
||||||
goto label__0__break;
|
goto label__0__break;
|
||||||
} else {
|
} else {
|
||||||
iop_a_src += 1u;
|
iop_a_src += 1u;
|
||||||
|
|||||||
@@ -1503,15 +1503,11 @@ pri func decoder.fill_bitstream!(src: base.io_reader) {
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
} else if args.src.length() <= 0 {
|
} else if args.src.length() <= 0 {
|
||||||
if args.src.can_undo_byte() {
|
args.src.undo_byte!()
|
||||||
args.src.undo_byte!()
|
|
||||||
}
|
|
||||||
break
|
break
|
||||||
|
|
||||||
} else if args.src.peek_u8() > 0 {
|
} else if args.src.peek_u8() > 0 {
|
||||||
if args.src.can_undo_byte() {
|
args.src.undo_byte!()
|
||||||
args.src.undo_byte!()
|
|
||||||
}
|
|
||||||
break
|
break
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in new issue
Block a user