Module Llair.Typ

Types

type t = private
  1. | Function of {
    1. return : t option;
    2. args : t NS.iarray;
    }
    (*

    (Global) function names have type Pointer to Function.

    *)
  2. | Integer of {
    1. bits : int;
    2. byts : int;
    }
    (*

    Integer of given bitwidth.

    *)
  3. | Float of {
    1. bits : int;
    2. byts : int;
    3. enc : [ `Brain | `IEEE | `Extended | `Pair ];
    }
    (*

    Floating-point numbers of given bitwidth and encoding.

    *)
  4. | Pointer of {
    1. elt : t;
    }
    (*

    Pointer to element type.

    *)
  5. | Array of {
    1. elt : t;
    2. len : int;
    3. bits : int;
    4. byts : int;
    }
    (*

    Statically-sized array of len elements of type elt.

    *)
  6. | Tuple of {
    1. elts : (int * t) NS.iarray;
    2. bits : int;
    3. byts : int;
    }
    (*

    Anonymous aggregate of heterogeneous types.

    *)
  7. | Struct of {
    1. name : string;
    2. elts : (int * t) NS.iarray;
    3. bits : int;
    4. byts : int;
    }
    (*

    Uniquely named aggregate of heterogeneous types. Elements are specified by their byte offset and their type. Every cycle of recursive types contains a Struct. NOTE: recursive Struct types are represented by cyclic values.

    *)
  8. | Opaque of {
    1. name : string;
    }
    (*

    Uniquely named aggregate type whose definition is hidden.

    *)
include Ppx_compare_lib.Comparable.S with type t := t
val compare : t Base__Ppx_compare_lib.compare
include Ppx_compare_lib.Equal.S with type t := t
val equal : t Base__Ppx_compare_lib.equal
include Sexplib0.Sexpable.S with type t := t
val t_of_sexp : Sexplib0__.Sexp.t -> t
val sexp_of_t : t -> Sexplib0__.Sexp.t
val pp : t NS.pp
val pp_defn : t NS.pp
include NS.Invariant.S with type t := t
val invariant : t -> unit

Constructors

val bool : t
val byt : t
val int : t
val siz : t
val ptr : t
val function_ : return:t option -> args:t NS.iarray -> t
val integer : bits:int -> byts:int -> t
val float : bits:int -> byts:int -> enc:[ `Brain | `Extended | `IEEE | `Pair ] -> t
val pointer : elt:t -> t
val array : elt:t -> len:int -> bits:int -> byts:int -> t
val tuple : (int * t) NS.iarray -> bits:int -> byts:int -> t
val struct_ : name:string -> bits:int -> byts:int -> (int * t) lazy_t NS.iarray -> t
val opaque : name:string -> t

Queries

val is_sized : t -> bool

Holds of types which are first-class and have a statically-known size.

val is_int : t -> bool
val bit_size_of : t -> int

The number of bits required to hold a value of the given type. Raises unless is_sized holds.

val size_of : t -> int

The number of bytes between adjacent values of the given type, including alignment padding. Raises unless is_sized holds.

val offset_length_of_elt : t -> int -> int * int

The offset in bytes to, and number of bytes occupied by, the given element of an aggretage type. Raises if type is not an aggregate or index is invalid.

val equivalent : t -> t -> bool

Equivalent types are those that denote the same sets of values in the semantic model. An equivalence relation.

val castable : t -> t -> bool

Castable types are those that can be cast between without loss of information. An equivalence relation.

val convertible : t -> t -> bool

Convertible types are those that can be converted between, perhaps with some loss of information. Not transitive: some admissible conversions must be performed in multiple steps, such as from Pointer to Integer to Array.

val compatible_fnptr : t -> t -> bool

compatible_fnptr t t' holds when (1) both t and t' are pointer types with function element type, and (2) t's function type can be applied at a call site with t''s function type, in that they have the same arity and convertible formal argument/return types.

module Tbl : NS.HashTable.S with type key = t

Mutable hash tables keyed on types