jon.recoil.org

Module Ocaml_typing.ScalarSource

This module defines: The scalar types intrinsic to the OCaml compiler, and all of the primitive operations defined on them.

Overview: This module provides a comprehensive type system for scalar values in OCaml.

Type Hierarchy:

Representation Forms:

Operations:

The locality parameter tracks where boxed values are allocated.

A Scalar.t represents a particular OCaml type that represents a scalar value. It might be tagged, boxed, or neither. There is also a type parameter for the locality of the scalar value, which represents the location in which that boxed values are allocated.

The important consideration is for a Scalar.t to represent all of the argument and return types of all the primitives that we want to support. The submodules are organized to make it easy for use different subsets of scalars in different places. Some examples:

Example: Scalar.Maybe_naked.Value (Integral.Width.Taggable Int) vs Scalar.Maybe_naked.Naked (Integral.Width.Taggable Int)

In some cases, only the number of bits used in the container (e.g. a machine register or stack slot) is important. We use Width for this. Width.t always represents the width of a scalar layout -- it has exactly one constuctor for each bit-width of the corresponding scalar. The type parameter is irrelevant within the Width module, that's why it's usually fixed to any_locality_mode when the corresponding function is expecting a simple sum type (e.g., to_string).

Sourcetype any_locality_mode =
  1. | Any_locality_mode
Sourceval equal_any_locality_mode : any_locality_mode -> any_locality_mode -> bool
Sourcemodule Maybe_naked : sig ... end
Sourceval naked : 'a -> (_, 'a) Maybe_naked.t
module type S := sig ... end
Sourcemodule Integral : sig ... end
Sourcemodule Floating : sig ... end
Sourcemodule Width : sig ... end
include S with type 'a width := 'a Width.t
Sourceval all : any_locality_mode t list
Sourceval map : 'a t -> f:('a -> 'b) -> 'b t
Sourceval ignore_locality : _ t -> any_locality_mode t
Sourceval to_string : any_locality_mode t -> string
Sourceval equal : ('a -> 'b -> bool) -> 'a t -> 'b t -> bool
Sourceval integral : 'a Integral.t -> 'a t
Sourceval floating : 'a Floating.t -> 'a t
Sourcemodule Signedness : sig ... end
Sourcemodule Integer_comparison : sig ... end
Sourcemodule Float_comparison : sig ... end
type 'a scalar := 'a t
Sourcemodule Operation : sig ... end