1 (**************************************************************************)
2 (* *)
3 (* OCaml *)
4 (* *)
5 (* Xavier Leroy, projet Gallium, INRIA Rocquencourt *)
6 (* Pierre Chambart, OCamlPro *)
7 (* Mark Shinwell and Leo White, Jane Street Europe *)
8 (* *)
9 (* Copyright 2010 Institut National de Recherche en Informatique et *)
10 (* en Automatique *)
11 (* Copyright 2013--2016 OCamlPro SAS *)
12 (* Copyright 2014--2016 Jane Street Group LLC *)
13 (* *)
14 (* All rights reserved. This file is distributed under the terms of *)
15 (* the GNU Lesser General Public License version 2.1, with the *)
16 (* special exception on linking described in the file LICENSE. *)
17 (* *)
18 (**************************************************************************)
19
20 (* Compilation environments for compilation units *)
21
22 open Cmx_format
23
24 (* CR-soon mshinwell: this is a bit ugly
25 mshinwell: deferred CR, this has been addressed in the export info
26 improvement feature.
27 *)
28 val imported_sets_of_closures_table
29 : Simple_value_approx.function_declarations option Set_of_closures_id.Tbl.t
30 (* flambda-only *)
31
32 val reset: ?packname:string -> string -> unit
33 (* Reset the environment and record the name of the unit being
34 compiled (arg). Optional argument is [-for-pack] prefix. *)
35
36 val unit_id_from_name: string -> Ident.t
37 (* flambda-only *)
38
39 val current_unit_infos: unit -> unit_infos
40 (* Return the infos for the unit being compiled *)
41
42 val current_unit_name: unit -> string
43 (* Return the name of the unit being compiled
44 clambda-only *)
45
46 val current_unit_linkage_name: unit -> Linkage_name.t
47 (* Return the linkage_name of the unit being compiled.
48 flambda-only *)
49
50 val current_unit: unit -> Compilation_unit.t
51 (* flambda-only *)
52
53 val current_unit_symbol: unit -> Symbol.t
54 (* flambda-only *)
55
56 val make_symbol: ?unitname:string -> string option -> string
57 (* [make_symbol ~unitname:u None] returns the asm symbol that
58 corresponds to the compilation unit [u] (default: the current unit).
59 [make_symbol ~unitname:u (Some id)] returns the asm symbol that
60 corresponds to symbol [id] in the compilation unit [u]
61 (or the current unit). *)
62
63 val symbol_in_current_unit: string -> bool
64 (* Return true if the given asm symbol belongs to the
65 current compilation unit, false otherwise. *)
66
67 val is_predefined_exception: Symbol.t -> bool
68 (* flambda-only *)
69
70 val unit_for_global: Ident.t -> Compilation_unit.t
71 (* flambda-only *)
72
73 val symbol_for_global: Ident.t -> string
74 (* Return the asm symbol that refers to the given global identifier
75 flambda-only *)
76 val symbol_for_global': Ident.t -> Symbol.t
77 (* flambda-only *)
78 val global_approx: Ident.t -> Clambda.value_approximation
79 (* Return the approximation for the given global identifier
80 clambda-only *)
81 val set_global_approx: Clambda.value_approximation -> unit
82 (* Record the approximation of the unit being compiled
83 clambda-only *)
84 val record_global_approx_toplevel: unit -> unit
85 (* Record the current approximation for the current toplevel phrase
86 clambda-only *)
87
88 val set_export_info: Export_info.t -> unit
89 (* Record the information of the unit being compiled
90 flambda-only *)
91 val approx_env: unit -> Export_info.t
92 (* Returns all the information loaded from external compilation units
93 flambda-only *)
94 val approx_for_global: Compilation_unit.t -> Export_info.t option
95 (* Loads the exported information declaring the compilation_unit
96 flambda-only *)
97
98 val need_curry_fun: int -> unit
99 val need_apply_fun: int -> unit
100 val need_send_fun: int -> unit
101 (* Record the need of a currying (resp. application,
102 message sending) function with the given arity *)
103
104 val new_const_symbol : unit -> string
105 val closure_symbol : Closure_id.t -> Symbol.t
106 (* Symbol of a function if the function is
107 closed (statically allocated)
108 flambda-only *)
109 val function_label : Closure_id.t -> string
110 (* linkage name of the code of a function
111 flambda-only *)
112
113 val new_structured_constant:
114 Clambda.ustructured_constant ->
115 shared:bool -> (* can be shared with another structurally equal constant *)
116 string
117 val structured_constants:
118 unit -> Clambda.preallocated_constant list
119 val clear_structured_constants: unit -> unit
120
121 val structured_constant_of_symbol:
122 string -> Clambda.ustructured_constant option
123
124 val add_exported_constant: string -> unit
125 (* clambda-only *)
126 type structured_constants
127 (* clambda-only *)
128 val snapshot: unit -> structured_constants
129 (* clambda-only *)
130 val backtrack: structured_constants -> unit
131 (* clambda-only *)
132
133 val read_unit_info: string -> unit_infos * Digest.t
134 (* Read infos and MD5 from a [.cmx] file. *)
135 val write_unit_info: unit_infos -> string -> unit
136 (* Save the given infos in the given file *)
137 val save_unit_info: string -> unit
138 (* Save the infos for the current unit in the given file *)
139 val cache_unit_info: unit_infos -> unit
140 (* Enter the given infos in the cache. The infos will be
141 honored by [symbol_for_global] and [global_approx]
142 without looking at the corresponding .cmx file. *)
143
144 val require_global: Ident.t -> unit
145 (* Enforce a link dependency of the current compilation
146 unit to the required module *)
147
148 val read_library_info: string -> library_infos
149
150 type error =
151 Not_a_unit_info of string
152 | Corrupted_unit_info of string
153 | Illegal_renaming of string * string * string
154
155 exception Error of error
156
157 val report_error: Format.formatter -> error -> unit
158