| 101 | } |
| 102 | |
| 103 | int64_t constantDecodeAsInt64(const ConstantEncoded& enc) { |
| 104 | const uint8_t* ptr = enc.value_bytes.data(); |
| 105 | switch (enc.value_kind) { |
| 106 | case StorageKind::kInt32: { |
| 107 | int32_t v{}; |
| 108 | std::memcpy(&v, ptr, sizeof(v)); |
| 109 | return static_cast<int64_t>(v); |
| 110 | } |
| 111 | case StorageKind::kInt64: { |
| 112 | int64_t v{}; |
| 113 | std::memcpy(&v, ptr, sizeof(v)); |
| 114 | return v; |
| 115 | } |
| 116 | case StorageKind::kUint64: { |
| 117 | uint64_t v{}; |
| 118 | std::memcpy(&v, ptr, sizeof(v)); |
| 119 | return static_cast<int64_t>(v); |
| 120 | } |
| 121 | case StorageKind::kFloat32: { |
| 122 | float v{}; |
| 123 | std::memcpy(&v, ptr, sizeof(v)); |
| 124 | return static_cast<int64_t>(v); |
| 125 | } |
| 126 | case StorageKind::kFloat64: { |
| 127 | double v{}; |
| 128 | std::memcpy(&v, ptr, sizeof(v)); |
| 129 | return static_cast<int64_t>(v); |
| 130 | } |
| 131 | default: |
| 132 | return 0; |
| 133 | } |
| 134 | } |
| 135 | |
| 136 | uint64_t constantDecodeAsUint64(const ConstantEncoded& enc) { |
| 137 | const uint8_t* ptr = enc.value_bytes.data(); |
no test coverage detected