Commit 747bc5fe authored by Andrei Paskevich's avatar Andrei Paskevich

rename Util.memo to Util.memo_int

parent eb053d42
......@@ -582,14 +582,12 @@ let ps_equ =
let f_equ t1 t2 = f_app ps_equ [t1; t2]
let f_neq t1 t2 = f_not (f_app ps_equ [t1; t2])
let fs_tuple n =
let fs_tuple = Util.memo_int 17 (fun n ->
let tyl = ref [] in
for i = 1 to n
do tyl := ty_var (create_tvsymbol (id_fresh "a")) :: !tyl done;
let ty = ty_tuple !tyl in
create_fsymbol (id_fresh ("Tuple" ^ string_of_int n)) !tyl ty
let fs_tuple = Util.memo fs_tuple
create_fsymbol (id_fresh ("Tuple" ^ string_of_int n)) !tyl ty)
let is_fs_tuple fs = fs == fs_tuple (List.length fs.ls_args)
......
......@@ -702,12 +702,10 @@ let builtin_theory =
let create_theory n = use_export (empty_theory n) builtin_theory
let tuple_theory n =
let tuple_theory = Util.memo_int 17 (fun n ->
let uc = empty_theory (id_fresh ("Tuple" ^ string_of_int n)) in
let uc = add_ty_decl uc [ts_tuple n, Talgebraic [fs_tuple n]] in
close_theory uc
let tuple_theory = Util.memo tuple_theory
close_theory uc)
(* Exception reporting *)
......
......@@ -218,15 +218,12 @@ let ts_real = create_tysymbol (id_fresh "real") [] None
let ty_int = ty_app ts_int []
let ty_real = ty_app ts_real []
let ts_tuple n =
let ts_tuple = Util.memo_int 17 (fun n ->
let vl = ref [] in
for i = 1 to n do vl := create_tvsymbol (id_fresh "a") :: !vl done;
create_tysymbol (id_fresh ("tuple" ^ string_of_int n)) !vl None
create_tysymbol (id_fresh ("tuple" ^ string_of_int n)) !vl None)
let ts_tuple = Util.memo ts_tuple
let ty_tuple tyl =
ty_app (ts_tuple (List.length tyl)) tyl
let ty_tuple tyl = ty_app (ts_tuple (List.length tyl)) tyl
let is_ts_tuple ts = ts == ts_tuple (List.length ts.ts_args)
......@@ -165,7 +165,7 @@ end
(* memoization *)
let memo ?(size=17) f =
let memo_int size f =
let h = Hashtbl.create size in
fun x -> try Hashtbl.find h x
with Not_found -> let y = f x in Hashtbl.add h x y; y
......
......@@ -84,6 +84,8 @@ module Mint : Map.S with type key = int
module Sstr : Set.S with type elt = string
module Mstr : Map.S with type key = string
val memo_int : int -> (int -> 'a) -> int -> 'a
(* Set, Map, Hashtbl on structures with a unique tag *)
module type Tagged =
......@@ -118,7 +120,3 @@ sig
module W : Hashweak.S with type key = X.t
end
(* memoization *)
val memo : ?size:int -> ('a -> 'b) -> 'a -> 'b
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment