OEND
)
+// IsCmp reports whether op is a comparison operation (==, !=, <, <=,
+// >, or >=).
+func (op Op) IsCmp() bool {
+ switch op {
+ case OEQ, ONE, OLT, OLE, OGT, OGE:
+ return true
+ }
+ return false
+}
+
// Nodes is a pointer to a slice of *Node.
// For fields that are not used in most nodes, this is used instead of
// a slice to save space.
ir.EditChildren(m, edit)
m.SetTypecheck(1)
- if typecheck.IsCmp(x.Op()) {
+ if x.Op().IsCmp() {
transformCompare(m.(*ir.BinaryExpr))
} else {
switch x.Op() {
return l, r, t
}
-func IsCmp(op ir.Op) bool {
- return iscmp[op]
-}
-
// tcArith typechecks operands of a binary arithmetic expression.
// The result of tcArith MUST be assigned back to original operands,
// t is the type of the expression, and should be set by the caller. e.g:
t = r.Type()
}
aop := ir.OXXX
- if iscmp[n.Op()] && t.Kind() != types.TIDEAL && !types.Identical(l.Type(), r.Type()) {
+ if n.Op().IsCmp() && t.Kind() != types.TIDEAL && !types.Identical(l.Type(), r.Type()) {
// comparison is okay as long as one side is
// assignable to the other. convert so they have
// the same type.
// special
okfor[ir.OCAP] = okforcap[:]
okfor[ir.OLEN] = okforlen[:]
-
- // comparison
- iscmp[ir.OLT] = true
- iscmp[ir.OGT] = true
- iscmp[ir.OGE] = true
- iscmp[ir.OLE] = true
- iscmp[ir.OEQ] = true
- iscmp[ir.ONE] = true
}
func makeErrorInterface() *types.Type {