Core.Std.Int.Set

Reviewed By: cristianoc

Differential Revision: D4232448

fbshipit-source-id: 83d9a98
master
Josh Berdine 8 years ago committed by Facebook Github Bot
parent 900da595b1
commit 23cda11fda

@ -155,11 +155,11 @@ let summary_values top_proc_set summary => {
let visited = ref Specs.Visitedset.empty;
let do_spec spec => visited := Specs.Visitedset.union spec.Specs.visited !visited;
IList.iter do_spec specs;
let visited_lines = ref IntSet.empty;
let visited_lines = ref Int.Set.empty;
Specs.Visitedset.iter
(fun (_, ls) => IList.iter (fun l => visited_lines := IntSet.add l !visited_lines) ls)
(fun (_, ls) => IList.iter (fun l => visited_lines := Int.Set.add !visited_lines l) ls)
!visited;
(Specs.Visitedset.cardinal !visited, IntSet.elements !visited_lines)
(Specs.Visitedset.cardinal !visited, Int.Set.elements !visited_lines)
};
let proof_trace = {
let pp_line fmt l => F.fprintf fmt "%d" l;

@ -144,7 +144,7 @@ module Visitedset =
let visited_str vis =
let s = ref "" in
let lines = ref IntSet.empty in
let lines = ref Int.Set.empty in
let do_one (_, ns) =
(* if IList.length ns > 1 then
begin
@ -152,9 +152,9 @@ let visited_str vis =
IList.iter (fun n -> ss := !ss ^ " " ^ string_of_int n) ns;
L.err "Node %d has lines %s@." node !ss
end; *)
IList.iter (fun n -> lines := IntSet.add n !lines) ns in
IList.iter (fun n -> lines := Int.Set.add !lines n) ns in
Visitedset.iter do_one vis;
IntSet.iter (fun n -> s := !s ^ " " ^ string_of_int n) !lines;
Int.Set.iter ~f:(fun n -> s := !s ^ " " ^ string_of_int n) !lines;
!s
(** A spec consists of:

@ -55,6 +55,8 @@ module Sys = struct
end
module Unix = Core.Std.Unix
module IntSet = Caml.Set.Make(Int)
module F = Format
(** List police: don't use the list module to avoid non-tail recursive
@ -80,16 +82,6 @@ let fst3 (x,_,_) = x
let snd3 (_,x,_) = x
let trd3 (_,_,x) = x
let int_of_bool b = if b then 1 else 0
(** {2 Useful Modules} *)
(** Set of integers *)
module IntSet = Set.Make(Int)
(** Maps from integers *)
module IntMap = Map.Make (Int)
(** {2 Printing} *)
(** Kind of simple printing: default or with full types *)

@ -39,6 +39,8 @@ module String = Core.Std.String
module Sys : module type of Core.Std.Sys
module Unix = Core.Std.Unix
module IntSet : Caml.Set.S with type elt = int
(** {2 Generic Utility Functions} *)
(** List police: don't use the list module to avoid non-tail recursive
@ -67,17 +69,6 @@ val snd3 : 'a * 'b * 'c -> 'b
(** Return the third component of a triple. *)
val trd3 : 'a * 'b * 'c -> 'c
(** Convert a bool into an int *)
val int_of_bool : bool -> int
(** {2 Useful Modules} *)
(** Set of integers *)
module IntSet : Set.S with type elt = int
(** Maps from integers *)
module IntMap : Map.S with type key = int
(** {2 Printing} *)
(** Colors supported in printing *)

@ -350,7 +350,7 @@ struct
{ empty_res_trans with exps = [(exp, typ)]}
let booleanValue_trans trans_state expr_info b =
characterLiteral_trans trans_state expr_info (Utils.int_of_bool b)
characterLiteral_trans trans_state expr_info (if b then 1 else 0)
let floatingLiteral_trans trans_state expr_info float_string =
let typ = CType_decl.get_type_from_expr_info expr_info trans_state.context.CContext.tenv in

@ -628,13 +628,13 @@ let get_array_length context pc expr_list content_type =
let detect_loop entry_pc impl =
let code = (JBir.code impl) in
let pc_bound = Array.length code in
let empty = IntSet.empty in
let empty = Int.Set.empty in
let rec loop visited pc =
if (IntSet.mem pc visited) || pc >= pc_bound then
if (Int.Set.mem visited pc) || pc >= pc_bound then
(false, visited)
else
begin
let visited_updated = IntSet.add pc visited in
let visited_updated = Int.Set.add visited pc in
match code.(pc) with
| JBir.Goto goto_pc when goto_pc = entry_pc -> (true, empty)
| JBir.Goto goto_pc -> loop visited_updated goto_pc

Loading…
Cancel
Save