jon.recoil.org

Module Compile_common

Common compilation pipeline between bytecode and native.

Initialization

type opt_backend =
  1. | Native
  2. | Js_of_ocaml
type backend =
  1. | Byte
  2. | Opt of Compile_common.opt_backend
type info = {
  1. target : Unit_info.t;
  2. module_name : Compilation_unit.t;
  3. env : Env.t;
  4. ppf_dump : Stdlib.Format.formatter;
  5. tool_name : string;
  6. backend : Compile_common.backend;
}

Information needed to compile a file.

type compilation_unit_or_inferred =
  1. | Exactly of Compilation_unit.t
  2. | Inferred_from_output_prefix
val with_info : backend:Compile_common.backend -> tool_name:string -> source_file:string -> output_prefix:string -> compilation_unit:Compile_common.compilation_unit_or_inferred -> kind:Unit_info.intf_or_impl -> dump_ext:string -> (Compile_common.info -> 'a) -> 'a

with_info ~native ~tool_name ~source_file ~output_prefix ~dump_ext k invokes its continuation k with an info structure built from its input, after initializing various global variables. This info structure and the initialized global state are not valid anymore after the continuation returns.

Due to current implementation limitations in the compiler, it is unsafe to try to compile several distinct compilation units by calling with_info several times.

module Parse_result : sig ... end

Interfaces

parse_intf info parses an interface (usually an .mli file).

typecheck_intf info parsetree typechecks an interface and returns the typedtree of the associated signature.

val emit_signature : Compile_common.info -> Misc.alerts -> Typedtree.signature -> unit

emit_signature info parsetree typedtree emits the .cmi file containing the given signature.

val interface : hook_parse_tree:(Parsetree.signature -> unit) -> hook_typed_tree:(Typedtree.signature -> unit) -> Compile_common.info -> unit

The complete compilation pipeline for interfaces.

Implementations

parse_impl info parses an implementation (usually an .ml file).

typecheck_impl info parsetree typechecks an implementation and returns the typedtree of the associated module, its public interface, and a coercion against that public interface.

val implementation : hook_parse_tree:(Parsetree.structure -> unit) -> hook_typed_tree:(Typedtree.implementation -> unit) -> Compile_common.info -> backend:(Compile_common.info -> Typedtree.implementation -> unit) -> unit

The complete compilation pipeline for implementations.