jon.recoil.org

Module Jkind.Sort

include Jkind_intf.Sort with type t = Jkind_types.Sort.t and type var = Jkind_types.Sort.var and type univar = Jkind_types.Sort.univar and type base = Jkind_types.Sort.base and type Const.t = Jkind_types.Sort.Const.t

A sort classifies how a type is represented at runtime. Every concrete jkind has a sort, and knowing the sort is sufficient for knowing the calling convention of values of a given type.

type univar : immutable_data = Jkind_types.Sort.univar = {
  1. name : string option;
}

Rigid sort variables similiar to Tunivar for types. They can be specified to be equal by enter_repr but cannot be equated/unified.

val enter_repr : (univar * univar) list -> (unit -> 'a) -> 'a

enter_repr pairs f establishes correspondence between sort univars (for Trepr) using the given list of pairs, then calls f.

type base : immediate = Jkind_types.Sort.base =
  1. | Void
    (*

    No run time representation at all

    *)
  2. | Scannable
    (*

    Standard ocaml value representation

    *)
  3. | Untagged_immediate
    (*

    Untagged 31- or 63-bit immediates, but without the tag bit, so they must never be visible to the GC

    *)
  4. | Float64
    (*

    Unboxed 64-bit floats

    *)
  5. | Float32
    (*

    Unboxed 32-bit floats

    *)
  6. | Word
    (*

    Unboxed native-size integers

    *)
  7. | Bits8
    (*

    Unboxed 8-bit integers

    *)
  8. | Bits16
    (*

    Unboxed 16-bit integers

    *)
  9. | Bits32
    (*

    Unboxed 32-bit integers

    *)
  10. | Bits64
    (*

    Unboxed 64-bit integers

    *)
  11. | Vec128
    (*

    Unboxed 128-bit simd vectors

    *)
  12. | Vec256
    (*

    Unboxed 256-bit simd vectors

    *)
  13. | Vec512
    (*

    Unboxed 512-bit simd vectors

    *)

These are the constant sorts -- fully determined and without variables

A sort variable that can be unified during type-checking.

module Const : sig ... end
module Var : sig ... end
val void : t
val scannable : t
val float64 : t
val float32 : t
val word : t
val bits32 : t
val bits64 : t
val new_var : level:int -> var

Create a new sort variable that can be unified.

val of_base : base -> t
val of_const : Const.t -> t
val of_var : var -> t
val equate : t -> t -> bool

This checks for equality, and sets any variables to make two sorts equal, if possible

val format : Format_doc.formatter -> t -> unit
val default_to_scannable_and_get : t -> Const.t

default_to_scannable_and_get extracts the sort as a `const`. If it's a variable, it is set to scannable first.

val default_for_transl_and_get : t -> Const.t

default_for_transl_and_get extracts the sort as a `const`. If it's a variable, it is set to value first. After we have support for void, this will default to void instead.

val var_default_to_scannable_and_get : var -> Const.t

Like default_to_scannable_and_get but operates directly on a var.

type change

To record changes to sorts, for use with Types.snapshot and Types.backtrack.

val undo_change : change -> unit
val new_genvar : unit -> var

Create a fresh polymorphic sort variable (level = Ident.highest_scope).

val new_genvar_for_cmi : unit -> var

Create a polymorphic sort variable (level = Ident.highest_scope), intended for saving to a cmi.

val is_genvar : var -> bool

Returns true iff the variable was created by new_genvar or new_genvar_for_cmi.

val reset_cmi_sort_id : unit -> unit
val get_representable_var : var -> t option

Get the concrete content of a variable. The returned sort must be representable (including rigid sorts).

val subst : (var * t) list -> t -> t

subst s t applies the variable substitution s to t, replacing each Var v where (v, t') is in subst with t'.

val instance_with : level:int -> var list -> (unit -> 'a) -> var list * 'a

instance_with ~level vars f creates a fresh sort var at level for each var in vars, calls f with instance configured to replace each var with its fresh copy, and returns the fresh vars together with the result of f. Raises if any var in vars is not a generic variable (see is_genvar).

val instance : t -> t

Apply instantiation to every Var node in a sort. Generic variables (see is_genvar) are replaced by fresh vars registered via instance_with; non-generic variables are left unchanged. Must be called within the dynamic extent of instance_with.

val to_string_genvar : var -> string

Returns a human-readable name for a generic variable. Must be called within the dynamic extent of print_with_genvars.

val print_with_genvars : var list -> (string list -> 'a) -> 'a

print_with_genvars vars f assigns a fresh name to each var in vars, calls f with those names, and returns the result. Within the call to f, to_string_genvar will return the assigned name for each var.

val generalize_with : (unit -> 'a) -> 'a * var list

generalize_with f runs f with sort generalization enabled (for let poly_ support). Returns the result of f and the list of sort variables lifted to generic during f.

val generalize : current_level:int -> t -> unit

Generalize sort variables when in sort generalization context. Sets the level of sort variables to Ident.highest_scope and accumulates them. This should be called from Ctype.generalize. Only has an effect when called within generalize_with.

module Debug_printers : sig ... end
module Flat : sig ... end