Melange_compiler_libs.Cmt_format
cmt and cmti files format.
The layout of a cmt file is as follows: <cmt> := {<cmi>} <cmt magic> {cmt infos} {<source info>} where <cmi> is the cmi file format: <cmi> := <cmi magic> <cmi info>. More precisely, the optional <cmi> part must be present if and only if the file is:
Thus, we provide a common reading function for cmi and cmt(i) files which returns an option for each of the three parts: cmi info, cmt info, source info.
type binary_annots =
| Packed(Types.signature, list(string))
| Implementation(Typedtree.structure)
| Interface(Typedtree.signature)
| Partial_implementation(array(binary_part))
| Partial_interface(array(binary_part))
;
and binary_part =
| Partial_structure(Typedtree.structure)
| Partial_structure_item(Typedtree.structure_item)
| Partial_expression(Typedtree.expression)
| Partial_pattern(Typedtree.pattern_category('k), Typedtree.general_pattern('k)) :
binary_part
| Partial_class_expr(Typedtree.class_expr)
| Partial_signature(Typedtree.signature)
| Partial_signature_item(Typedtree.signature_item)
| Partial_module_type(Typedtree.module_type)
;
type cmt_infos = {
cmt_modname: Misc.modname,
cmt_annots: binary_annots,
cmt_value_dependencies: list((Types.value_description, Types.value_description)),
cmt_comments: list((string, Location.t)),
cmt_args: array(string),
cmt_sourcefile: option(string),
cmt_builddir: string,
cmt_loadpath: Load_path.paths,
cmt_source_digest: option(string),
cmt_initial_env: Env.t,
cmt_imports: Misc.crcs,
cmt_interface_digest: option(Stdlib.Digest.t),
cmt_use_summaries: bool,
cmt_uid_to_decl: Shape.Uid.Tbl.t(Typedtree.item_declaration),
cmt_impl_shape: option(Shape.t),
cmt_ident_occurrences: list((Location.loc(Longident.t), Melange_compiler_libs__.Shape_reduce.result)),
};
exception Error(error);
let read: string => (option(Cmi_format.cmi_infos), option(cmt_infos));
read filename
opens filename, and extract both the cmi_infos, if it exists, and the cmt_infos, if it exists. Thus, it can be used with .cmi, .cmt and .cmti files.
.cmti files always contain a cmi_infos at the beginning. .cmt files only contain a cmi_infos at the beginning if there is no associated .cmti file.
let read_cmt: string => cmt_infos;
let read_cmi: string => Cmi_format.cmi_infos;
let save_cmt:
Unit_info.Artifact.t =>
binary_annots =>
Env.t =>
option(Cmi_format.cmi_infos) =>
option(Shape.t) =>
unit;
save_cmt filename modname binary_annots sourcefile initial_env cmi
writes a cmt(i) file.
let add_saved_type: binary_part => unit;
let get_saved_types: unit => list(binary_part);
let set_saved_types: list(binary_part) => unit;
let record_value_dependency:
Types.value_description =>
Types.value_description =>
unit;