(n *chast.CaseExpr)
| 543 | } |
| 544 | |
| 545 | func (c *cc) convertCaseExpr(n *chast.CaseExpr) *ast.CaseExpr { |
| 546 | ce := &ast.CaseExpr{ |
| 547 | Location: n.Pos().Offset, |
| 548 | } |
| 549 | |
| 550 | // Convert test expression (CASE expr WHEN ...) |
| 551 | if n.Operand != nil { |
| 552 | ce.Arg = c.convertExpr(n.Operand) |
| 553 | } |
| 554 | |
| 555 | // Convert WHEN clauses |
| 556 | if len(n.Whens) > 0 { |
| 557 | ce.Args = &ast.List{} |
| 558 | for _, when := range n.Whens { |
| 559 | caseWhen := &ast.CaseWhen{ |
| 560 | Expr: c.convertExpr(when.Condition), |
| 561 | Result: c.convertExpr(when.Result), |
| 562 | } |
| 563 | ce.Args.Items = append(ce.Args.Items, caseWhen) |
| 564 | } |
| 565 | } |
| 566 | |
| 567 | // Convert ELSE clause |
| 568 | if n.Else != nil { |
| 569 | ce.Defresult = c.convertExpr(n.Else) |
| 570 | } |
| 571 | |
| 572 | return ce |
| 573 | } |
| 574 | |
| 575 | func (c *cc) convertCastExpr(n *chast.CastExpr) *ast.TypeCast { |
| 576 | tc := &ast.TypeCast{ |
no test coverage detected