(measureRow unsafe.Pointer, ast expr.Expr, measureBytes int)
| 224 | } |
| 225 | |
| 226 | func readMeasure(measureRow unsafe.Pointer, ast expr.Expr, measureBytes int) *float64 { |
| 227 | // TODO: consider converting non-zero identity values to nil. |
| 228 | var result float64 |
| 229 | if measureBytes == 4 { |
| 230 | switch ast.Type() { |
| 231 | case expr.Unsigned: |
| 232 | result = float64(*(*uint32)(measureRow)) |
| 233 | case expr.Signed, expr.Boolean: |
| 234 | result = float64(*(*int32)(measureRow)) |
| 235 | case expr.Float: |
| 236 | result = float64(*(*float32)(measureRow)) |
| 237 | default: |
| 238 | // Should never happen |
| 239 | return nil |
| 240 | } |
| 241 | } else if measureBytes == 8 { |
| 242 | switch ast.Type() { |
| 243 | case expr.Unsigned: |
| 244 | result = float64(*(*uint64)(measureRow)) |
| 245 | case expr.Signed, expr.Boolean: |
| 246 | result = float64(*(*int64)(measureRow)) |
| 247 | case expr.Float: |
| 248 | result = *(*float64)(measureRow) |
| 249 | default: |
| 250 | // Should never happen. |
| 251 | return nil |
| 252 | } |
| 253 | } else { // should never happen |
| 254 | return nil |
| 255 | } |
| 256 | |
| 257 | return &result |
| 258 | } |
no test coverage detected