Skip to content

Commit

Permalink
Process the -parameter flag
Browse files Browse the repository at this point in the history
  • Loading branch information
lukemaurer committed Jan 29, 2025
1 parent 0514f08 commit 0df6396
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/kernel/mconfig.ml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ let dump_ocaml x =
("pp", Json.option (dump_with_workdir Json.string) x.pp);
("warnings", dump_warnings x.warnings);
("cmi_file", Json.option Json.string x.cmi_file);
("parameters", `List (List.map ~f:Json.string x.parameters));
("as_parameter", `Bool x.as_parameter);
( "zero_alloc_check",
`String (Zero_alloc_annotations.to_string x.zero_alloc_check) )
Expand Down
7 changes: 6 additions & 1 deletion src/kernel/mocaml.ml
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,16 @@ let setup_reader_config config =
as_parameter := ocaml.as_parameter;
zero_alloc_check := ocaml.zero_alloc_check

let init_params params =
List.iter params ~f:(fun s ->
Env.register_parameter (s |> Global_module.Name.create_no_args))

let setup_typer_config config =
setup_reader_config config;
let visible = Mconfig.build_path config in
let hidden = Mconfig.hidden_build_path config in
Load_path.(init ~auto_include:no_auto_include ~visible ~hidden)
Load_path.(init ~auto_include:no_auto_include ~visible ~hidden);
init_params config.ocaml.parameters

(** Switchable implementation of Oprint *)

Expand Down
5 changes: 4 additions & 1 deletion src/kernel/mtyper.ml
Original file line number Diff line number Diff line change
Expand Up @@ -289,10 +289,13 @@ let run config parsetree =
(* Resetting the local store will clear the load_path cache.
Save it now, reset the store and then restore the path. *)
let { Load_path.visible; hidden } = Load_path.get_paths () in
(* Same story with the registered parameters. *)
let parameters = Env.parameters () in
Mocaml.flush_caches ();
Local_store.reset ();
Load_path.reset ();
Load_path.(init ~auto_include:no_auto_include ~visible ~hidden));
Load_path.(init ~auto_include:no_auto_include ~visible ~hidden);
List.iter ~f:Env.register_parameter parameters);
let caught = ref [] in
Msupport.catch_errors Mconfig.(config.ocaml.warnings) caught @@ fun () ->
Typecore.reset_delayed_checks ();
Expand Down

0 comments on commit 0df6396

Please sign in to comment.