Calculate the zlib checksum.

This commit is contained in:
Nigel Tao committed 2017-10-21 12:38:23 +11:00
1 parent 62935c41d7
commit 1c75edb32e
8 files changed
+174 -46

No files matched your search

+3 -15
View File
@@ -762,6 +762,7 @@ func (q *checker) bcheckExprOther(n *a.Expr, depth uint32) (*big.Int, *big.Int,
// TODO: delete this hack that only matches "foo.is_suspension(etc)".
if isThatMethod(q.tm, n, t.KeyIsError, 0) || isThatMethod(q.tm, n, t.KeyIsOK, 0) ||
isThatMethod(q.tm, n, t.KeyIsSuspension, 0) || isThatMethod(q.tm, n, t.KeySuffix, 1) {
// TODO: should return be break? Ditto below.
return nil, nil, nil
}
// TODO: delete this hack that only matches "foo.set_literal_width(etc)".
@@ -777,21 +778,8 @@ func (q *checker) bcheckExprOther(n *a.Expr, depth uint32) (*big.Int, *big.Int,
return nil, nil, nil
}
// TODO: delete this hack that only matches "foo.decode(etc)".
if isThatMethod(q.tm, n, q.tm.ByName("decode").Key(), 2) {
for _, o := range n.Args() {
a := o.Arg().Value()
aMin, aMax, err := q.bcheckExpr(a, depth)
if err != nil {
return nil, nil, err
}
// TODO: check that aMin and aMax is within the function's
// declared arg bounds.
_, _ = aMin, aMax
}
return nil, nil, nil
}
// TODO: delete this hack that only matches "foo.copy_from_slice(etc)".
if isThatMethod(q.tm, n, t.KeyCopyFromSlice, 1) {
if isThatMethod(q.tm, n, q.tm.ByName("decode").Key(), 2) || isThatMethod(q.tm, n, t.KeyCopyFromSlice, 1) ||
isThatMethod(q.tm, n, q.tm.ByName("update").Key(), 1) {
for _, o := range n.Args() {
a := o.Arg().Value()
aMin, aMax, err := q.bcheckExpr(a, depth)
+16
View File
@@ -553,6 +553,22 @@ func (q *checker) tcheckExprOther(n *a.Expr, depth uint32) error {
n.SetMType(typeExprU64)
return nil
}
// TODO: delete this hack that only matches "foo.update(etc)".
if isThatMethod(q.tm, n, q.tm.ByName("update").Key(), 1) {
foo := n.LHS().Expr().LHS().Expr()
if err := q.tcheckExpr(foo, depth); err != nil {
return err
}
n.LHS().SetTypeChecked()
n.LHS().Expr().SetMType(typeExprPlaceholder) // HACK.
for _, o := range n.Args() {
if err := q.tcheckArg(o.Arg(), depth); err != nil {
return err
}
}
n.SetMType(typeExprU32)
return nil
}
case t.KeyOpenBracket:
// n is an index.