summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/c_backend.ml6
-rw-r--r--src/c_backend.mli2
-rw-r--r--src/sail.ml8
-rw-r--r--src/specialize.mli2
4 files changed, 11 insertions, 7 deletions
diff --git a/src/c_backend.ml b/src/c_backend.ml
index 47e84446..05b09b65 100644
--- a/src/c_backend.ml
+++ b/src/c_backend.ml
@@ -3499,7 +3499,7 @@ let smt_trace ctx =
| cdef -> cdef
-let compile_ast ctx c_includes (Defs defs) =
+let compile_ast ctx output_chan c_includes (Defs defs) =
try
c_debug (lazy (Util.log_line __MODULE__ __LINE__ "Identifying recursive functions"));
let recursive_functions = Spec_analysis.top_sort_defs (Defs defs) |> get_recursive_functions in
@@ -3622,7 +3622,7 @@ let compile_ast ctx c_includes (Defs defs) =
^^ model_init ^^ hlhl
^^ model_fini ^^ hlhl
^^ model_default_main ^^ hlhl
- ^^ model_main)
- |> print_endline
+ ^^ model_main ^^ hardline)
+ |> output_string output_chan
with
Type_error (_, l, err) -> c_error ("Unexpected type error when compiling to C:\n" ^ Type_error.string_of_type_error err)
diff --git a/src/c_backend.mli b/src/c_backend.mli
index 10bf9f40..a11ac7f5 100644
--- a/src/c_backend.mli
+++ b/src/c_backend.mli
@@ -89,7 +89,7 @@ val initial_ctx : Env.t -> ctx
val compile_aexp : ctx -> Ast.typ Anf.aexp -> instr list * (clexp -> instr) * instr list
-val compile_ast : ctx -> string list -> tannot Ast.defs -> unit
+val compile_ast : ctx -> out_channel -> string list -> tannot Ast.defs -> unit
val bytecode_ast : ctx -> (cdef list -> cdef list) -> tannot Ast.defs -> cdef list
diff --git a/src/sail.ml b/src/sail.ml
index 344152a2..49abd3bd 100644
--- a/src/sail.ml
+++ b/src/sail.ml
@@ -407,9 +407,11 @@ let main() =
then
let ast_c = rewrite_ast_c type_envs ast in
let ast_c, type_envs = Specialize.(specialize typ_ord_specialization ast_c type_envs) in
- (* let ast_c, type_envs = Specialize.(specialize' 2 int_specialization ast_c type_envs) in *)
+ (* let ast_c, type_envs = Specialize.(specialize' 2 int_specialization_with_externs ast_c type_envs) in *)
+ let output_chan = match !opt_file_out with Some f -> open_out (f ^ ".c") | None -> stdout in
Util.opt_warnings := true;
- C_backend.compile_ast (C_backend.initial_ctx type_envs) (!opt_includes_c) ast_c
+ C_backend.compile_ast (C_backend.initial_ctx type_envs) output_chan (!opt_includes_c) ast_c;
+ close_out output_chan
else ());
(if !(opt_print_cgen)
then Cgen_backend.output type_envs ast
@@ -435,7 +437,7 @@ let main() =
begin
try
if not (Sys.is_directory latex_dir) then begin
- prerr_endline ("Failure: latex output directory exists but is not a directory: " ^ latex_dir);
+ prerr_endline ("Failure: latex output location exists and is not a directory: " ^ latex_dir);
exit 1
end
with Sys_error(_) -> Unix.mkdir latex_dir 0o755
diff --git a/src/specialize.mli b/src/specialize.mli
index b6299558..6ec8c2aa 100644
--- a/src/specialize.mli
+++ b/src/specialize.mli
@@ -79,6 +79,8 @@ val polymorphic_functions : specialization -> 'a defs -> IdSet.t
which case specialize returns the AST unmodified. *)
val specialize : specialization -> tannot defs -> Env.t -> tannot defs * Env.t
+(** specialize' n performs at most n specialization passes. Useful for
+ int_specialization which is not guaranteed to terminate. *)
val specialize' : int -> specialization -> tannot defs -> Env.t -> tannot defs * Env.t
(** return all instantiations of a function id, with the