moonpool/dev/ocaml/Cmt_format/index.html
2023-08-28 17:11:38 +00:00

15 lines
No EOL
15 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Cmt_format (ocaml.Cmt_format)</title><link rel="stylesheet" href="../../_odoc-theme/odoc.css"/><meta charset="utf-8"/><meta name="generator" content="odoc 2.2.1"/><meta name="viewport" content="width=device-width,initial-scale=1.0"/><script src="../../highlight.pack.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body class="odoc"><nav class="odoc-nav"><a href="../index.html">Up</a> <a href="../index.html">ocaml</a> &#x00BB; Cmt_format</nav><header class="odoc-preamble"><h1>Module <code><span>Cmt_format</span></code></h1><p>cmt and cmti files format.</p></header><div class="odoc-content"><p>The layout of a cmt file is as follows: &lt;cmt&gt; := {&lt;cmi&gt;} &lt;cmt magic&gt; {cmt infos} {&lt;source info&gt;} where &lt;cmi&gt; is the cmi file format: &lt;cmi&gt; := &lt;cmi magic&gt; &lt;cmi info&gt;. More precisely, the optional &lt;cmi&gt; part must be present if and only if the file is:</p><ul><li>a cmti, or</li><li>a cmt, for a ml file which has no corresponding mli (hence no corresponding cmti).</li></ul><p>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.</p><div class="odoc-spec"><div class="spec type anchored" id="type-binary_annots"><a href="#type-binary_annots" class="anchor"></a><code><span><span class="keyword">type</span> binary_annots</span><span> = </span></code><ol><li id="type-binary_annots.Packed" class="def variant constructor anchored"><a href="#type-binary_annots.Packed" class="anchor"></a><code><span>| </span><span><span class="constructor">Packed</span> <span class="keyword">of</span> <a href="../Types/index.html#type-signature">Types.signature</a> * <span>string list</span></span></code></li><li id="type-binary_annots.Implementation" class="def variant constructor anchored"><a href="#type-binary_annots.Implementation" class="anchor"></a><code><span>| </span><span><span class="constructor">Implementation</span> <span class="keyword">of</span> <a href="../Typedtree/index.html#type-structure">Typedtree.structure</a></span></code></li><li id="type-binary_annots.Interface" class="def variant constructor anchored"><a href="#type-binary_annots.Interface" class="anchor"></a><code><span>| </span><span><span class="constructor">Interface</span> <span class="keyword">of</span> <a href="../Typedtree/index.html#type-signature">Typedtree.signature</a></span></code></li><li id="type-binary_annots.Partial_implementation" class="def variant constructor anchored"><a href="#type-binary_annots.Partial_implementation" class="anchor"></a><code><span>| </span><span><span class="constructor">Partial_implementation</span> <span class="keyword">of</span> <span><a href="#type-binary_part">binary_part</a> array</span></span></code></li><li id="type-binary_annots.Partial_interface" class="def variant constructor anchored"><a href="#type-binary_annots.Partial_interface" class="anchor"></a><code><span>| </span><span><span class="constructor">Partial_interface</span> <span class="keyword">of</span> <span><a href="#type-binary_part">binary_part</a> array</span></span></code></li></ol></div></div><div class="odoc-spec"><div class="spec type anchored" id="type-binary_part"><a href="#type-binary_part" class="anchor"></a><code><span><span class="keyword">and</span> binary_part</span><span> = </span></code><ol><li id="type-binary_part.Partial_structure" class="def variant constructor anchored"><a href="#type-binary_part.Partial_structure" class="anchor"></a><code><span>| </span><span><span class="constructor">Partial_structure</span> <span class="keyword">of</span> <a href="../Typedtree/index.html#type-structure">Typedtree.structure</a></span></code></li><li id="type-binary_part.Partial_structure_item" class="def variant constructor anchored"><a href="#type-binary_part.Partial_structure_item" class="anchor"></a><code><span>| </span><span><span class="constructor">Partial_structure_item</span> <span class="keyword">of</span> <a href="../Typedtree/index.html#type-structure_item">Typedtree.structure_item</a></span></code></li><li id="type-binary_part.Partial_expression" class="def variant constructor anchored"><a href="#type-binary_part.Partial_expression" class="anchor"></a><code><span>| </span><span><span class="constructor">Partial_expression</span> <span class="keyword">of</span> <a href="../Typedtree/index.html#type-expression">Typedtree.expression</a></span></code></li><li id="type-binary_part.Partial_pattern" class="def variant constructor anchored"><a href="#type-binary_part.Partial_pattern" class="anchor"></a><code><span>| </span><span><span class="constructor">Partial_pattern</span> : <span><span class="type-var">'k</span> <a href="../Typedtree/index.html#type-pattern_category">Typedtree.pattern_category</a></span>
* <span><span class="type-var">'k</span> <a href="../Typedtree/index.html#type-general_pattern">Typedtree.general_pattern</a></span> <span class="arrow">&#45;&gt;</span> <a href="#type-binary_part">binary_part</a></span></code></li><li id="type-binary_part.Partial_class_expr" class="def variant constructor anchored"><a href="#type-binary_part.Partial_class_expr" class="anchor"></a><code><span>| </span><span><span class="constructor">Partial_class_expr</span> <span class="keyword">of</span> <a href="../Typedtree/index.html#type-class_expr">Typedtree.class_expr</a></span></code></li><li id="type-binary_part.Partial_signature" class="def variant constructor anchored"><a href="#type-binary_part.Partial_signature" class="anchor"></a><code><span>| </span><span><span class="constructor">Partial_signature</span> <span class="keyword">of</span> <a href="../Typedtree/index.html#type-signature">Typedtree.signature</a></span></code></li><li id="type-binary_part.Partial_signature_item" class="def variant constructor anchored"><a href="#type-binary_part.Partial_signature_item" class="anchor"></a><code><span>| </span><span><span class="constructor">Partial_signature_item</span> <span class="keyword">of</span> <a href="../Typedtree/index.html#type-signature_item">Typedtree.signature_item</a></span></code></li><li id="type-binary_part.Partial_module_type" class="def variant constructor anchored"><a href="#type-binary_part.Partial_module_type" class="anchor"></a><code><span>| </span><span><span class="constructor">Partial_module_type</span> <span class="keyword">of</span> <a href="../Typedtree/index.html#type-module_type">Typedtree.module_type</a></span></code></li></ol></div></div><div class="odoc-spec"><div class="spec type anchored" id="type-cmt_infos"><a href="#type-cmt_infos" class="anchor"></a><code><span><span class="keyword">type</span> cmt_infos</span><span> = </span><span>{</span></code><ol><li id="type-cmt_infos.cmt_modname" class="def record field anchored"><a href="#type-cmt_infos.cmt_modname" class="anchor"></a><code><span>cmt_modname : <a href="../Misc/index.html#type-modname">Misc.modname</a>;</span></code></li><li id="type-cmt_infos.cmt_annots" class="def record field anchored"><a href="#type-cmt_infos.cmt_annots" class="anchor"></a><code><span>cmt_annots : <a href="#type-binary_annots">binary_annots</a>;</span></code></li><li id="type-cmt_infos.cmt_value_dependencies" class="def record field anchored"><a href="#type-cmt_infos.cmt_value_dependencies" class="anchor"></a><code><span>cmt_value_dependencies : <span><span>(<a href="../Types/index.html#type-value_description">Types.value_description</a> * <a href="../Types/index.html#type-value_description">Types.value_description</a>)</span>
list</span>;</span></code></li><li id="type-cmt_infos.cmt_comments" class="def record field anchored"><a href="#type-cmt_infos.cmt_comments" class="anchor"></a><code><span>cmt_comments : <span><span>(string * <a href="../Location/index.html#type-t">Location.t</a>)</span> list</span>;</span></code></li><li id="type-cmt_infos.cmt_args" class="def record field anchored"><a href="#type-cmt_infos.cmt_args" class="anchor"></a><code><span>cmt_args : <span>string array</span>;</span></code></li><li id="type-cmt_infos.cmt_sourcefile" class="def record field anchored"><a href="#type-cmt_infos.cmt_sourcefile" class="anchor"></a><code><span>cmt_sourcefile : <span>string option</span>;</span></code></li><li id="type-cmt_infos.cmt_builddir" class="def record field anchored"><a href="#type-cmt_infos.cmt_builddir" class="anchor"></a><code><span>cmt_builddir : string;</span></code></li><li id="type-cmt_infos.cmt_loadpath" class="def record field anchored"><a href="#type-cmt_infos.cmt_loadpath" class="anchor"></a><code><span>cmt_loadpath : <span>string list</span>;</span></code></li><li id="type-cmt_infos.cmt_source_digest" class="def record field anchored"><a href="#type-cmt_infos.cmt_source_digest" class="anchor"></a><code><span>cmt_source_digest : <span>string option</span>;</span></code></li><li id="type-cmt_infos.cmt_initial_env" class="def record field anchored"><a href="#type-cmt_infos.cmt_initial_env" class="anchor"></a><code><span>cmt_initial_env : <a href="../Env/index.html#type-t">Env.t</a>;</span></code></li><li id="type-cmt_infos.cmt_imports" class="def record field anchored"><a href="#type-cmt_infos.cmt_imports" class="anchor"></a><code><span>cmt_imports : <a href="../Misc/index.html#type-crcs">Misc.crcs</a>;</span></code></li><li id="type-cmt_infos.cmt_interface_digest" class="def record field anchored"><a href="#type-cmt_infos.cmt_interface_digest" class="anchor"></a><code><span>cmt_interface_digest : <span><a href="../Stdlib/Digest/index.html#type-t">Stdlib.Digest.t</a> option</span>;</span></code></li><li id="type-cmt_infos.cmt_use_summaries" class="def record field anchored"><a href="#type-cmt_infos.cmt_use_summaries" class="anchor"></a><code><span>cmt_use_summaries : bool;</span></code></li><li id="type-cmt_infos.cmt_uid_to_loc" class="def record field anchored"><a href="#type-cmt_infos.cmt_uid_to_loc" class="anchor"></a><code><span>cmt_uid_to_loc : <span><a href="../Location/index.html#type-t">Location.t</a> <a href="../Shape/Uid/Tbl/index.html#type-t">Shape.Uid.Tbl.t</a></span>;</span></code></li><li id="type-cmt_infos.cmt_impl_shape" class="def record field anchored"><a href="#type-cmt_infos.cmt_impl_shape" class="anchor"></a><code><span>cmt_impl_shape : <span><a href="../Shape/index.html#type-t">Shape.t</a> option</span>;</span></code></li></ol><code><span>}</span></code></div></div><div class="odoc-spec"><div class="spec type anchored" id="type-error"><a href="#type-error" class="anchor"></a><code><span><span class="keyword">type</span> error</span><span> = </span></code><ol><li id="type-error.Not_a_typedtree" class="def variant constructor anchored"><a href="#type-error.Not_a_typedtree" class="anchor"></a><code><span>| </span><span><span class="constructor">Not_a_typedtree</span> <span class="keyword">of</span> string</span></code></li></ol></div></div><div class="odoc-spec"><div class="spec exception anchored" id="exception-Error"><a href="#exception-Error" class="anchor"></a><code><span><span class="keyword">exception</span> </span><span><span class="exception">Error</span> <span class="keyword">of</span> <a href="#type-error">error</a></span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-read"><a href="#val-read" class="anchor"></a><code><span><span class="keyword">val</span> read : <span>string <span class="arrow">&#45;&gt;</span></span> <span><a href="../Cmi_format/index.html#type-cmi_infos">Cmi_format.cmi_infos</a> option</span> * <span><a href="#type-cmt_infos">cmt_infos</a> option</span></span></code></div><div class="spec-doc"><p><code>read filename</code> 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.</p><p>.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.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-read_cmt"><a href="#val-read_cmt" class="anchor"></a><code><span><span class="keyword">val</span> read_cmt : <span>string <span class="arrow">&#45;&gt;</span></span> <a href="#type-cmt_infos">cmt_infos</a></span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-read_cmi"><a href="#val-read_cmi" class="anchor"></a><code><span><span class="keyword">val</span> read_cmi : <span>string <span class="arrow">&#45;&gt;</span></span> <a href="../Cmi_format/index.html#type-cmi_infos">Cmi_format.cmi_infos</a></span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-save_cmt"><a href="#val-save_cmt" class="anchor"></a><code><span><span class="keyword">val</span> save_cmt :
<span>string <span class="arrow">&#45;&gt;</span></span>
<span>string <span class="arrow">&#45;&gt;</span></span>
<span><a href="#type-binary_annots">binary_annots</a> <span class="arrow">&#45;&gt;</span></span>
<span><span>string option</span> <span class="arrow">&#45;&gt;</span></span>
<span><a href="../Env/index.html#type-t">Env.t</a> <span class="arrow">&#45;&gt;</span></span>
<span><span><a href="../Cmi_format/index.html#type-cmi_infos">Cmi_format.cmi_infos</a> option</span> <span class="arrow">&#45;&gt;</span></span>
<span><span><a href="../Shape/index.html#type-t">Shape.t</a> option</span> <span class="arrow">&#45;&gt;</span></span>
unit</span></code></div><div class="spec-doc"><p><code>save_cmt filename modname binary_annots sourcefile initial_env cmi</code> writes a cmt(i) file.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-read_magic_number"><a href="#val-read_magic_number" class="anchor"></a><code><span><span class="keyword">val</span> read_magic_number : <span><a href="../Stdlib/index.html#type-in_channel">in_channel</a> <span class="arrow">&#45;&gt;</span></span> string</span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-clear"><a href="#val-clear" class="anchor"></a><code><span><span class="keyword">val</span> clear : <span>unit <span class="arrow">&#45;&gt;</span></span> unit</span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-add_saved_type"><a href="#val-add_saved_type" class="anchor"></a><code><span><span class="keyword">val</span> add_saved_type : <span><a href="#type-binary_part">binary_part</a> <span class="arrow">&#45;&gt;</span></span> unit</span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-get_saved_types"><a href="#val-get_saved_types" class="anchor"></a><code><span><span class="keyword">val</span> get_saved_types : <span>unit <span class="arrow">&#45;&gt;</span></span> <span><a href="#type-binary_part">binary_part</a> list</span></span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-set_saved_types"><a href="#val-set_saved_types" class="anchor"></a><code><span><span class="keyword">val</span> set_saved_types : <span><span><a href="#type-binary_part">binary_part</a> list</span> <span class="arrow">&#45;&gt;</span></span> unit</span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-record_value_dependency"><a href="#val-record_value_dependency" class="anchor"></a><code><span><span class="keyword">val</span> record_value_dependency :
<span><a href="../Types/index.html#type-value_description">Types.value_description</a> <span class="arrow">&#45;&gt;</span></span>
<span><a href="../Types/index.html#type-value_description">Types.value_description</a> <span class="arrow">&#45;&gt;</span></span>
unit</span></code></div></div></div></body></html>