(constant: Constant)
| 68 | } |
| 69 | |
| 70 | function stringifyConstant(constant: Constant): string { |
| 71 | if (constant.constantKind?.case === "nullValue") { |
| 72 | return "null"; |
| 73 | } else if (constant.constantKind?.case === "boolValue") { |
| 74 | return constant.constantKind.value.toString(); |
| 75 | } else if (constant.constantKind?.case === "int64Value") { |
| 76 | return constant.constantKind.value.toString(); |
| 77 | } else if (constant.constantKind?.case === "uint64Value") { |
| 78 | return constant.constantKind.value.toString(); |
| 79 | } else if (constant.constantKind?.case === "doubleValue") { |
| 80 | return constant.constantKind.value.toString(); |
| 81 | } else if (constant.constantKind?.case === "stringValue") { |
| 82 | return `"${constant.constantKind.value}"`; |
| 83 | } else if (constant.constantKind?.case === "bytesValue") { |
| 84 | return `b'${constant.constantKind.value.toString()}'`; |
| 85 | } else if (constant.constantKind?.case === "durationValue") { |
| 86 | return `duration(${constant.constantKind.value})`; |
| 87 | } else if (constant.constantKind?.case === "timestampValue") { |
| 88 | return `timestamp(${constant.constantKind.value})`; |
| 89 | } else { |
| 90 | throw new Error("Unknown constant type"); |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | export default stringifyExpr; |
no test coverage detected