@@ -129,6 +129,7 @@ type typ =
129129 overapproximation of the possible values of each of its
130130 fields is given by the array of types *)
131131 | Bigarray of Bigarray .t
132+ | Null
132133 | Bot
133134
134135module Domain = struct
@@ -156,11 +157,12 @@ module Domain = struct
156157 else
157158 Array. init (max l l') ~f: (fun i ->
158159 if i < l then if i < l' then join t.(i) t'.(i) else t.(i) else t'.(i)))
159- | Int _ , Tuple _ -> t'
160- | Tuple _ , Int _ -> t
160+ | ( Int _ | Null ) , Tuple _ -> t'
161+ | Tuple _ , ( Int _ | Null ) -> t
161162 | Bigarray b , Bigarray b' when Bigarray. equal b b' -> t
163+ | Null , Null -> Null
162164 | Top , _ | _ , Top -> Top
163- | (Int _ | Number _ | Tuple _ | Bigarray _ ), _ -> Top
165+ | (Int _ | Number _ | Tuple _ | Bigarray _ | Null ), _ -> Top
164166
165167 let join_set ?(others = false ) f s =
166168 if others then Top else Var.Set. fold (fun x a -> join (f x) a) s Bot
@@ -173,20 +175,21 @@ module Domain = struct
173175 | Tuple t , Tuple t' ->
174176 Array. length t = Array. length t' && Array. for_all2 ~f: equal t t'
175177 | Bigarray b , Bigarray b' -> Bigarray. equal b b'
176- | (Top | Tuple _ | Int _ | Number _ | Bigarray _ | Bot ), _ -> false
178+ | Null , Null -> true
179+ | (Top | Tuple _ | Int _ | Number _ | Bigarray _ | Null | Bot ), _ -> false
177180
178181 let bot = Bot
179182
180183 let depth_treshold = 4
181184
182185 let rec depth t =
183186 match t with
184- | Top | Bot | Number _ | Int _ | Bigarray _ -> 0
187+ | Top | Bot | Number _ | Int _ | Bigarray _ | Null -> 0
185188 | Tuple l -> 1 + Array. fold_left ~f: (fun acc t' -> max (depth t') acc) l ~init: 0
186189
187190 let rec truncate depth t =
188191 match t with
189- | Top | Bot | Number _ | Int _ | Bigarray _ -> t
192+ | Top | Bot | Number _ | Int _ | Bigarray _ | Null -> t
190193 | Tuple l ->
191194 if depth = 0
192195 then Top
@@ -225,6 +228,7 @@ module Domain = struct
225228 | Boxed -> " boxed"
226229 | Unboxed -> " unboxed" )
227230 | Bigarray b -> Bigarray. print f b
231+ | Null -> Format. fprintf f " null"
228232 | Tuple t ->
229233 Format. fprintf
230234 f
@@ -290,6 +294,7 @@ let rec constant_type (c : constant) =
290294 | NativeInt _ -> Number (Nativeint , Unboxed )
291295 | Float _ -> Number (Float , Unboxed )
292296 | Tuple (_ , a , _ ) -> Tuple (Array. map ~f: (fun c' -> Domain. box (constant_type c')) a)
297+ | Null_ -> Null
293298 | _ -> Top
294299
295300let arg_type ~approx arg =
@@ -540,7 +545,7 @@ let box_numbers p st types =
540545 Var.Set. iter box s)
541546 | Expr _ -> ()
542547 | Phi { known; _ } -> Var.Set. iter box known)
543- | Number (_ , Boxed ) | Int _ | Tuple _ | Bigarray _ | Bot -> () )
548+ | Number (_ , Boxed ) | Int _ | Tuple _ | Bigarray _ | Null | Bot -> () )
544549 in
545550 Code. fold_closures
546551 p
0 commit comments