Remove ast.NewExpr statusPkg arg

This commit is contained in:
Nigel Tao committed 2020-06-10 12:05:48 +10:00
1 parent 7dc73a856a
commit ed48514f30
11 files changed
+39 -43

No files matched your search

+3 -3
View File
@@ -58,7 +58,7 @@ func otherHandSide(n *a.Expr, thisHS *a.Expr) (op t.ID, thatHS *a.Expr) {
type facts []*a.Expr
func (z *facts) appendBinaryOpFact(op t.ID, lhs *a.Expr, rhs *a.Expr) {
o := a.NewExpr(0, op, 0, 0, lhs.AsNode(), nil, rhs.AsNode(), nil)
o := a.NewExpr(0, op, 0, lhs.AsNode(), nil, rhs.AsNode(), nil)
o.SetMBounds(bounds{zero, one})
o.SetMType(typeExprBool)
z.appendFact(o)
@@ -210,7 +210,7 @@ func simplify(tm *t.Map, n *a.Expr) (*a.Expr, error) {
return nil, err
}
if l != lhs || r != rhs {
o := a.NewExpr(0, op, 0, 0, l.AsNode(), nil, r.AsNode(), nil)
o := a.NewExpr(0, op, 0, l.AsNode(), nil, r.AsNode(), nil)
o.SetConstValue(n.ConstValue())
o.SetMType(n.MType())
return o, nil
@@ -343,7 +343,7 @@ func proveReasonRequirement(q *checker, op t.ID, lhs *a.Expr, rhs *a.Expr) error
"check: internal error: proveReasonRequirement token (0x%X) is not an XBinaryOp", op)
}
if err := q.proveBinaryOp(op, lhs, rhs); err != nil {
n := a.NewExpr(0, op, 0, 0, lhs.AsNode(), nil, rhs.AsNode(), nil)
n := a.NewExpr(0, op, 0, lhs.AsNode(), nil, rhs.AsNode(), nil)
return fmt.Errorf("cannot prove %q: %v", n.Str(q.tm), err)
}
return nil
+12 -12
View File
@@ -68,7 +68,7 @@ var (
maxIntBits = big.NewInt(t.MaxIntBits)
zeroExpr = a.NewExpr(0, 0, 0, t.ID0, nil, nil, nil, nil)
zeroExpr = a.NewExpr(0, 0, t.ID0, nil, nil, nil, nil)
)
func init() {
@@ -190,7 +190,7 @@ func invert(tm *t.Map, n *a.Expr) (*a.Expr, error) {
default:
op, lhs, rhs = t.IDXUnaryNot, nil, n
}
o := a.NewExpr(n.AsNode().AsRaw().Flags(), op, 0, 0, lhs.AsNode(), nil, rhs.AsNode(), args)
o := a.NewExpr(n.AsNode().AsRaw().Flags(), op, 0, lhs.AsNode(), nil, rhs.AsNode(), args)
o.SetMType(n.MType())
return o, nil
}
@@ -457,14 +457,14 @@ func (q *checker) bcheckAssignment(lhs *a.Expr, op t.ID, rhs *a.Expr) error {
}
switch op {
case t.IDPlusEq, t.IDMinusEq:
oRHS := a.NewExpr(0, op.BinaryForm(), 0, 0, xRHS.AsNode(), nil, rhs.AsNode(), nil)
oRHS := a.NewExpr(0, op.BinaryForm(), 0, xRHS.AsNode(), nil, rhs.AsNode(), nil)
// TODO: call SetMBounds?
oRHS.SetMType(typeExprIdeal)
oRHS, err := simplify(q.tm, oRHS)
if err != nil {
return nil, err
}
o := a.NewExpr(0, xOp, 0, 0, xLHS.AsNode(), nil, oRHS.AsNode(), nil)
o := a.NewExpr(0, xOp, 0, xLHS.AsNode(), nil, oRHS.AsNode(), nil)
o.SetMBounds(bounds{zero, one})
o.SetMType(typeExprBool)
return o, nil
@@ -712,7 +712,7 @@ func (q *checker) bcheckVar(n *a.Var) error {
return err
}
lhs := a.NewExpr(0, 0, 0, n.Name(), nil, nil, nil, nil)
lhs := a.NewExpr(0, 0, n.Name(), nil, nil, nil, nil)
lhs.SetMType(n.XType())
// "var x T" has an implicit "= 0".
//
@@ -1265,7 +1265,7 @@ func makeConstValueExpr(tm *t.Map, cv *big.Int) (*a.Expr, error) {
if err != nil {
return nil, err
}
o := a.NewExpr(0, 0, 0, id, nil, nil, nil, nil)
o := a.NewExpr(0, 0, id, nil, nil, nil, nil)
o.SetConstValue(cv)
o.SetMBounds(bounds{cv, cv})
o.SetMType(typeExprIdeal)
@@ -1274,10 +1274,10 @@ func makeConstValueExpr(tm *t.Map, cv *big.Int) (*a.Expr, error) {
// makeSliceLength returns "x.length()".
func makeSliceLength(slice *a.Expr) *a.Expr {
x := a.NewExpr(0, t.IDDot, 0, t.IDLength, slice.AsNode(), nil, nil, nil)
x := a.NewExpr(0, t.IDDot, t.IDLength, slice.AsNode(), nil, nil, nil)
x.SetMBounds(bounds{one, one})
x.SetMType(a.NewTypeExpr(t.IDFunc, 0, t.IDLength, slice.MType().AsNode(), nil, nil))
x = a.NewExpr(0, t.IDOpenParen, 0, 0, x.AsNode(), nil, nil, nil)
x = a.NewExpr(0, t.IDOpenParen, 0, x.AsNode(), nil, nil, nil)
// TODO: call SetMBounds?
x.SetMType(typeExprU64)
return x
@@ -1287,7 +1287,7 @@ func makeSliceLength(slice *a.Expr) *a.Expr {
//
// n must be the t.ID of a small power of 2.
func makeSliceLengthEqEq(x t.ID, xTyp *a.TypeExpr, n t.ID) *a.Expr {
xExpr := a.NewExpr(0, 0, 0, x, nil, nil, nil, nil)
xExpr := a.NewExpr(0, 0, x, nil, nil, nil, nil)
xExpr.SetMType(xTyp)
lhs := makeSliceLength(xExpr)
@@ -1298,12 +1298,12 @@ func makeSliceLengthEqEq(x t.ID, xTyp *a.TypeExpr, n t.ID) *a.Expr {
}
cv := big.NewInt(int64(nValue))
rhs := a.NewExpr(0, 0, 0, n, nil, nil, nil, nil)
rhs := a.NewExpr(0, 0, n, nil, nil, nil, nil)
rhs.SetConstValue(cv)
rhs.SetMBounds(bounds{cv, cv})
rhs.SetMType(typeExprIdeal)
ret := a.NewExpr(0, t.IDXBinaryEqEq, 0, 0, lhs.AsNode(), nil, rhs.AsNode(), nil)
ret := a.NewExpr(0, t.IDXBinaryEqEq, 0, lhs.AsNode(), nil, rhs.AsNode(), nil)
ret.SetMBounds(bounds{zero, one})
ret.SetMType(typeExprBool)
return ret
@@ -1514,7 +1514,7 @@ func (q *checker) bcheckExprAssociativeOp(n *a.Expr, depth uint32) (bounds, erro
continue
}
lhs := a.NewExpr(n.AsNode().AsRaw().Flags(),
n.Operator(), 0, n.Ident(), n.LHS(), n.MHS(), n.RHS(), args[:i])
n.Operator(), n.Ident(), n.LHS(), n.MHS(), n.RHS(), args[:i])
lb, err = q.bcheckExprBinaryOp1(op, lhs, lb, o.AsExpr(), depth)
if err != nil {
return bounds{}, err
+1 -1
View File
@@ -140,7 +140,7 @@ func Check(tm *t.Map, files []*a.File, resolveUse func(usePath string) ([]byte,
if err != nil {
return nil, err
}
cNode := a.NewConst(0, "", 0, name, xType, a.NewExpr(0, 0, 0, value, nil, nil, nil, nil))
cNode := a.NewConst(0, "", 0, name, xType, a.NewExpr(0, 0, value, nil, nil, nil, nil))
if err := c.checkConst(cNode.AsNode()); err != nil {
return nil, err
}
+2 -2
View File
@@ -307,7 +307,7 @@ var reasons = [...]struct {
if xc0 == nil {
return errFailed
}
t1 := a.NewExpr(0, t.IDXBinaryPlus, 0, 0, xb0.AsNode(), nil, xc0.AsNode(), nil)
t1 := a.NewExpr(0, t.IDXBinaryPlus, 0, xb0.AsNode(), nil, xc0.AsNode(), nil)
if err := proveReasonRequirement(q, t.IDXBinaryLessThan, xa, t1); err != nil {
return err
}
@@ -355,7 +355,7 @@ var reasons = [...]struct {
return errFailed
}
// a <= (c - b)
t1 := a.NewExpr(0, t.IDXBinaryMinus, 0, 0, xc.AsNode(), nil, xb.AsNode(), nil)
t1 := a.NewExpr(0, t.IDXBinaryMinus, 0, xc.AsNode(), nil, xb.AsNode(), nil)
if err := proveReasonRequirement(q, t.IDXBinaryLessEq, xa, t1); err != nil {
return err
}
+1 -1
View File
@@ -230,7 +230,7 @@ func genProveReasonRequirement(n *node, name string) error {
fmt.Fprintf(&out, "if err := proveReasonRequirement(q, t.ID%s, %s, %s); err != nil { return err }\n",
key, l, r)
} else {
fmt.Fprintf(&out, "%s := a.NewExpr(0, t.ID%s, 0, 0, %s.AsNode(), nil, %s.AsNode(), nil)\n",
fmt.Fprintf(&out, "%s := a.NewExpr(0, t.ID%s, 0, %s.AsNode(), nil, %s.AsNode(), nil)\n",
name, key, l, r)
}
return nil
+1 -1
View File
@@ -109,7 +109,7 @@ func (q *checker) optimizeIOMethodAdvance(receiver *a.Expr, advance *big.Int, up
}
return a.NewExpr(x.AsNode().AsRaw().Flags(),
t.IDXBinaryGreaterEq, 0, 0, x.LHS(), nil, o.AsNode(), nil), nil
t.IDXBinaryGreaterEq, 0, x.LHS(), nil, o.AsNode(), nil), nil
})
return retOK, retErr
}
+3 -3
View File
@@ -24,9 +24,9 @@ import (
)
var (
exprArgs = a.NewExpr(0, 0, 0, t.IDArgs, nil, nil, nil, nil)
exprNullptr = a.NewExpr(0, 0, 0, t.IDNullptr, nil, nil, nil, nil)
exprThis = a.NewExpr(0, 0, 0, t.IDThis, nil, nil, nil, nil)
exprArgs = a.NewExpr(0, 0, t.IDArgs, nil, nil, nil, nil)
exprNullptr = a.NewExpr(0, 0, t.IDNullptr, nil, nil, nil, nil)
exprThis = a.NewExpr(0, 0, t.IDThis, nil, nil, nil, nil)
)
var (
+2 -2
View File
@@ -359,8 +359,8 @@ func (q *checker) tcheckExprOther(n *a.Expr, depth uint32) error {
return nil
} else if id1.IsDQStrLiteral(q.tm) {
if _, ok := q.c.statuses[n.StatusQID()]; !ok {
return fmt.Errorf("check: unrecognized status %s", n.StatusQID().Str(q.tm))
if _, ok := q.c.statuses[t.QID{0, n.Ident()}]; !ok {
return fmt.Errorf("check: unrecognized status %s", n.Ident().Str(q.tm))
}
n.SetMType(typeExprStatus)
return nil