You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
80 lines
2.8 KiB
80 lines
2.8 KiB
7 years ago
|
(*
|
||
6 years ago
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
||
7 years ago
|
*
|
||
|
* This source code is licensed under the MIT license found in the
|
||
|
* LICENSE file in the root directory of this source tree.
|
||
|
*)
|
||
7 years ago
|
|
||
|
(** Types *)
|
||
|
|
||
|
type t = private
|
||
|
| Function of {return: t option; args: t vector}
|
||
|
(** (Global) function names have type Pointer to Function. *)
|
||
5 years ago
|
| Integer of {bits: int; byts: int} (** Integer of given bitwidth. *)
|
||
|
| Float of {bits: int; byts: int; enc: [`IEEE | `Extended | `Pair]}
|
||
6 years ago
|
(** Floating-point numbers of given bitwidth and encoding. *)
|
||
|
| Pointer of {elt: t} (** Pointer to element type. *)
|
||
5 years ago
|
| Array of {elt: t; len: int; bits: int; byts: int}
|
||
7 years ago
|
(** Statically-sized array of [len] elements of type [elt]. *)
|
||
5 years ago
|
| Tuple of {elts: t vector; bits: int; byts: int; packed: bool}
|
||
7 years ago
|
(** Anonymous aggregate of heterogeneous types. *)
|
||
5 years ago
|
| Struct of
|
||
5 years ago
|
{name: string; elts: t vector; bits: int; byts: int; packed: bool}
|
||
7 years ago
|
(** Uniquely named aggregate of heterogeneous types. Every cycle of
|
||
|
recursive types contains a [Struct]. NOTE: recursive [Struct]
|
||
|
types are represented by cyclic values. *)
|
||
5 years ago
|
| Opaque of {name: string}
|
||
7 years ago
|
(** Uniquely named aggregate type whose definition is hidden. *)
|
||
6 years ago
|
[@@deriving compare, equal, hash, sexp]
|
||
7 years ago
|
|
||
6 years ago
|
val pp : t pp
|
||
|
val pp_defn : t pp
|
||
7 years ago
|
|
||
6 years ago
|
include Invariant.S with type t := t
|
||
7 years ago
|
|
||
|
(** Constructors *)
|
||
|
|
||
6 years ago
|
val bool : t
|
||
6 years ago
|
val byt : t
|
||
6 years ago
|
val int : t
|
||
6 years ago
|
val siz : t
|
||
6 years ago
|
val ptr : t
|
||
6 years ago
|
val function_ : return:t option -> args:t vector -> t
|
||
5 years ago
|
val integer : bits:int -> byts:int -> t
|
||
|
val float : bits:int -> byts:int -> enc:[`Extended | `IEEE | `Pair] -> t
|
||
6 years ago
|
val pointer : elt:t -> t
|
||
5 years ago
|
val array : elt:t -> len:int -> bits:int -> byts:int -> t
|
||
|
val tuple : t vector -> bits:int -> byts:int -> packed:bool -> t
|
||
7 years ago
|
|
||
5 years ago
|
val struct_ :
|
||
|
name:string -> bits:int -> byts:int -> packed:bool -> t lazy_t vector -> t
|
||
|
|
||
|
val opaque : name:string -> t
|
||
7 years ago
|
|
||
5 years ago
|
(** Queries *)
|
||
6 years ago
|
|
||
7 years ago
|
val is_sized : t -> bool
|
||
|
(** Holds of types which are first-class and have a statically-known size. *)
|
||
6 years ago
|
|
||
5 years ago
|
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. *)
|
||
|
|
||
5 years ago
|
val equivalent : t -> t -> bool
|
||
|
(** Equivalent types are those that denote the same sets of values in the
|
||
|
semantic model. An equivalence relation. *)
|
||
|
|
||
6 years ago
|
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]. *)
|