package / ocaml-base-compiler.4.10.0 / driver / compile_common.mli
1 (**************************************************************************)
2 (* *)
3 (* OCaml *)
4 (* *)
5 (* Gabriel Radanne *)
6 (* *)
7 (* Copyright 2018 Gabriel Radanne *)
8 (* *)
9 (* All rights reserved. This file is distributed under the terms of *)
10 (* the GNU Lesser General Public License version 2.1, with the *)
11 (* special exception on linking described in the file LICENSE. *)
12 (* *)
13 (**************************************************************************)
14
15 (** Common compilation pipeline between bytecode and native. *)
16
17 (** {2 Initialization} *)
18
19 type info = {
20 source_file : string;
21 module_name : string;
22 output_prefix : string;
23 env : Env.t;
24 ppf_dump : Format.formatter;
25 tool_name : string;
26 native : bool;
27 }
28 (** Information needed to compile a file. *)
29
30 val with_info :
31 native:bool ->
32 tool_name:string ->
33 source_file:string ->
34 output_prefix:string ->
35 dump_ext:string ->
36 (info -> 'a) -> 'a
37 (** [with_info ~native ~tool_name ~source_file ~output_prefix ~dump_ext k]
38 invokes its continuation [k] with an [info] structure built from
39 its input, after initializing various global variables. This info
40 structure and the initialized global state are not valid anymore
41 after the continuation returns.
42
43 Due to current implementation limitations in the compiler, it is
44 unsafe to try to compile several distinct compilation units by
45 calling [with_info] several times.
46 *)
47
48 (** {2 Interfaces} *)
49
50 val parse_intf : info -> Parsetree.signature
51 (** [parse_intf info] parses an interface (usually an [.mli] file). *)
52
53 val typecheck_intf : info -> Parsetree.signature -> Typedtree.signature
54 (** [typecheck_intf info parsetree] typechecks an interface and returns
55 the typedtree of the associated signature.
56 *)
57
58 val emit_signature : info -> Parsetree.signature -> Typedtree.signature -> unit
59 (** [emit_signature info parsetree typedtree] emits the [.cmi] file
60 containing the given signature.
61 *)
62
63 val interface : info -> unit
64 (** The complete compilation pipeline for interfaces. *)
65
66 (** {2 Implementations} *)
67
68 val parse_impl : info -> Parsetree.structure
69 (** [parse_impl info] parses an implementation (usually an [.ml] file). *)
70
71 val typecheck_impl :
72 info -> Parsetree.structure -> Typedtree.structure * Typedtree.module_coercion
73 (** [typecheck_impl info parsetree] typechecks an implementation and returns
74 the typedtree of the associated module, along with a coercion against
75 its public interface.
76 *)
77
78 val implementation :
79 info ->
80 backend:(info -> Typedtree.structure * Typedtree.module_coercion -> unit) ->
81 unit
82 (** The complete compilation pipeline for implementations. *)
83
84 (** {2 Build artifacts} *)
85
86 val cmo : info -> string
87 val cmx : info -> string
88 val obj : info -> string
89 val annot : info -> string
90 (** Return the filename of some compiler build artifacts associated
91 with the file being compiled.
92 *)
93