diff options
-rw-r--r-- | toplevel/toploop.ml | 1 | ||||
-rw-r--r-- | typing/env.ml | 30 | ||||
-rw-r--r-- | typing/env.mli | 1 |
3 files changed, 25 insertions, 7 deletions
diff --git a/toplevel/toploop.ml b/toplevel/toploop.ml index cff423e7f..6a83bcc9c 100644 --- a/toplevel/toploop.ml +++ b/toplevel/toploop.ml @@ -423,6 +423,7 @@ let loop ppf = first_line := true; let phr = try !parse_toplevel_phrase lb with Exit -> raise PPerror in if !Clflags.dump_parsetree then Printast.top_phrase ppf phr; + Env.reset_missing_cmis (); ignore(execute_phrase true ppf phr) with | End_of_file -> exit 0 diff --git a/typing/env.ml b/typing/env.ml index f4dbcf516..33a19152f 100644 --- a/typing/env.ml +++ b/typing/env.ml @@ -201,7 +201,7 @@ type pers_struct = ps_flags: pers_flags list } let persistent_structures = - (Hashtbl.create 17 : (string, pers_struct) Hashtbl.t) + (Hashtbl.create 17 : (string, pers_struct option) Hashtbl.t) (* Consistency between persistent structures *) @@ -254,17 +254,29 @@ let read_pers_struct modname filename = if not !Clflags.recursive_types then raise(Error(Need_recursive_types(ps.ps_name, !current_unit)))) ps.ps_flags; - Hashtbl.add persistent_structures modname ps; + Hashtbl.add persistent_structures modname (Some ps); ps with End_of_file | Failure _ -> close_in ic; raise(Error(Corrupted_interface(filename))) let find_pers_struct name = - try - Hashtbl.find persistent_structures name - with Not_found -> - read_pers_struct name (find_in_path_uncap !load_path (name ^ ".cmi")) + if name = "*predef*" then raise Not_found; + let r = + try Some (Hashtbl.find persistent_structures name) + with Not_found -> None + in + match r with + | Some None -> raise Not_found + | Some (Some sg) -> sg + | None -> + let filename = + try find_in_path_uncap !load_path (name ^ ".cmi") + with Not_found -> + Hashtbl.add persistent_structures name None; + raise Not_found + in + read_pers_struct name filename let reset_cache () = current_unit := ""; @@ -273,6 +285,10 @@ let reset_cache () = Hashtbl.clear value_declarations; Hashtbl.clear type_declarations +let reset_missing_cmis () = + let l = Hashtbl.fold (fun name r acc -> if r = None then name :: acc else acc) persistent_structures [] in + List.iter (Hashtbl.remove persistent_structures) l + let set_unit_name name = current_unit := name @@ -1115,7 +1131,7 @@ let save_signature_with_imports sg modname filename imports = ps_crcs = crcs; ps_filename = filename; ps_flags = flags } in - Hashtbl.add persistent_structures modname ps; + Hashtbl.add persistent_structures modname (Some ps); Consistbl.set crc_units modname crc filename with exn -> close_out oc; diff --git a/typing/env.mli b/typing/env.mli index 9befc7df7..21a469d14 100644 --- a/typing/env.mli +++ b/typing/env.mli @@ -93,6 +93,7 @@ val enter_cltype: string -> cltype_declaration -> t -> Ident.t * t (* Initialize the cache of in-core module interfaces. *) val reset_cache: unit -> unit +val reset_missing_cmis: unit -> unit (* Remember the name of the current compilation unit. *) val set_unit_name: string -> unit |