(expr ast.Expr)
| 191 | } |
| 192 | |
| 193 | func (un *unparser) visitCallBinary(expr ast.Expr) error { |
| 194 | c := expr.AsCall() |
| 195 | fun := c.FunctionName() |
| 196 | args := c.Args() |
| 197 | lhs := args[0] |
| 198 | // add parens if the current operator is lower precedence than the lhs expr operator. |
| 199 | lhsParen := isComplexOperatorWithRespectTo(fun, lhs) |
| 200 | rhs := args[1] |
| 201 | // add parens if the current operator is lower precedence than the rhs expr operator, |
| 202 | // or the same precedence and the operator is left recursive. |
| 203 | rhsParen := isComplexOperatorWithRespectTo(fun, rhs) |
| 204 | if !rhsParen && isLeftRecursive(fun) { |
| 205 | rhsParen = isSamePrecedence(fun, rhs) |
| 206 | } |
| 207 | err := un.visitMaybeNested(lhs, lhsParen) |
| 208 | if err != nil { |
| 209 | return err |
| 210 | } |
| 211 | unmangled, found := operators.FindReverseBinaryOperator(fun) |
| 212 | if !found { |
| 213 | return fmt.Errorf("cannot unmangle operator: %s", fun) |
| 214 | } |
| 215 | |
| 216 | un.writeOperatorWithWrapping(fun, unmangled) |
| 217 | return un.visitMaybeNested(rhs, rhsParen) |
| 218 | } |
| 219 | |
| 220 | func (un *unparser) visitCallConditional(expr ast.Expr) error { |
| 221 | c := expr.AsCall() |
no test coverage detected