Skip to content

Commit bc267c8

Browse files
committed
Remove IntDomain.BigInt
1 parent a8d74cd commit bc267c8

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

src/cdomain/value/cdomains/intDomain.ml

+8-13
Original file line numberDiff line numberDiff line change
@@ -1773,13 +1773,8 @@ struct
17731773
include (Lattice.Reverse (Base) : Lattice.S with type t := Base.t)
17741774
end
17751775

1776-
module BigInt = struct
1777-
include IntOps.BigIntOps
1778-
let arbitrary () = QCheck.map ~rev:Z.to_int64 Z.of_int64 QCheck.int64
1779-
end
1780-
17811776
module BISet = struct
1782-
include SetDomain.Make (BigInt)
1777+
include SetDomain.Make (IntOps.BigIntOps)
17831778
let is_singleton s = cardinal s = 1
17841779
end
17851780

@@ -2062,7 +2057,7 @@ struct
20622057
let of_bool = of_bool_cmp
20632058
let to_bool x =
20642059
match x with
2065-
| `Definite x -> Some (BigInt.to_bool x)
2060+
| `Definite x -> Some (IntOps.BigIntOps.to_bool x)
20662061
| `Excluded (s,r) when S.mem Z.zero s -> Some true
20672062
| _ -> None
20682063
let top_bool = `Excluded (S.empty (), R.of_interval range_ikind (0L, 1L))
@@ -2257,14 +2252,14 @@ struct
22572252
| _, Some false ->
22582253
of_bool ik false
22592254
| _, _ ->
2260-
lift2 BigInt.logand ik x y
2255+
lift2 IntOps.BigIntOps.logand ik x y
22612256
let logor ik x y =
22622257
match to_bool x, to_bool y with
22632258
| Some true, _
22642259
| _, Some true ->
22652260
of_bool ik true
22662261
| _, _ ->
2267-
lift2 BigInt.logor ik x y
2262+
lift2 IntOps.BigIntOps.logor ik x y
22682263
let lognot ik = eq ik (of_int ik Z.zero)
22692264

22702265
let invariant_ikind e ik (x:t) =
@@ -2297,12 +2292,12 @@ struct
22972292
let definite x = of_int ik x in
22982293
let shrink = function
22992294
| `Excluded (s, _) -> GobQCheck.shrink (S.arbitrary ()) s >|= excluded (* S TODO: possibly shrink excluded to definite *)
2300-
| `Definite x -> (return `Bot) <+> (GobQCheck.shrink (BigInt.arbitrary ()) x >|= definite)
2295+
| `Definite x -> (return `Bot) <+> (GobQCheck.shrink (IntOps.BigIntOps.arbitrary ()) x >|= definite)
23012296
| `Bot -> empty
23022297
in
23032298
QCheck.frequency ~shrink ~print:show [
23042299
20, QCheck.map excluded (S.arbitrary ());
2305-
10, QCheck.map definite (BigInt.arbitrary ());
2300+
10, QCheck.map definite (IntOps.BigIntOps.arbitrary ());
23062301
1, QCheck.always `Bot
23072302
] (* S TODO: decide frequencies *)
23082303

@@ -2630,8 +2625,8 @@ module Enums : S with type int_t = Z.t = struct
26302625
| Some b -> of_bool ik (not b)
26312626
| None -> top_bool
26322627

2633-
let logand = lift2 BigInt.logand
2634-
let logor = lift2 BigInt.logor
2628+
let logand = lift2 IntOps.BigIntOps.logand
2629+
let logor = lift2 IntOps.BigIntOps.logor
26352630
let maximal = function
26362631
| Inc xs when not (BISet.is_empty xs) -> Some (BISet.max_elt xs)
26372632
| Exc (excl,r) ->

src/common/util/intOps.ml

+9
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ sig
5555
val to_string : t -> string
5656
val of_bigint : Z.t -> t
5757
val to_bigint : t -> Z.t
58+
59+
val arbitrary : unit -> t QCheck.arbitrary
5860
end
5961

6062
module type IntOps =
@@ -115,6 +117,8 @@ struct
115117
let to_string = string_of_int
116118
let of_bigint = Z.to_int
117119
let to_bigint = Z.of_int
120+
121+
let arbitrary () = QCheck.int
118122
end
119123

120124
module Int32OpsBase : IntOpsBase with type t = int32 =
@@ -161,6 +165,8 @@ struct
161165
let to_string = Int32.to_string
162166
let of_bigint = Z.to_int32
163167
let to_bigint = Z.of_int32
168+
169+
let arbitrary () = QCheck.int32
164170
end
165171

166172
module Int64OpsBase : IntOpsBase with type t = int64 =
@@ -207,6 +213,8 @@ struct
207213
let to_string = Int64.to_string
208214
let of_bigint = Z.to_int64
209215
let to_bigint = Z.of_int64
216+
217+
let arbitrary () = QCheck.int64
210218
end
211219

212220
module BigIntOpsBase : IntOpsBase with type t = Z.t =
@@ -252,6 +260,7 @@ struct
252260
let bitor = Z.logor
253261
let bitxor = Z.logxor
254262

263+
let arbitrary () = QCheck.map ~rev:Z.to_int64 Z.of_int64 QCheck.int64
255264
end
256265

257266

0 commit comments

Comments
 (0)