[sledge] Switch from Base.Array to Containers.Array

Reviewed By: jvillard

Differential Revision: D24306084

fbshipit-source-id: 93a8e0d74
master
Josh Berdine 4 years ago committed by Facebook GitHub Bot
parent b2109fa0b9
commit 9959fbb478

@ -27,7 +27,7 @@ let bindings (itv : t) =
let vars =
Environment.vars box.box1_env |> fun (i, r) -> Array.append i r
in
Array.zip_exn vars box.interval_array
Array.combine_exn vars box.interval_array
let sexp_of_t (itv : t) =
let sexps =
@ -295,8 +295,8 @@ let call ~summaries ~globals:_ ~actuals ~areturn ~formals ~freturn:_
let q'' = Abstract1.change_environment man q' callee_env false in
let q''' =
Abstract1.rename_array man q''
(Array.of_list_map ~f:(mangle >> apron_var_of_reg) formals)
(Array.of_list_map ~f:apron_var_of_reg formals)
(Array.map ~f:(mangle >> apron_var_of_reg) (Array.of_list formals))
(Array.map ~f:apron_var_of_reg (Array.of_list formals))
in
(q''', {areturn; caller_q= q})

@ -5,20 +5,24 @@
* LICENSE file in the root directory of this source tree.
*)
open NS0
include Base.Array
open! NS0
module Array = ContainersLabels.Array
include Array
let pp sep pp_elt fs a = List.pp sep pp_elt fs (to_list a)
type 'a t = 'a array [@@deriving compare, equal, sexp]
let is_empty = function [||] -> true | _ -> false
let map xs ~f = map ~f xs
let map_endo xs ~f = map_endo map xs ~f
let fold_map_inplace a ~init ~f =
let s = ref init in
let f x =
let s', x' = f !s x in
s := s' ;
x'
in
map_inplace a ~f ;
!s
let combine_exn xs ys =
let len = length xs in
if len <> length ys then invalid_arg "Array.combine_exn" ;
init len ~f:(fun i -> (xs.(i), ys.(i)))
let combine xs ys =
try Some (combine_exn xs ys) with Invalid_argument _ -> None
let fold xs ~init ~f = fold ~f ~init xs
let to_list_rev_map xs ~f = fold ~f:(fun ys x -> f x :: ys) ~init:[] xs
let pp sep pp_elt fs a = List.pp sep pp_elt fs (to_list a)

@ -5,14 +5,20 @@
* LICENSE file in the root directory of this source tree.
*)
open NS0
include module type of Base.Array
open! NS0
include module type of ContainersLabels.Array
val pp : (unit, unit) fmt -> 'a pp -> 'a array pp
type 'a t = 'a array [@@deriving compare, equal, sexp]
val is_empty : 'a t -> bool
val map : 'a t -> f:('a -> 'b) -> 'b t
val map_endo : 'a t -> f:('a -> 'a) -> 'a t
(** Like map, but specialized to require [f] to be an endofunction, which
(** Like [map], but specialized to require [f] to be an endofunction, which
enables preserving [==] if [f] preserves [==] of every element. *)
val fold_map_inplace : 'a array -> init:'s -> f:('s -> 'a -> 's * 'a) -> 's
val combine : 'a t -> 'b t -> ('a * 'b) t option
val combine_exn : 'a t -> 'b t -> ('a * 'b) t
val fold : 'a array -> init:'s -> f:('s -> 'a -> 's) -> 's
val to_list_rev_map : 'a array -> f:('a -> 'b) -> 'b list
val pp : (unit, unit) fmt -> 'a pp -> 'a array pp

@ -99,7 +99,7 @@ let struct_ =
| None ->
(* Add placeholder defn to prevent computing [elts] in calls to
[struct] from [elts] for recursive occurrences of [name]. *)
let elts = Array.create ~len:(IArray.length elt_thks) dummy_typ in
let elts = Array.make (IArray.length elt_thks) dummy_typ in
let typ =
Struct {name; elts= IArray.of_array elts; bits; byts; packed}
in

Loading…
Cancel
Save