| 568 | } |
| 569 | |
| 570 | func (con *converter) visitConst(expr *exprpb.Expr) error { |
| 571 | c := expr.GetConstExpr() |
| 572 | switch c.ConstantKind.(type) { |
| 573 | case *exprpb.Constant_BoolValue: |
| 574 | if c.GetBoolValue() { |
| 575 | con.str.WriteString("TRUE") |
| 576 | } else { |
| 577 | con.str.WriteString("FALSE") |
| 578 | } |
| 579 | case *exprpb.Constant_BytesValue: |
| 580 | b := c.GetBytesValue() |
| 581 | con.str.WriteString(`b"`) |
| 582 | con.str.WriteString(bytesToOctets(b)) |
| 583 | con.str.WriteString(`"`) |
| 584 | case *exprpb.Constant_DoubleValue: |
| 585 | d := strconv.FormatFloat(c.GetDoubleValue(), 'g', -1, 64) |
| 586 | con.str.WriteString(d) |
| 587 | case *exprpb.Constant_Int64Value: |
| 588 | i := strconv.FormatInt(c.GetInt64Value(), 10) |
| 589 | con.str.WriteString(i) |
| 590 | case *exprpb.Constant_NullValue: |
| 591 | con.str.WriteString("NULL") |
| 592 | case *exprpb.Constant_StringValue: |
| 593 | con.str.WriteString(strconv.Quote(c.GetStringValue())) |
| 594 | case *exprpb.Constant_Uint64Value: |
| 595 | ui := strconv.FormatUint(c.GetUint64Value(), 10) |
| 596 | con.str.WriteString(ui) |
| 597 | default: |
| 598 | return fmt.Errorf("unimplemented : %v", expr) |
| 599 | } |
| 600 | return nil |
| 601 | } |
| 602 | |
| 603 | func (con *converter) visitIdent(expr *exprpb.Expr) error { |
| 604 | con.str.WriteString("`") |