mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-17 16:32:11 +01:00
Rename some bcheckOptimizeXxx methods.
This commit is contained in:
1 parent
d2a01dd938
commit
693af478d6
2 files changed
+18
-18
No files matched your search
@@ -233,8 +233,8 @@ func (q *checker) bcheckStatement(n *a.Node) error {
|
||||
q.errFilename, q.errLine = n.Raw().FilenameLine()
|
||||
|
||||
// TODO: be principled about checking for provenNotToSuspend. Should we
|
||||
// call bcheckOptimizeSuspendible only for assignments, for var statements
|
||||
// too, or for all statements generally?
|
||||
// call optimizeSuspendible only for assignments, for var statements too,
|
||||
// or for all statements generally?
|
||||
|
||||
switch n.Kind() {
|
||||
case a.KAssert:
|
||||
@@ -250,7 +250,7 @@ func (q *checker) bcheckStatement(n *a.Node) error {
|
||||
return err
|
||||
}
|
||||
if n.Suspendible() {
|
||||
if err := q.bcheckOptimizeSuspendible(n, 0); err != nil {
|
||||
if err := q.optimizeSuspendible(n, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -407,7 +407,7 @@ func (q *checker) bcheckAssignment(lhs *a.Expr, op t.ID, rhs *a.Expr) error {
|
||||
// What's here is somewhat ad hoc. Perhaps we need a call keyword and an
|
||||
// explicit "foo = call bar?()" syntax.
|
||||
if rhs.Suspendible() {
|
||||
if err := q.bcheckOptimizeSuspendible(rhs, 0); err != nil {
|
||||
if err := q.optimizeSuspendible(rhs, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -715,7 +715,7 @@ func (q *checker) bcheckExpr(n *a.Expr, depth uint32) (*big.Int, *big.Int, error
|
||||
return nil, nil, fmt.Errorf("check: expression %q bounds [%v..%v] is not within bounds [%v..%v]",
|
||||
n.String(q.tm), nMin, nMax, tMin, tMax)
|
||||
}
|
||||
if err := q.bcheckOptimizeNonSuspendible(n); err != nil {
|
||||
if err := q.optimizeNonSuspendible(n); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
return nMin, nMax, nil
|
||||
|
||||
+13
-13
@@ -36,12 +36,12 @@ func splitReceiverMethodArgs(n *a.Expr) (receiver *a.Expr, method t.Key, args []
|
||||
return n.LHS().Expr(), n.ID1().Key(), args
|
||||
}
|
||||
|
||||
// TODO: should bcheckOptimizeNonSuspendible be bcheckOptimizeExpr and check
|
||||
// both suspendible and non-suspendible expressions?
|
||||
// TODO: should optimizeNonSuspendible be optimizeExpr and check both
|
||||
// suspendible and non-suspendible expressions?
|
||||
//
|
||||
// See also "be principled about checking for provenNotToSuspend".
|
||||
|
||||
func (q *checker) bcheckOptimizeNonSuspendible(n *a.Expr) error {
|
||||
func (q *checker) optimizeNonSuspendible(n *a.Expr) error {
|
||||
// TODO: check n.CallSuspendible()?
|
||||
//
|
||||
// Should we have an explicit "foo = call bar?()" syntax?
|
||||
@@ -55,7 +55,7 @@ func (q *checker) bcheckOptimizeNonSuspendible(n *a.Expr) error {
|
||||
|
||||
switch nMethod {
|
||||
case t.KeyCopyFromHistory32:
|
||||
return q.bcheckOptimizeCopyFromHistory32(n)
|
||||
return q.optimizeCopyFromHistory32(n)
|
||||
case t.KeySinceMark:
|
||||
for _, x := range q.facts {
|
||||
xReceiver, xMethod, _ := splitReceiverMethodArgs(x)
|
||||
@@ -69,14 +69,14 @@ func (q *checker) bcheckOptimizeNonSuspendible(n *a.Expr) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// bcheckOptimizeCopyFromHistory32 checks if the code generator can call the
|
||||
// Bounds Check Optimized version of CopyFromHistory32. As per
|
||||
// cgen/base-impl.h, the conditions are:
|
||||
// optimizeCopyFromHistory32 checks if the code generator can call the Bounds
|
||||
// Check Optimized version of CopyFromHistory32. As per cgen/base-impl.h, the
|
||||
// conditions are:
|
||||
// - start != NULL
|
||||
// - distance != 0
|
||||
// - distance <= (*ptr_ptr - start)
|
||||
// - length <= (end - *ptr_ptr)
|
||||
func (q *checker) bcheckOptimizeCopyFromHistory32(n *a.Expr) error {
|
||||
func (q *checker) optimizeCopyFromHistory32(n *a.Expr) error {
|
||||
// The arguments are (distance, length).
|
||||
nReceiver, _, args := splitReceiverMethodArgs(n)
|
||||
if len(args) != 2 {
|
||||
@@ -190,7 +190,7 @@ check3:
|
||||
return nil
|
||||
}
|
||||
|
||||
func (q *checker) bcheckOptimizeSuspendible(n *a.Expr, depth uint32) error {
|
||||
func (q *checker) optimizeSuspendible(n *a.Expr, depth uint32) error {
|
||||
if depth > a.MaxExprDepth {
|
||||
return fmt.Errorf("check: expression recursion depth too large")
|
||||
}
|
||||
@@ -199,14 +199,14 @@ func (q *checker) bcheckOptimizeSuspendible(n *a.Expr, depth uint32) error {
|
||||
if !n.CallSuspendible() {
|
||||
for _, o := range n.Node().Raw().SubNodes() {
|
||||
if o != nil && o.Kind() == a.KExpr {
|
||||
if err := q.bcheckOptimizeSuspendible(o.Expr(), depth); err != nil {
|
||||
if err := q.optimizeSuspendible(o.Expr(), depth); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, o := range n.Args() {
|
||||
if o != nil && o.Kind() == a.KExpr {
|
||||
if err := q.bcheckOptimizeSuspendible(o.Expr(), depth); err != nil {
|
||||
if err := q.optimizeSuspendible(o.Expr(), depth); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -229,14 +229,14 @@ func (q *checker) bcheckOptimizeSuspendible(n *a.Expr, depth uint32) error {
|
||||
|
||||
if nMethod < t.Key(len(ioMethodAdvances)) {
|
||||
if advance := ioMethodAdvances[nMethod]; advance != nil {
|
||||
return q.bcheckOptimizeIOMethodAdvance(n, nReceiver, advance)
|
||||
return q.optimizeIOMethodAdvance(n, nReceiver, advance)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (q *checker) bcheckOptimizeIOMethodAdvance(n *a.Expr, receiver *a.Expr, advance *big.Int) error {
|
||||
func (q *checker) optimizeIOMethodAdvance(n *a.Expr, receiver *a.Expr, advance *big.Int) error {
|
||||
return q.facts.update(func(x *a.Expr) (*a.Expr, error) {
|
||||
op := x.ID0().Key()
|
||||
if op != t.KeyXBinaryGreaterEq && op != t.KeyXBinaryGreaterThan {
|
||||
|
||||
Reference in new issue
Block a user