mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-20 08:47:28 +01:00
Rename I/O available methods to length
This commit is contained in:
1 parent
79b923c322
commit
be8542e313
15 files changed
+149
-152
No files matched your search
@@ -1085,7 +1085,7 @@ func (q *checker) bcheckExprCallSpecialCases(n *a.Expr, depth uint32) (bounds, e
|
||||
} else {
|
||||
adv = advanceExpr.Str(q.tm)
|
||||
}
|
||||
return bounds{}, fmt.Errorf("check: could not prove %s pre-condition: %s.available() >= %s",
|
||||
return bounds{}, fmt.Errorf("check: could not prove %s pre-condition: %s.length() >= %s",
|
||||
method.Str(q.tm), recv.Str(q.tm), adv)
|
||||
}
|
||||
// TODO: drop other recv-related facts?
|
||||
@@ -1120,7 +1120,7 @@ func (q *checker) canUndoByte(recv *a.Expr) error {
|
||||
|
||||
func (q *checker) canLimitedCopyU32FromHistoryFast(recv *a.Expr, args []*a.Node) error {
|
||||
// As per cgen's io-private.h, there are three pre-conditions:
|
||||
// - n <= this.available()
|
||||
// - n <= this.length()
|
||||
// - distance > 0
|
||||
// - distance <= this.history_available()
|
||||
|
||||
@@ -1130,7 +1130,7 @@ func (q *checker) canLimitedCopyU32FromHistoryFast(recv *a.Expr, args []*a.Node)
|
||||
n := args[0].AsArg().Value()
|
||||
distance := args[1].AsArg().Value()
|
||||
|
||||
// Check "n <= this.available()".
|
||||
// Check "n <= this.length()".
|
||||
check0:
|
||||
for {
|
||||
for _, x := range q.facts {
|
||||
@@ -1148,9 +1148,9 @@ check0:
|
||||
continue
|
||||
}
|
||||
|
||||
// Check that the RHS is "recv.available()".
|
||||
// Check that the RHS is "recv.length()".
|
||||
y, method, yArgs := splitReceiverMethodArgs(x.RHS().AsExpr())
|
||||
if method != t.IDAvailable || len(yArgs) != 0 {
|
||||
if method != t.IDLength || len(yArgs) != 0 {
|
||||
continue
|
||||
}
|
||||
if !y.Eq(recv) {
|
||||
@@ -1159,7 +1159,7 @@ check0:
|
||||
|
||||
break check0
|
||||
}
|
||||
return fmt.Errorf("check: could not prove n <= %s.available()", recv.Str(q.tm))
|
||||
return fmt.Errorf("check: could not prove n <= %s.length()", recv.Str(q.tm))
|
||||
}
|
||||
|
||||
// Check "distance > 0".
|
||||
|
||||
@@ -55,7 +55,7 @@ func (q *checker) optimizeIOMethodAdvance(receiver *a.Expr, advance *big.Int, ad
|
||||
|
||||
retErr = q.facts.update(func(x *a.Expr) (*a.Expr, error) {
|
||||
// TODO: update (discard?) any facts that merely mention
|
||||
// receiver.available(), even if they aren't an exact match.
|
||||
// receiver.length(), even if they aren't an exact match.
|
||||
|
||||
op := x.Operator()
|
||||
if op != t.IDXBinaryGreaterEq && op != t.IDXBinaryGreaterThan {
|
||||
@@ -67,13 +67,13 @@ func (q *checker) optimizeIOMethodAdvance(receiver *a.Expr, advance *big.Int, ad
|
||||
return x, nil
|
||||
}
|
||||
|
||||
// Check that lhs is "receiver.available()".
|
||||
// Check that lhs is "receiver.length()".
|
||||
lhs := x.LHS().AsExpr()
|
||||
if lhs.Operator() != t.IDOpenParen || len(lhs.Args()) != 0 {
|
||||
return x, nil
|
||||
}
|
||||
lhs = lhs.LHS().AsExpr()
|
||||
if lhs.Operator() != t.IDDot || lhs.Ident() != t.IDAvailable {
|
||||
if lhs.Operator() != t.IDDot || lhs.Ident() != t.IDLength {
|
||||
return x, nil
|
||||
}
|
||||
lhs = lhs.LHS().AsExpr()
|
||||
@@ -102,7 +102,7 @@ func (q *checker) optimizeIOMethodAdvance(receiver *a.Expr, advance *big.Int, ad
|
||||
|
||||
if rcv.Cmp(advance) == 0 {
|
||||
// TODO: delete the (adjusted) fact, as newRCV will be zero, and
|
||||
// "foo.available() >= 0" is redundant.
|
||||
// "foo.length() >= 0" is redundant.
|
||||
}
|
||||
|
||||
// Create a new a.Expr to hold the adjusted RHS constant value, newRCV.
|
||||
@@ -121,20 +121,20 @@ func (q *checker) optimizeIOMethodAdvance(receiver *a.Expr, advance *big.Int, ad
|
||||
func (q *checker) optimizeIOMethodAdvanceExpr(receiver *a.Expr, advanceExpr *a.Expr, update bool) (retOK bool, retErr error) {
|
||||
retErr = q.facts.update(func(x *a.Expr) (*a.Expr, error) {
|
||||
// TODO: update (discard?) any facts that merely mention
|
||||
// receiver.available(), even if they aren't an exact match.
|
||||
// receiver.length(), even if they aren't an exact match.
|
||||
|
||||
op := x.Operator()
|
||||
if op != t.IDXBinaryGreaterEq && op != t.IDXBinaryGreaterThan {
|
||||
return x, nil
|
||||
}
|
||||
|
||||
// Check that lhs is "receiver.available()".
|
||||
// Check that lhs is "receiver.length()".
|
||||
lhs := x.LHS().AsExpr()
|
||||
if lhs.Operator() != t.IDOpenParen || len(lhs.Args()) != 0 {
|
||||
return x, nil
|
||||
}
|
||||
lhs = lhs.LHS().AsExpr()
|
||||
if lhs.Operator() != t.IDDot || lhs.Ident() != t.IDAvailable {
|
||||
if lhs.Operator() != t.IDDot || lhs.Ident() != t.IDLength {
|
||||
return x, nil
|
||||
}
|
||||
lhs = lhs.LHS().AsExpr()
|
||||
|
||||
Reference in new issue
Block a user