newBinExprIfValidOverload constructs a new BinaryExpr if and only if the pair of arguments have a valid implementation for the given BinaryOperator.
(op BinaryOperator, left TypedExpr, right TypedExpr)
| 1159 | // if the pair of arguments have a valid implementation for the given |
| 1160 | // BinaryOperator. |
| 1161 | func newBinExprIfValidOverload(op BinaryOperator, left TypedExpr, right TypedExpr) *BinaryExpr { |
| 1162 | leftRet, rightRet := left.ResolvedType(), right.ResolvedType() |
| 1163 | fn, ok := BinOps[op].lookupImpl(leftRet, rightRet) |
| 1164 | if ok { |
| 1165 | expr := &BinaryExpr{ |
| 1166 | Operator: op, |
| 1167 | Left: left, |
| 1168 | Right: right, |
| 1169 | fn: fn, |
| 1170 | } |
| 1171 | expr.typ = returnTypeToFixedType(fn.returnType(), []TypedExpr{left, right}) |
| 1172 | return expr |
| 1173 | } |
| 1174 | return nil |
| 1175 | } |
| 1176 | |
| 1177 | // Format implements the NodeFormatter interface. |
| 1178 | func (node *BinaryExpr) Format(ctx *FmtCtx) { |
no test coverage detected
searching dependent graphs…