Module Runtime_shape
module Sort = Jkind_types.Sortmodule Or_void : sig ... endmodule Runtime_layout : sig ... endRuntime shapes describe the runtime representation of OxCaml values.
While a regular Shape.t can describe both types and module expressions, runtime shapes are specifically concerned with how values are represented at runtime. Every runtime shape has a Runtime_layout.t that describes its physical representation (e.g., boxed value, unboxed float, SIMD vector), but runtime shapes carry additional structural information beyond the layout:
- For tuples and records: the types of each field
- For variants: the constructors and their argument types
- For recursive types: the recursive definition
- For predefined types: specific information like array element types
This structural information is used during DWARF debug information generation to produce accurate type descriptions that debuggers can use to inspect values at runtime.
and desc = private | Unknown of Runtime_layout.t| Predef of predef| Tuple of {args : t list;kind : tuple_kind;
}| Variant of {constructors : constructors;kind : variant_kind;
}| Record of {fields : string mixed_block_field list;kind : record_kind;
}| Func| Mu of t| Rec_var of Shape.DeBruijn_index.t * Runtime_layout.t
and variant_kind = private | Variant_boxed| Variant_attribute_unboxed of Runtime_layout.t| Variant_polymorphic
and constructor = private | Constructor_with_tuple_arg of {name : string;args : unit mixed_block_field list;
}| Constructor_with_record_arg of {name : string;args : string mixed_block_field list;
}
and constructors = constructor listand predef = | Array of array_kind| Bytes| Char| Extension_constructor| Float| Float32| Floatarray| Int| Int8| Int16| Int32| Int64| Lazy_t of t| Nativeint| String| Simd of simd_vec_split| Exception| Unboxed of unboxed
and unboxed = | Unboxed_float| Unboxed_float32| Unboxed_nativeint| Unboxed_int64| Unboxed_int32| Unboxed_int16| Unboxed_int8| Unboxed_simd of simd_vec_split
val runtime_layout_of_unboxed : unboxed -> Runtime_layout.tGet the runtime layout of a built-in unboxed type.
val simd_vec_split_to_byte_size : simd_vec_split -> intGet the byte size of a SIMD vector type.
val mixed_block_field :
field_type:t ->
label:'label ->
'label mixed_block_fieldCreate a mixed block field with the given type and label.
val map_mixed_block_field_label :
('a -> 'b) ->
'a mixed_block_field ->
'b mixed_block_fieldTransform the label of a mixed block field.
val constructor_with_tuple_arg :
name:string ->
args:unit mixed_block_field list ->
constructorCreate a constructor with tuple-style arguments for use in variants.
Note that in args, the order matters for the runtime memory layout. Ensure fields are in the correct order (i.e., values occur before non-values).
val constructor_with_record_arg :
name:string ->
args:string mixed_block_field list ->
constructorCreate a constructor with record-style arguments for use in variants.
Note that in args, the order matters for the runtime memory layout. Ensure fields are in the correct order (i.e., values occur before non-values).
val constructor_name : constructor -> stringGet the name of a constructor.
val constructor_args : constructor -> string option mixed_block_field listGet the arguments of a constructor as a list of fields with optional labels. Tuple-style constructors have None labels, record-style constructors have Some name labels.
val unknown : Runtime_layout.t -> tCreate an unknown shape with the given runtime layout. Used when more precise type information is unavailable.
val variant : constructors -> tCreate a boxed variant shape from a list of constructors.
val polymorphic_variant : constructors -> tCreate a polymorphic variant shape from a list of constructors.
val variant_attribute_unboxed :
constructor_name:string ->
constructor_arg:string option mixed_block_field ->
tAttribute-unboxed variant. Argument must have been flattened beforehand. See type_shape_to_complex_shape.
val record_attribute_unboxed : contents:string mixed_block_field -> tAttribute-unboxed record. Argument must have been flattened beforehand. See type_shape_to_complex_shape.
val record_mixed : string mixed_block_field list -> tMixed record with value layout. Fields must have been unarized beforehand.
val func : tThe shape of a function value (always has Value layout).
Create a recursive type shape. The argument is the body of the recursive type, which may reference rec_var to refer back to the recursive binding.
val rec_var : Shape.DeBruijn_index.t -> Runtime_layout.t -> tCreate a reference to a recursive binding using de Bruijn indexing.
val runtime_layout : t -> Runtime_layout.tProject the runtime layout of a shape.
val print : Format.formatter -> t -> unitval hash : t -> int