Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch from BatEnum to Seq #1443

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dune-project
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
(depends
(ocaml (>= 4.10))
(goblint-cil (>= 2.0.3)) ; TODO no way to define as pin-depends? Used goblint.opam.template to add it for now. https://github.com/ocaml/dune/issues/3231. Alternatively, removing this line and adding cil as a git submodule and `(vendored_dirs cil)` as ./dune also works. This way, no more need to reinstall the pinned cil opam package on changes. However, then cil is cleaned and has to be rebuild together with goblint.
(batteries (>= 3.5.1))
(batteries (>= 3.7.1))
(zarith (>= 1.10))
(yojson (>= 2.0.0))
(qcheck-core (>= 0.19))
Expand Down
2 changes: 1 addition & 1 deletion goblint.opam
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ depends: [
"dune" {>= "3.7"}
"ocaml" {>= "4.10"}
"goblint-cil" {>= "2.0.3"}
"batteries" {>= "3.5.1"}
"batteries" {>= "3.7.1"}
"zarith" {>= "1.10"}
"yojson" {>= "2.0.0"}
"qcheck-core" {>= "0.19"}
Expand Down
2 changes: 1 addition & 1 deletion goblint.opam.locked
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ depends: [
"base-bytes" {= "base"}
"base-threads" {= "base"}
"base-unix" {= "base"}
"batteries" {= "3.6.0"}
"batteries" {= "3.7.1"}
"benchmark" {= "1.6" & with-test}
"bigarray-compat" {= "1.1.0"}
"bigstringaf" {= "0.9.0"}
Expand Down
6 changes: 3 additions & 3 deletions src/analyses/apron/relationAnalysis.apron.ml
Original file line number Diff line number Diff line change
Expand Up @@ -623,8 +623,8 @@ struct
)
in
RD.invariant apr
|> List.enum
|> Enum.filter_map (fun (lincons1: Apron.Lincons1.t) ->
|> List.to_seq
|> Seq.filter_map (fun (lincons1: Apron.Lincons1.t) ->
(* filter one-vars and exact *)
(* TODO: exact filtering doesn't really work with octagon because it returns two SUPEQ constraints instead *)
if (one_var || GobApron.Lincons1.num_vars lincons1 >= 2) && (exact || Apron.Lincons1.get_typ lincons1 <> EQ) then
Expand All @@ -634,7 +634,7 @@ struct
else
None
)
|> Enum.fold (fun acc x -> Invariant.(acc && of_exp x)) Invariant.none
|> Seq.fold_left (fun acc x -> Invariant.(acc && of_exp x)) Invariant.none

let query ctx (type a) (q: a Queries.t): a Queries.result =
let open Queries in
Expand Down
16 changes: 8 additions & 8 deletions src/analyses/apron/relationPriv.apron.ml
Original file line number Diff line number Diff line change
Expand Up @@ -354,14 +354,14 @@ struct
let rel = st.rel in
let (g_vars, gs) =
RD.vars rel
|> List.enum
|> Enum.filter_map (fun var ->
|> List.to_seq
|> Seq.filter_map (fun var ->
match RD.V.find_metadata var with
| Some (Global g) -> Some (var, g)
| _ -> None
)
|> Enum.uncombine
|> Tuple2.map List.of_enum List.of_enum
|> Seq.unzip
|> Tuple2.map List.of_seq List.of_seq
in
let g_unprot_vars = List.map AV.unprot gs in
let g_prot_vars = List.map AV.prot gs in
Expand All @@ -386,14 +386,14 @@ struct
let rel = st.rel in
let (g_vars, gs) =
RD.vars rel
|> List.enum
|> Enum.filter_map (fun var ->
|> List.to_seq
|> Seq.filter_map (fun var ->
match RD.V.find_metadata var with
| Some (Global g) -> Some (var, g)
| _ -> None
)
|> Enum.uncombine
|> Tuple2.map List.of_enum List.of_enum
|> Seq.unzip
|> Tuple2.map List.of_seq List.of_seq
in
let g_unprot_vars = List.map AV.unprot gs in
let g_prot_vars = List.map AV.prot gs in
Expand Down
4 changes: 2 additions & 2 deletions src/analyses/deadlock.ml
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ struct
) (List.tl path_visited_lock_event_pairs)
in
let mhp =
Enum.cartesian_product (List.enum path_visited_lock_event_pairs) (List.enum path_visited_lock_event_pairs)
|> Enum.for_all (fun (((_, (_, _, access1)) as p1), ((_, (_, _, access2)) as p2)) ->
Seq.product (List.to_seq path_visited_lock_event_pairs) (List.to_seq path_visited_lock_event_pairs)
|> Seq.for_all (fun (((_, (_, _, access1)) as p1), ((_, (_, _, access2)) as p2)) ->
LockEventPair.equal p1 p2 || MCPAccess.A.may_race access1 access2
)
in
Expand Down
7 changes: 3 additions & 4 deletions src/analyses/extractPthread.ml
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ module Tbls = struct
table |> Hashtbl.filter (( = ) v) |> Hashtbl.keys |> Enum.get


let to_list () = table |> Hashtbl.enum |> List.of_enum
let to_list () = table |> Hashtbl.bindings
end

module Tbl (G : TblGen) = struct
Expand All @@ -146,7 +146,7 @@ module Tbls = struct

let get k = Hashtbl.find table k

let get_key v = table |> Hashtbl.enum |> List.of_enum |> List.assoc_inv v
let get_key v = table |> Hashtbl.bindings |> List.assoc_inv v
end

let all_keys_count table =
Expand Down Expand Up @@ -411,8 +411,7 @@ module Variables = struct
Some v
| _ ->
None)
|> Set.enum
|> List.of_enum
|> Set.elements


let is_top tid var =
Expand Down
54 changes: 27 additions & 27 deletions src/cdomains/apron/apronDomain.apron.ml
Original file line number Diff line number Diff line change
Expand Up @@ -295,27 +295,27 @@ struct
(* partition assigns with supported and unsupported exps *)
let (supported, unsupported) =
ves
|> List.enum
|> Enum.map (Tuple2.map2 (fun e ->
|> List.to_seq
|> Seq.map (Tuple2.map2 (fun e ->
match Convert.texpr1_of_cil_exp ask nd env e (Lazy.from_val no_ov) with
| texpr1 -> Some texpr1
| exception Convert.Unsupported_CilExp _ -> None
))
|> Enum.partition (fun (_, e_opt) -> Option.is_some e_opt)
|> Seq.partition (fun (_, e_opt) -> Option.is_some e_opt)
in
(* parallel assign supported *)
let (supported_vs, texpr1s) =
supported
|> Enum.map (Tuple2.map2 Option.get)
|> Enum.uncombine
|> Tuple2.map Array.of_enum Array.of_enum
|> Seq.map (Tuple2.map2 Option.get)
|> Seq.unzip
|> Tuple2.map Array.of_seq Array.of_seq
in
A.assign_texpr_array_with Man.mgr nd supported_vs texpr1s None;
(* forget unsupported *)
let unsupported_vs =
unsupported
|> Enum.map fst
|> Array.of_enum
|> Seq.map fst
|> Array.of_seq
in
A.forget_array_with Man.mgr nd unsupported_vs false

Expand All @@ -328,10 +328,10 @@ struct
let env = A.env nd in
let (vs, texpr1s) =
vv's
|> List.enum
|> Enum.map (Tuple2.map2 (Texpr1.var env))
|> Enum.uncombine
|> Tuple2.map Array.of_enum Array.of_enum
|> List.to_seq
|> Seq.map (Tuple2.map2 (Texpr1.var env))
|> Seq.unzip
|> Tuple2.map Array.of_seq Array.of_seq
in
A.assign_texpr_array_with Man.mgr nd vs texpr1s None

Expand All @@ -341,9 +341,9 @@ struct
let vs = Array.of_list vs in
let texpr1s =
v's
|> List.enum
|> Enum.map (Texpr1.var env)
|> Array.of_enum
|> List.to_seq
|> Seq.map (Texpr1.var env)
|> Array.of_seq
in
A.assign_texpr_array Man.mgr d vs texpr1s None

Expand All @@ -360,27 +360,27 @@ struct
(* partition substitutes with supported and unsupported exps *)
let (supported, unsupported) =
ves
|> List.enum
|> Enum.map (Tuple2.map2 (fun e ->
|> List.to_seq
|> Seq.map (Tuple2.map2 (fun e ->
match Convert.texpr1_of_cil_exp ask nd env e no_ov with
| texpr1 -> Some texpr1
| exception Convert.Unsupported_CilExp _ -> None
))
|> Enum.partition (fun (_, e_opt) -> Option.is_some e_opt)
|> Seq.partition (fun (_, e_opt) -> Option.is_some e_opt)
in
(* parallel substitute supported *)
let (supported_vs, texpr1s) =
supported
|> Enum.map (Tuple2.map2 Option.get)
|> Enum.uncombine
|> Tuple2.map Array.of_enum Array.of_enum
|> Seq.map (Tuple2.map2 Option.get)
|> Seq.unzip
|> Tuple2.map Array.of_seq Array.of_seq
in
A.substitute_texpr_array_with Man.mgr nd supported_vs texpr1s None;
(* forget unsupported *)
let unsupported_vs =
unsupported
|> Enum.map fst
|> Array.of_enum
|> Seq.map fst
|> Array.of_seq
in
A.forget_array_with Man.mgr nd unsupported_vs false

Expand Down Expand Up @@ -550,11 +550,11 @@ struct
(* let x = A.copy Man.mgr x in
A.minimize Man.mgr x; *)
let {lincons0_array; array_env}: Lincons1.earray = A.to_lincons_array Man.mgr x in
Array.enum lincons0_array
|> Enum.map (fun (lincons0: Lincons0.t) ->
Array.to_seq lincons0_array
|> Seq.map (fun (lincons0: Lincons0.t) ->
Lincons1.{lincons0; env = array_env}
)
|> List.of_enum
|> List.of_seq
end

(** With heterogeneous environments. *)
Expand Down Expand Up @@ -738,7 +738,7 @@ struct
in
let tcons1_earray: Tcons1.earray = {
array_env = y_env;
tcons0_array = tcons1s |> List.enum |> Enum.map Tcons1.get_tcons0 |> Array.of_enum
tcons0_array = tcons1s |> List.to_seq |> Seq.map Tcons1.get_tcons0 |> Array.of_seq
}
in
let w = A.widening Man.mgr x y in
Expand Down
38 changes: 19 additions & 19 deletions src/cdomains/apron/gobApron.apron.ml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ struct
include Set.Make (Lincons1)

let of_earray ({lincons0_array; array_env}: Lincons1.earray): t =
Array.enum lincons0_array
|> Enum.map (fun (lincons0: Lincons0.t) ->
Array.to_seq lincons0_array
|> Seq.map (fun (lincons0: Lincons0.t) ->
Lincons1.{lincons0; env = array_env}
)
|> of_enum
|> of_seq
end

(** A few code elements for environment changes from functions as remove_vars etc. have been moved to sharedFunctions as they are needed in a similar way inside affineEqualityDomain.
Expand All @@ -45,32 +45,32 @@ struct
let ivars_only env =
let ivs, fvs = Environment.vars env in
assert (Array.length fvs = 0); (* shouldn't ever contain floats *)
List.of_enum (Array.enum ivs)
Array.to_list ivs

let add_vars env vs =
let vs' =
vs
|> List.enum
|> Enum.filter (fun v -> not (Environment.mem_var env v))
|> Array.of_enum
|> List.to_seq
|> Seq.filter (fun v -> not (Environment.mem_var env v))
|> Array.of_seq
in
Environment.add env vs' [||]

let remove_vars env vs =
let vs' =
vs
|> List.enum
|> Enum.filter (fun v -> Environment.mem_var env v)
|> Array.of_enum
|> List.to_seq
|> Seq.filter (fun v -> Environment.mem_var env v)
|> Array.of_seq
in
Environment.remove env vs'

let remove_filter env f =
let vs' =
ivars_only env
|> List.enum
|> Enum.filter f
|> Array.of_enum
|> List.to_seq
|> Seq.filter f
|> Array.of_seq
in
Environment.remove env vs'

Expand All @@ -79,9 +79,9 @@ struct
make a new env with just the desired vs. *)
let vs' =
vs
|> List.enum
|> Enum.filter (fun v -> Environment.mem_var env v)
|> Array.of_enum
|> List.to_seq
|> Seq.filter (fun v -> Environment.mem_var env v)
|> Array.of_seq
in
Environment.make vs' [||]

Expand All @@ -90,9 +90,9 @@ struct
make a new env with just the desired vars. *)
let vs' =
ivars_only env
|> List.enum
|> Enum.filter f
|> Array.of_enum
|> List.to_seq
|> Seq.filter f
|> Array.of_seq
in
Environment.make vs' [||]
end
4 changes: 2 additions & 2 deletions src/solver/effectWConEq.ml
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ module Make =
HM.replace rho x tmp;
let w = try HM.find infl x with Not_found -> VS.empty in
HM.replace infl x VS.empty;
BatEnum.iter (HM.remove stable) (VS.enum w);
BatEnum.iter solve (VS.enum w)
VS.iter (HM.remove stable) w;
VS.iter solve w
end
in

Expand Down
6 changes: 3 additions & 3 deletions src/solver/sLR.ml
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ module SLR3 =
HM.replace rho x tmp;
let w = try HM.find infl x with Not_found -> VS.empty in
let w = if wpx then VS.add x w else w in
q := Enum.fold (fun x y -> H.add y x) !q (VS.enum w);
q := VS.fold H.add w !q;
HM.replace infl x VS.empty;
Enum.iter (HM.remove stable) (VS.enum w)
VS.iter (HM.remove stable) w
end;
while (H.size !q <> 0) && (min_key q <= get_key x) do
solve (extract_min q)
Expand Down Expand Up @@ -107,7 +107,7 @@ module SLR3 =
HM.find rho y
and sides x =
let w = try HM.find set x with Not_found -> VS.empty in
Enum.fold (fun d z -> try S.Dom.join d (HPM.find rho' (z,x)) with Not_found -> d) (S.Dom.bot ()) (VS.enum w)
VS.fold (fun z d -> try S.Dom.join d (HPM.find rho' (z,x)) with Not_found -> d) w (S.Dom.bot ())
and side x y d =
HM.add globals y ();
if not (HM.mem rho y) then begin
Expand Down
6 changes: 3 additions & 3 deletions src/solver/sLRphased.ml
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ module Make =
HM.replace rho x val_new;
let w = try HM.find infl x with Not_found -> VS.empty in
(* let w = if wpx then VS.add x w else w in *)
q := Enum.fold (fun x y -> H.add y x) !q (VS.enum w);
q := VS.fold H.add w !q;
HM.replace infl x VS.empty
end
and solve0 ?(side=false) x =
Expand Down Expand Up @@ -156,12 +156,12 @@ module Make =
HM.replace rho1 x d;
let w = VS.add x @@ try HM.find infl x with Not_found -> VS.empty in
HM.replace infl x VS.empty;
q := Enum.fold (fun x y -> H.add y x) !q (VS.enum w);
q := VS.fold H.add w !q;
iterate true prio
)
and sides x =
let w = try HM.find set x with Not_found -> VS.empty in
let v = Enum.fold (fun d z -> try S.Dom.join d (HPM.find rho' (z,x)) with Not_found -> d) (S.Dom.bot ()) (VS.enum w)
let v = VS.fold (fun z d -> try S.Dom.join d (HPM.find rho' (z,x)) with Not_found -> d) w (S.Dom.bot ())
in if tracing then trace "sol" "SIDES: Var: %a\nVal: %a" S.Var.pretty_trace x S.Dom.pretty v; v
and eq x get set =
eval_rhs_event x;
Expand Down
Loading
Loading