From bb1d6bef1969fbf23c75bdb93ece87321f35f86d Mon Sep 17 00:00:00 2001 From: Alasdair Date: Tue, 28 Nov 2023 16:48:00 +0000 Subject: [PATCH] Add empty action function to Target --- src/bin/sail.ml | 2 +- src/lib/target.ml | 2 ++ src/lib/target.mli | 4 ++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/bin/sail.ml b/src/bin/sail.ml index 58df98d2a..398a34f8a 100644 --- a/src/bin/sail.ml +++ b/src/bin/sail.ml @@ -333,7 +333,7 @@ let rec options = ("--help", Arg.Unit (fun () -> help !options), " display this list of options"); ] -let register_default_target () = Target.register ~name:"default" (fun _ _ _ _ _ _ -> ()) +let register_default_target () = Target.register ~name:"default" Target.empty_action let run_sail (config : Yojson.Basic.t option) tgt = Target.run_pre_parse_hook tgt (); diff --git a/src/lib/target.ml b/src/lib/target.ml index 1703886b4..de8e2ea7a 100644 --- a/src/lib/target.ml +++ b/src/lib/target.ml @@ -123,6 +123,8 @@ let register ~name ?flag ?description:desc ?(options = []) ?(pre_parse_hook = fu targets := StringMap.add name tgt !targets; tgt +let empty_action _ _ _ _ _ _ = () + let get_the_target () = match !the_target with Some name -> StringMap.find_opt name !targets | None -> None let get ~name = StringMap.find_opt name !targets diff --git a/src/lib/target.mli b/src/lib/target.mli index aa8bf912b..d3fc5fc7e 100644 --- a/src/lib/target.mli +++ b/src/lib/target.mli @@ -128,6 +128,10 @@ val register : (Yojson.Basic.t option -> string -> string option -> tannot ast -> Effects.side_effect_info -> Env.t -> unit) -> target +(** Use if you want to register a target that does nothing *) +val empty_action : + Yojson.Basic.t option -> string -> string option -> tannot ast -> Effects.side_effect_info -> Env.t -> unit + (** Return the current target. For example, if we register a 'coq' target, and Sail is invoked with `sail -coq`, then this function will return the coq target. *)