mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-23 08:47:56 +01:00
Generate lang/check/reason.go.
This commit is contained in:
1 parent
61b771a418
commit
dec234779e
4 files changed
+363
-37
No files matched your search
+48
-34
@@ -1,3 +1,5 @@
|
||||
// Code generated by running "go generate". DO NOT EDIT.
|
||||
|
||||
// Use of this source code is governed by a BSD-style license that can be found
|
||||
// in the LICENSE file.
|
||||
|
||||
@@ -12,56 +14,74 @@ var reasons = [...]struct {
|
||||
s string
|
||||
r reason
|
||||
}{
|
||||
|
||||
{`"a < (b + c): a < c; 0 <= b"`, func(q *checker, n *a.Assert) error {
|
||||
op, xa, xbc := parseBinaryOp(n.Condition())
|
||||
op, xa, t0 := parseBinaryOp(n.Condition())
|
||||
if op.Key() != t.KeyXBinaryLessThan {
|
||||
return errFailed
|
||||
}
|
||||
op, xb, xc := parseBinaryOp(xbc)
|
||||
op, xb, xc := parseBinaryOp(t0)
|
||||
if op.Key() != t.KeyXBinaryPlus {
|
||||
return errFailed
|
||||
}
|
||||
if err := q.proveBinaryOp(t.KeyXBinaryLessThan, xa, xc); err != nil {
|
||||
return binOpReasonError(q.tm, t.IDXBinaryLessThan, xa, xc, err)
|
||||
// a < c
|
||||
if err := proveReasonRequirement(q, t.IDXBinaryLessThan, xa, xc); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := q.proveBinaryOp(t.KeyXBinaryLessEq, zeroExpr, xb); err != nil {
|
||||
return binOpReasonError(q.tm, t.IDXBinaryLessEq, zeroExpr, xb, err)
|
||||
// 0 <= b
|
||||
if err := proveReasonRequirement(q, t.IDXBinaryLessEq, zeroExpr, xb); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}},
|
||||
|
||||
{`"(a + b) <= c: a <= (c - b)"`, func(q *checker, n *a.Assert) error {
|
||||
op, xab, xc := parseBinaryOp(n.Condition())
|
||||
op, t0, xc := parseBinaryOp(n.Condition())
|
||||
if op.Key() != t.KeyXBinaryLessEq {
|
||||
return errFailed
|
||||
}
|
||||
op, xa, xb := parseBinaryOp(xab)
|
||||
op, xa, xb := parseBinaryOp(t0)
|
||||
if op.Key() != t.KeyXBinaryPlus {
|
||||
return errFailed
|
||||
}
|
||||
sub := a.NewExpr(a.FlagsTypeChecked, t.IDXBinaryMinus, 0, xc.Node(), nil, xb.Node(), nil)
|
||||
if err := q.proveBinaryOp(t.KeyXBinaryLessEq, xa, sub); err != nil {
|
||||
return binOpReasonError(q.tm, t.IDXBinaryLessEq, xa, sub, err)
|
||||
// a <= (c - b)
|
||||
t1 := a.NewExpr(a.FlagsTypeChecked, t.IDXBinaryMinus, 0, xc.Node(), nil, xb.Node(), nil)
|
||||
if err := proveReasonRequirement(q, t.IDXBinaryLessEq, xa, t1); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}},
|
||||
|
||||
{`"a < b: a < c; c <= b"`, func(q *checker, n *a.Assert) error {
|
||||
xc := argValue(q.tm, n.Args(), "c")
|
||||
if xc == nil {
|
||||
return errFailed
|
||||
}
|
||||
op, xa, xb := parseBinaryOp(n.Condition())
|
||||
if op.Key() != t.KeyXBinaryLessThan {
|
||||
return errFailed
|
||||
}
|
||||
if err := q.proveBinaryOp(t.KeyXBinaryLessThan, xa, xc); err != nil {
|
||||
return binOpReasonError(q.tm, t.IDXBinaryLessThan, xa, xc, err)
|
||||
// a < c
|
||||
xc := argValue(q.tm, n.Args(), "c")
|
||||
if xc == nil {
|
||||
return errFailed
|
||||
}
|
||||
if err := q.proveBinaryOp(t.KeyXBinaryLessEq, xc, xb); err != nil {
|
||||
return binOpReasonError(q.tm, t.IDXBinaryLessEq, xc, xb, err)
|
||||
if err := proveReasonRequirement(q, t.IDXBinaryLessThan, xa, xc); err != nil {
|
||||
return err
|
||||
}
|
||||
// c <= b
|
||||
if err := proveReasonRequirement(q, t.IDXBinaryLessEq, xc, xb); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}},
|
||||
|
||||
{`"a < (b + c): a < (b0 + c0); b0 <= b; c0 <= c"`, func(q *checker, n *a.Assert) error {
|
||||
op, xa, t0 := parseBinaryOp(n.Condition())
|
||||
if op.Key() != t.KeyXBinaryLessThan {
|
||||
return errFailed
|
||||
}
|
||||
op, xb, xc := parseBinaryOp(t0)
|
||||
if op.Key() != t.KeyXBinaryPlus {
|
||||
return errFailed
|
||||
}
|
||||
// a < (b0 + c0)
|
||||
xb0 := argValue(q.tm, n.Args(), "b0")
|
||||
if xb0 == nil {
|
||||
return errFailed
|
||||
@@ -70,23 +90,17 @@ var reasons = [...]struct {
|
||||
if xc0 == nil {
|
||||
return errFailed
|
||||
}
|
||||
op, xa, xbc := parseBinaryOp(n.Condition())
|
||||
if op.Key() != t.KeyXBinaryLessThan {
|
||||
return errFailed
|
||||
t1 := a.NewExpr(a.FlagsTypeChecked, t.IDXBinaryPlus, 0, xb0.Node(), nil, xc0.Node(), nil)
|
||||
if err := proveReasonRequirement(q, t.IDXBinaryLessThan, xa, t1); err != nil {
|
||||
return err
|
||||
}
|
||||
op, xb, xc := parseBinaryOp(xbc)
|
||||
if op.Key() != t.KeyXBinaryPlus {
|
||||
return errFailed
|
||||
// b0 <= b
|
||||
if err := proveReasonRequirement(q, t.IDXBinaryLessEq, xb0, xb); err != nil {
|
||||
return err
|
||||
}
|
||||
plus := a.NewExpr(a.FlagsTypeChecked, t.IDXBinaryPlus, 0, xb0.Node(), nil, xc0.Node(), nil)
|
||||
if err := q.proveBinaryOp(t.KeyXBinaryLessThan, xa, plus); err != nil {
|
||||
return binOpReasonError(q.tm, t.IDXBinaryLessThan, xa, plus, err)
|
||||
}
|
||||
if err := q.proveBinaryOp(t.KeyXBinaryLessEq, xb0, xb); err != nil {
|
||||
return binOpReasonError(q.tm, t.IDXBinaryLessEq, xb0, xb, err)
|
||||
}
|
||||
if err := q.proveBinaryOp(t.KeyXBinaryLessEq, xc0, xc); err != nil {
|
||||
return binOpReasonError(q.tm, t.IDXBinaryLessEq, xc0, xc, err)
|
||||
// c0 <= c
|
||||
if err := proveReasonRequirement(q, t.IDXBinaryLessEq, xc0, xc); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}},
|
||||
|
||||
Reference in new issue
Block a user