Module Ocaml_typing.Vicuna_value_shapes

This file defines a representation of the runtime shapes of OCaml values. These shapes are different from (and unrelated to) the shapes defined in typing/shape.mli.

type value_shape =
  1. | Value
    (*

    anything of C type value

    *)
  2. | Imm
    (*

    immediate, tagged with a one at the end

    *)
  3. | Nativeint
    (*

    block of a native word integer, e.g., 64-bit integer on amd64 target

    *)
  4. | Double
    (*

    block of a native double

    *)
  5. | Int64
    (*

    block of a 64-bit integer

    *)
  6. | Int32
    (*

    block of a 32-bit integer

    *)
  7. | String
    (*

    block of a char pointer with a size, representing both Bytes.t and String.t

    *)
  8. | FloatArray
    (*

    block containing native doubles

    *)
  9. | Block of (int * value_shape list) option
    (*

    Block whose tag is below no-scan tag (i.e., a normal ocaml block value). If the argment is None, then the block could have any tag and any elements. If the argument is Some (t, shs), then t is the tag of the block and shs contains the shapes of its fields. In the case of Some (t, shs), the number of fields is known statically (i.e., the length of the list shs).

    To represent arrays (which are blocks with tag 0 at run time, but whose size is not statically known), there is a separate construtor, Array sh, which keeps track of the shapes of the elements.

    *)
  10. | Array of value_shape
    (*

    Block with tag 0 and a fixed size (not known statically). The shape of the elements is given by the argument.

    *)
  11. | Closure
    (*

    Block with closure tag.

    *)
  12. | Obj
    (*

    Block with object tag.

    *)
  13. | Or of value_shape * value_shape
    (*

    Disjunction between two shapes for, e.g., variant types.

    *)
type fn_value_shapes = {
  1. arguments : value_shape list;
  2. return : value_shape;
}
type extfun_desc = {
  1. shape : fn_value_shapes option;
    (*

    If the shape is not present, then we fallback on the arity of the C code.

    *)
}

An extfun_desc describes the information that we know about an external function. To enable extensions in the future, we define it as a record of options. This enables adding new, optional fields in the future without breaking the serialized form.

type extfun = {
  1. name : string;
    (*

    C name of the function

    *)
  2. desc : extfun_desc;
}
type extfuns = {
  1. version : string;
  2. extfuns : extfun list;
}
val print_extfuns : Format.formatter -> extfuns -> unit
val print_extfuns_readable : Format.formatter -> extfuns -> unit