Add ast.ExprOperatorEtc constants

This commit is contained in:
Nigel Tao committed 2021-03-29 19:54:51 +11:00
1 parent 41e407a774
commit decb64e5ea
8 files changed
+34 -26

No files matched your search

+4 -4
View File
@@ -331,7 +331,7 @@ func (q *checker) bcheckStatement(n *a.Node) error {
}
if lTyp.IsStatus() {
if v := n.Value(); (v.Operator() == 0) || (v.Operator() == t.IDDot) {
if v := n.Value(); (v.Operator() == 0) || (v.Operator() == a.ExprOperatorSelector) {
if id := v.Ident(); (id != t.IDOk) && (q.hasIsErrorFact(id) || isErrorStatus(id, q.tm)) {
n.SetRetsError()
}
@@ -430,7 +430,7 @@ func (q *checker) bcheckAssert(n *a.Assert) error {
func (q *checker) bcheckAssignment(lhs *a.Expr, op t.ID, rhs *a.Expr) error {
oldFacts := (map[*a.Expr]struct{})(nil)
if (rhs.Operator() == t.IDOpenParen) && rhs.Effect().Impure() {
if (rhs.Operator() == a.ExprOperatorCall) && rhs.Effect().Impure() {
oldFacts = map[*a.Expr]struct{}{}
for _, x := range q.facts {
oldFacts[x] = struct{}{}
@@ -450,7 +450,7 @@ func (q *checker) bcheckAssignment(lhs *a.Expr, op t.ID, rhs *a.Expr) error {
return err
}
if (rhs.Operator() == t.IDOpenParen) && rhs.Effect().Impure() {
if (rhs.Operator() == a.ExprOperatorCall) && rhs.Effect().Impure() {
if rhs.Effect().Coroutine() && (op != t.IDEqQuestion) {
if err := q.facts.update(updateFactsForSuspension); err != nil {
return err
@@ -505,7 +505,7 @@ func (q *checker) bcheckAssignment(lhs *a.Expr, op t.ID, rhs *a.Expr) error {
if lhs.MType().IsNumType() && rhs.Effect().Pure() {
q.facts.appendBinaryOpFact(t.IDXBinaryEqEq, lhs, rhs)
if rhs.Operator() == t.IDOpenParen {
if rhs.Operator() == a.ExprOperatorCall {
if lTyp := rhs.LHS().AsExpr().MType(); lTyp.IsFuncType() && lTyp.Receiver().IsNumType() {
switch fn := lTyp.FuncName(); fn {
case t.IDMax, t.IDMin:
+6 -6
View File
@@ -33,12 +33,12 @@ import (
// splitReceiverMethodArgs returns the "receiver", "method" and "args" in the
// expression "receiver.method(args)".
func splitReceiverMethodArgs(n *a.Expr) (receiver *a.Expr, method t.ID, args []*a.Node) {
if n.Operator() != t.IDOpenParen {
if n.Operator() != a.ExprOperatorCall {
return nil, 0, nil
}
args = n.Args()
n = n.LHS().AsExpr()
if n.Operator() != t.IDDot {
if n.Operator() != a.ExprOperatorSelector {
return nil, 0, nil
}
return n.LHS().AsExpr(), n.Ident(), args
@@ -94,11 +94,11 @@ func (q *checker) optimizeIOMethodAdvance(receiver *a.Expr, advance *big.Int, ad
// Check that lhs is "receiver.length()".
lhs := x.LHS().AsExpr()
if lhs.Operator() != t.IDOpenParen || len(lhs.Args()) != 0 {
if (lhs.Operator() != a.ExprOperatorCall) || (len(lhs.Args()) != 0) {
return x, nil
}
lhs = lhs.LHS().AsExpr()
if lhs.Operator() != t.IDDot || lhs.Ident() != t.IDLength {
if (lhs.Operator() != a.ExprOperatorSelector) || (lhs.Ident() != t.IDLength) {
return x, nil
}
lhs = lhs.LHS().AsExpr()
@@ -155,11 +155,11 @@ func (q *checker) optimizeIOMethodAdvanceExpr(receiver *a.Expr, advanceExpr *a.E
// Check that lhs is "receiver.length()".
lhs := x.LHS().AsExpr()
if lhs.Operator() != t.IDOpenParen || len(lhs.Args()) != 0 {
if (lhs.Operator() != a.ExprOperatorCall) || (len(lhs.Args()) != 0) {
return x, nil
}
lhs = lhs.LHS().AsExpr()
if lhs.Operator() != t.IDDot || lhs.Ident() != t.IDLength {
if (lhs.Operator() != a.ExprOperatorSelector) || (lhs.Ident() != t.IDLength) {
return x, nil
}
lhs = lhs.LHS().AsExpr()