Skip to content

Commit

Permalink
relocate fake_modules to global typer
Browse files Browse the repository at this point in the history
  • Loading branch information
Simn committed Jan 25, 2024
1 parent 08f30ca commit 5571d92
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/compiler/server.ml
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ let check_module sctx ctx m_path m_extra p =
ServerMessage.unchanged_content com "" file;
end else begin
ServerMessage.not_cached com "" m_path;
if m_extra.m_kind = MFake then Hashtbl.remove Typecore.fake_modules (Path.UniqueKey.lazy_key m_extra.m_file);
if m_extra.m_kind = MFake then Hashtbl.remove ctx.g.fake_modules (Path.UniqueKey.lazy_key m_extra.m_file);
raise (Dirty (FileChanged file))
end
end
Expand Down
6 changes: 3 additions & 3 deletions src/context/typecore.ml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ type typer_globals = {
mutable return_partial_type : bool;
mutable build_count : int;
mutable t_dynamic_def : Type.t;
fake_modules : (Path.UniqueKey.t,module_def) Hashtbl.t;
(* api *)
do_macro : typer -> macro_mode -> path -> string -> expr list -> pos -> macro_result;
do_load_macro : typer -> bool -> path -> string -> pos -> ((string * bool * t) list * t * tclass * Type.tclass_field);
Expand Down Expand Up @@ -466,19 +467,18 @@ let make_lazy ?(force=true) ctx t_proc f where =
if force then delay ctx PForce (fun () -> ignore(lazy_type r));
r

let fake_modules = Hashtbl.create 0
let create_fake_module ctx file =
let key = ctx.com.file_keys#get file in
let file = Path.get_full_path file in
let mdep = (try Hashtbl.find fake_modules key with Not_found ->
let mdep = (try Hashtbl.find ctx.g.fake_modules key with Not_found ->
let mdep = {
m_id = alloc_mid();
m_path = (["$DEP"],file);
m_types = [];
m_statics = None;
m_extra = module_extra file (Define.get_signature ctx.com.defines) (file_time file) MFake ctx.com.compilation_step [];
} in
Hashtbl.add fake_modules key mdep;
Hashtbl.add ctx.g.fake_modules key mdep;
mdep
) in
ctx.com.module_lut#add mdep.m_path mdep;
Expand Down
1 change: 1 addition & 0 deletions src/typing/typerEntry.ml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ let create com macros =
build_count = 0;
t_dynamic_def = t_dynamic;
functional_interface_lut = new Lookup.pmap_lookup;
fake_modules = Hashtbl.create 0;
do_macro = MacroContext.type_macro;
do_load_macro = MacroContext.load_macro';
do_load_module = TypeloadModule.load_module;
Expand Down

0 comments on commit 5571d92

Please sign in to comment.