intervalToConstant converts an interval to a Mangle constant (pair of numbers).
(interval ast.Interval)
| 461 | |
| 462 | // intervalToConstant converts an interval to a Mangle constant (pair of numbers). |
| 463 | func intervalToConstant(interval ast.Interval) ast.Constant { |
| 464 | var startNano, endNano int64 |
| 465 | |
| 466 | if interval.Start.Type == ast.TimestampBound { |
| 467 | startNano = interval.Start.Timestamp |
| 468 | } else if interval.Start.Type == ast.NegativeInfinityBound { |
| 469 | startNano = math.MinInt64 // -inf |
| 470 | } |
| 471 | |
| 472 | if interval.End.Type == ast.TimestampBound { |
| 473 | endNano = interval.End.Timestamp |
| 474 | } else if interval.End.Type == ast.PositiveInfinityBound { |
| 475 | endNano = math.MaxInt64 // +inf |
| 476 | } |
| 477 | |
| 478 | startConst := ast.Number(startNano) |
| 479 | endConst := ast.Number(endNano) |
| 480 | return ast.Pair(&startConst, &endConst) |
| 481 | } |
| 482 | |
| 483 | // premiseTemporalLiteral evaluates a temporal literal premise. |
| 484 | // This is called from oneStepEvalPremise when encountering a TemporalLiteral. |