diff options
author | Gabriel Scherer <gabriel.scherer@gmail.com> | 2019-01-04 19:03:09 +0100 |
---|---|---|
committer | Gabriel Scherer <gabriel.scherer@gmail.com> | 2019-01-05 12:12:20 +0100 |
commit | 95bdcd3856109be309d51505c1f9fcd0c58d3a2a (patch) | |
tree | 764f7425e081dc25aed7c6babf2453bf17f72727 /driver/optcompile.ml | |
parent | c6d95c9ef6b64aa3321a69a885b6d52dca377bc4 (diff) | |
download | ocaml-95bdcd3856109be309d51505c1f9fcd0c58d3a2a.tar.gz |
Compile_common: turn `init` into continuation-passing `with_info`
I think this clarifies the fact that the `info` value is a resource that
has a limited lifetime. The new API lets us create (and close) the ppf_dump
directly from `Compile_common.with_info`, simplifying the API for user.
Diffstat (limited to 'driver/optcompile.ml')
-rw-r--r-- | driver/optcompile.ml | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/driver/optcompile.ml b/driver/optcompile.ml index 9256253166..85c655e96d 100644 --- a/driver/optcompile.ml +++ b/driver/optcompile.ml @@ -20,12 +20,11 @@ open Compile_common let tool_name = "ocamlopt" -let init = - Compile_common.init ~native:true ~tool_name +let with_info = + Compile_common.with_info ~native:true ~tool_name let interface ~source_file ~output_prefix = - Compmisc.with_ppf_dump ~file_prefix:(output_prefix ^ ".cmi") @@ fun ppf_dump -> - let info = init ~ppf_dump ~source_file ~output_prefix in + with_info ~source_file ~output_prefix ~dump_ext:"cmi" @@ fun info -> Compile_common.interface info let (|>>) (x, y) f = (x, f y) @@ -78,12 +77,11 @@ let clambda i typed = Compilenv.save_unit_info (cmx i)) let implementation ~backend ~source_file ~output_prefix = - Compmisc.with_ppf_dump ~file_prefix:(output_prefix ^ ".cmx") @@ fun ppf_dump -> - let info = init ~ppf_dump ~source_file ~output_prefix in let backend info typed = Compilenv.reset ?packname:!Clflags.for_package info.module_name; if Config.flambda then flambda info backend typed else clambda info typed in + with_info ~source_file ~output_prefix ~dump_ext:"cmx" @@ fun info -> Compile_common.implementation info ~backend |