Module Hardcaml_kernel.ConstantSource

Representation of variable width Constants and conversion to/from OCaml types.

include Ppx_compare_lib.Comparable.S with type t := t
Sourceval compare : t -> t -> int
include Ppx_compare_lib.Comparable.S__local with type t := t
include Ppx_compare_lib.Equal.S with type t := t
Sourceval equal : t -> t -> bool
include Ppx_compare_lib.Equal.S__local with type t := t
include Sexplib0.Sexpable.S with type t := t
include Sexplib0.Sexpable.Of_sexp with type t := t
Sourceval t_of_sexp : Sexplib0.Sexp.t -> t
include Sexplib0.Sexpable.Sexp_of with type t := t
Sourceval sexp_of_t : t -> Sexplib0.Sexp.t
include Bin_prot.Binable.S with type t := t
include Bin_prot.Binable.S_only_functions with type t := t
include sig ... end
Sourceval bin_size_t : t Bin_prot.Size.sizer
Sourceval bin_write_t : t Bin_prot.Write.writer
Sourceval bin_read_t : t Bin_prot.Read.reader
Sourceval __bin_read_t__ : t Bin_prot.Read.vtag_reader

This function only needs implementation if t exposed to be a polymorphic variant. Despite what the type reads, this does *not* produce a function after reading; instead it takes the constructor tag (int) before reading and reads the rest of the variant t afterwards.

Sourceval bin_shape_t : Bin_prot.Shape.t
Sourceval empty : t
Sourceval create : int -> t

create n create a n bit constant, initialized to hold all 0s.

Sourceval width : t -> int

Bit width of constant

Sourceval to_binary_string : t -> string

Convert a constant to a string of '1' and '0' chars.

Sourceval to_binary_string_hum : t -> string

Same as to_binary_string but adds '_'s every chars

Sourceval to_int : t -> int

Convert constant to an int. Bits above Int.num_bits are dropped.

Sourceval to_int32 : t -> int32

Convert constant to an int32. Bits above Int32.num_bits are dropped.

Sourceval to_int64 : t -> int64

Convert constant to an int64. Bits above Int64.num_bits are dropped.

Sourceval to_int64_array : t -> int64 array

Convert to array of int64s

Sourceval to_bigint : signedness:Signedness.t -> t -> Bigint.t

Convert to an arbitrary precision integer.

Sourceval to_hex_string : ?capitalize:bool -> signedness:Signedness.t -> t -> string

Convert to a hex encoded string.

Sourceval of_binary_string : string -> t

Convert a string containing '1' and '0' characters to a constant. Width is inferred from the strings length.

Sourceval of_binary_string_hum : string -> t

Same as of_binary_string but allow '_' chars

Sourceval of_int : width:int -> int -> t

Create a constant from the given int value.

Sourceval of_int32 : width:int -> int32 -> t

Create a constant from the given int32 value

Sourceval of_int64 : width:int -> int64 -> t

Create a constant from the given int64 value

Sourceval of_int64_array : width:int -> int64 array -> t

Create from an array of int64s

Sourceval of_bigint_trunc : width:int -> Bigint.t -> t

Convert from an arbitrary precision integer.

Sourceval of_hex_string : signedness:Signedness.t -> width:int -> string -> t

Create from a hex encoded string.

Sourceval of_octal_string : signedness:Signedness.t -> width:int -> string -> t

Create from an octal encoded string.

Sourceval int_of_hex_char : char -> int

Utility conversion functions to/from hex chars

Sourceval hex_char_of_int : int -> char
Sourcemodule type Bit = sig ... end
Sourcemodule Make_bit_list (Bit : Bit) : sig ... end

Create constant conversion functions from lists of some inner Bit.t type.

Sourceval of_bit_list : int list -> t
Sourceval to_bit_list : t -> int list
Sourceval pp : Base.Formatter.t -> t -> unit
Sourcemodule Raw : sig ... end

Convert to from constants from raw bit patterns stored in strings and bytes. Data is copied and resized as appropriate.

Sourcemodule Expert : sig ... end