let from_ival_int ival int =
let max_elt_int = Kernel.ArrayPrecisionLevel.get() in
let max_elt = Int.of_int max_elt_int in
let add_offset x acc = join (inject_one ~value:x ~size:int) acc in
match ival with
| Ival.Top(None, _, _, _)
| Ival.Top(_, None, _, _) | Ival.Float _ -> top
| Ival.Top(Some mn, Some mx, _r, m) ->
if Int.le m int
then inject_one ~value:mn ~size:(Int.add (Int.sub mx mn) int)
else
let elts = Int.native_div (Int.sub mx mn) m in
if Int.gt elts max_elt then begin
Kernel.result ~once:true ~current:true
"more than %d(%a) elements to enumerate. Approximating."
max_elt_int
Int.pretty elts;
top
end else Int.fold add_offset ~inf:mn ~sup:mx ~step:m bottom
| Ival.Set(s) ->
Array.fold_right
add_offset
s
bottom