summaryrefslogtreecommitdiff
path: root/src/sail.ml
diff options
context:
space:
mode:
authorAlasdair Armstrong2019-08-01 14:42:56 +0100
committerAlasdair Armstrong2019-08-01 14:42:56 +0100
commit8f9aa39623699f5b50f7abf6dc3c124062542b7e (patch)
tree6e4b270a1df779f3ce9118f1d4f69230176cd587 /src/sail.ml
parent019c5a18384c3800de3435e637cfee7cbc8fd551 (diff)
parenta170279fb7e48e9981bd5eef015466ba202987ce (diff)
Merge branch 'sail2' into separate_bv
Diffstat (limited to 'src/sail.ml')
-rw-r--r--src/sail.ml17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/sail.ml b/src/sail.ml
index e9b1914d..516b3726 100644
--- a/src/sail.ml
+++ b/src/sail.ml
@@ -70,6 +70,7 @@ let opt_file_arguments = ref ([]:string list)
let opt_process_elf : string option ref = ref None
let opt_ocaml_generators = ref ([]:string list)
let opt_splice = ref ([]:string list)
+let opt_have_feature = ref None
let set_target name = Arg.Unit (fun _ -> opt_target := Some name)
@@ -276,6 +277,9 @@ let options = Arg.align ([
( "-memo",
Arg.Tuple [Arg.Set opt_memo_z3; Arg.Set C_backend.opt_memo_cache],
" memoize calls to z3, and intermediate compilation results");
+ ( "-have_feature",
+ Arg.String (fun symbol -> opt_have_feature := Some symbol),
+ " check if a feature symbol is set by default");
( "-splice",
Arg.String (fun s -> opt_splice := s :: !opt_splice),
"<filename> add functions from file, replacing existing definitions where necessary");
@@ -410,6 +414,9 @@ let load_files ?check:(check=false) type_envs files =
else
let ast = Scattered.descatter ast in
let ast, type_envs = rewrite_ast_initial type_envs ast in
+ (* Recheck after descattering so that the internal type environments always
+ have complete variant types *)
+ let ast, type_envs = Type_error.check Type_check.initial_env ast in
let out_name = match !opt_file_out with
| None when parsed = [] -> "out.sail"
@@ -545,7 +552,17 @@ let target name out_name ast type_envs =
| Some t ->
raise (Reporting.err_unreachable Parse_ast.Unknown __POS__ ("Undefined target: " ^ t))
+let feature_check () =
+ match !opt_have_feature with
+ | None -> ()
+ | Some symbol ->
+ if Process_file.have_symbol symbol then
+ exit 0
+ else
+ exit 2
+
let main () =
+ feature_check ();
if !opt_print_version then
print_endline version
else