Class ConstraintWindows
constrain as expression into the inclusive numeric window
[lo,hi] it narrows to — call this, do not re-derive it.
The long[] {lo, hi} encoding is this package's window currency: CriticalValues
tests a window for disjointness, WitnessEnumerator enumerates its edges, SymbolicEngine
discharges or refutes against it, and the fuzz generator sprays its edges as test inputs
(SymbolHarvester.constraintWindowEdges). This class is the ONE place that knows how a
ConstraintExpr becomes that pair, and the one place that renders it for a human. It was
extracted from SymbolicEngine's private helpers when the generator needed the same fold —
a second copy would have let the verifier and the generator disagree about what a constrained
type's admissible values are.
Not the only admissibility route, and not interchangeable with the other one. The window
answers "which INTERVAL of values does this constraint admit"; EquivalenceClassModel
.admissibleClassCount answers "which of the base type's VALUE-CLASSES does it admit", by probing each
class's representative literal through CompileTimeConstraintEvaluator
(the evaluator that powers E08260). Those are different questions with different domains — the probe
handles String and matches, which have no interval at all, while the window reaches boundary
values no representative literal names. Do not fold one into the other, and do not add a third:
anything new belongs on one of these two.
Integer only, deliberately. A window is a fold over ORDER, so it is defined only where the
constrained base has a total order the compiler can evaluate at compile time as a long.
Anything else — a Float or String literal, an or-combination (which is a union, not an
interval), <> / matches / contains — yields null, meaning "no decidable
window", and every caller must treat null as "know nothing" rather than "empty".
-
Method Summary
Modifier and TypeMethodDescriptionstatic long[]windowOf(ConstraintExpr constraint) The inclusive numeric window[lo,hi]an Integer constraint narrows to, or null when it is not a decidable numeric window.static StringwindowText(long[] window) A window rendered for a human, with an unbounded end shown as an ellipsis rather than theLongextreme that stands in for it.
-
Method Details
-
windowOf
The inclusive numeric window[lo,hi]an Integer constraint narrows to, or null when it is not a decidable numeric window. Handles a single comparison andand-combinations of them; an absent bound stays at theLongextreme, soconstrain as > 0folds to[1, Long.MAX_VALUE].- Parameters:
constraint- the constrained type's constraint expression, may be null- Returns:
- the window, or null when nothing decidable can be said
-
windowText
A window rendered for a human, with an unbounded end shown as an ellipsis rather than theLongextreme that stands in for it.- Parameters:
window- the[lo,hi]pair- Returns:
- the rendered window, e.g.
[0, 100]or[1, …]
-