mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-23 16:52:18 +01:00
Add a nptr T type
This commit is contained in:
1 parent
15f2f42b77
commit
29eb64a0a4
11 files changed
+39
-27
No files matched your search
+18
-3
@@ -888,8 +888,6 @@ func (q *checker) bcheckExprOther(n *a.Expr, depth uint32) (a.Bounds, error) {
|
||||
|
||||
func (q *checker) bcheckExprCall(n *a.Expr, depth uint32) error {
|
||||
// TODO: handle func pre/post conditions.
|
||||
//
|
||||
// TODO: bcheck the receiver, e.g. ptr vs nptr.
|
||||
lhs := n.LHS().AsExpr()
|
||||
f, err := q.c.resolveFunc(lhs.MType())
|
||||
if err != nil {
|
||||
@@ -905,7 +903,24 @@ func (q *checker) bcheckExprCall(n *a.Expr, depth uint32) error {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
||||
recv := lhs.LHS().AsExpr()
|
||||
if recv.MType().Decorator() != t.IDNptr {
|
||||
return nil
|
||||
}
|
||||
// Check that q.facts contain "recv != nullptr".
|
||||
for _, x := range q.facts {
|
||||
if x.Operator() != t.IDXBinaryNotEq {
|
||||
continue
|
||||
}
|
||||
xLHS := x.LHS().AsExpr()
|
||||
xRHS := x.RHS().AsExpr()
|
||||
if (xLHS.Eq(exprNullptr) && xRHS.Eq(recv)) ||
|
||||
(xRHS.Eq(exprNullptr) && xLHS.Eq(recv)) {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
return fmt.Errorf("check: cannot prove %q", recv.Str(q.tm)+" != nullptr")
|
||||
}
|
||||
|
||||
var errNotASpecialCase = errors.New("not a special case")
|
||||
|
||||
@@ -27,12 +27,12 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
exprIn = a.NewExpr(0, 0, 0, t.IDIn, nil, nil, nil, nil)
|
||||
exprOut = a.NewExpr(0, 0, 0, t.IDOut, nil, nil, nil, nil)
|
||||
exprThis = a.NewExpr(0, 0, 0, t.IDThis, nil, nil, nil, nil)
|
||||
exprIn = a.NewExpr(0, 0, 0, t.IDIn, nil, nil, nil, nil)
|
||||
exprOut = a.NewExpr(0, 0, 0, t.IDOut, nil, nil, nil, nil)
|
||||
exprThis = a.NewExpr(0, 0, 0, t.IDThis, nil, nil, nil, nil)
|
||||
exprNullptr = a.NewExpr(0, 0, 0, t.IDNullptr, nil, nil, nil, nil)
|
||||
)
|
||||
|
||||
// typeExprFoo is an *ast.Node MType (implicit type).
|
||||
var (
|
||||
typeExprGeneric1 = a.NewTypeExpr(0, t.IDBase, t.IDDagger1, nil, nil, nil)
|
||||
typeExprGeneric2 = a.NewTypeExpr(0, t.IDBase, t.IDDagger2, nil, nil, nil)
|
||||
|
||||
+1
-2
@@ -1009,8 +1009,7 @@ swtch:
|
||||
}
|
||||
fallthrough
|
||||
|
||||
// TODO: also check t.IDNptr? Where else should we look for nptr?
|
||||
case t.IDPtr, t.IDSlice, t.IDTable:
|
||||
case t.IDNptr, t.IDPtr, t.IDSlice, t.IDTable:
|
||||
if err := q.tcheckTypeExpr(typ.Inner(), depth); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user