diff options
author | Gabriel Scherer <gabriel.scherer@gmail.com> | 2018-07-30 17:56:46 +0200 |
---|---|---|
committer | Gabriel Scherer <gabriel.scherer@gmail.com> | 2018-08-04 16:07:51 +0200 |
commit | ebc34d5115605630ead302b71d86b19a5d5b6af8 (patch) | |
tree | 364c553b5ac61ca23323c22c337f2f27e407866b /driver/optcompile.ml | |
parent | 50f3cef9a634c0d71b1c0c43d2fd7841d69d6947 (diff) | |
download | ocaml-ebc34d5115605630ead302b71d86b19a5d5b6af8.tar.gz |
compile_common: remove wrap_compilation
wrap_compilation makes the compilation pipeline non-modular by
exposing a split between two fixed passes, a frontend and a backend,
in a .mli interface. I need a finer-grained interface for a feature
I've been using in my Menhir-parser branch, and it is likely that
other users also will need to be finer-grained than that.
This PR pushes the error/ressource handling contained with
wrap_compilation into its producers (note: this change assume that
only typecheck_impl needs Stypes.dump, and that only the optcompile
backend may generate `obj` and `cmx` files), so that the logic in
"wrap" becomes very simple, and then inlines it in the two users in
{opt,}compile.ml.
Diffstat (limited to 'driver/optcompile.ml')
-rw-r--r-- | driver/optcompile.ml | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/driver/optcompile.ml b/driver/optcompile.ml index 165437767f..d399212968 100644 --- a/driver/optcompile.ml +++ b/driver/optcompile.ml @@ -77,10 +77,18 @@ let implementation ~backend ~sourcefile ~outputprefix = init ppf_dump ~init_path:true ~tool_name ~sourcefile ~outputprefix in Compilenv.reset ?packname:!Clflags.for_package info.modulename; - let frontend info = typecheck_impl info @@ parse_impl info in - let backend info typed = - if Config.flambda - then flambda info backend typed - else clambda info typed - in - wrap_compilation ~frontend ~backend info + Profile.record_call info.sourcefile @@ fun () -> + let parsed = parse_impl info in + let typed = typecheck_impl info parsed in + if not !Clflags.print_types then begin + let exceptionally () = + Misc.remove_file (Compile_common.obj info); + Misc.remove_file (Compile_common.cmx info); + in + Misc.try_finally ~exceptionally (fun () -> + if Config.flambda + then flambda info backend typed + else clambda info typed + ) + end; + Warnings.check_fatal (); |