| 253 | } |
| 254 | |
| 255 | func formatLiteral(c ref.Val) string { |
| 256 | switch v := c.(type) { |
| 257 | case types.Bool: |
| 258 | return fmt.Sprintf("%t", v) |
| 259 | case types.Bytes: |
| 260 | return fmt.Sprintf("b%s", strconv.Quote(string(v))) |
| 261 | case types.Double: |
| 262 | return fmt.Sprintf("%v", float64(v)) |
| 263 | case types.Int: |
| 264 | return fmt.Sprintf("%d", int64(v)) |
| 265 | case types.String: |
| 266 | return strconv.Quote(string(v)) |
| 267 | case types.Uint: |
| 268 | return fmt.Sprintf("%du", uint64(v)) |
| 269 | case types.Null: |
| 270 | return "null" |
| 271 | default: |
| 272 | panic("Unknown constant type") |
| 273 | } |
| 274 | } |
| 275 | |
| 276 | func (w *debugWriter) append(s string) { |
| 277 | w.doIndent() |