package bap-std
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=7c6d0dfe2640e800829617dd150ffe748493fe3f317ed41be44312b2821deb46
md5=5dbc6677d646bec59fd7414f23e88cf8
doc/bap/Bap/Std/Word/Int_err/index.html
Module Word.Int_err
Arithmetic raised into Or_error
monad
All binary integer operations are only well defined on operands with equal sizes.
Module Int
provides a set of integer operations that do not raise exceptions, but return values raised to an Or_error monad.
Example:
Z.(i16 v1 + i16 v2 / int 16 v3)
,
or just:
Z.(!$v1 + !$v2 / !$v3)
.
val (!$) : t -> t Core_kernel.Or_error.t
!$v
lifts v
to an Or_error monad. It is, essentially, the same as Ok v
The following lifter will check that their operand has a corresponding width.
val i1 : t -> t Core_kernel.Or_error.t
i1 x
is Ok x
iff bitwidth x = 1
val i4 : t -> t Core_kernel.Or_error.t
i4 x
is Ok x
iff bitwidth x = 4
val i8 : t -> t Core_kernel.Or_error.t
i8 x
is Ok x
iff bitwidth x = 8
val i16 : t -> t Core_kernel.Or_error.t
i16 x
is Ok x
iff bitwidth x = 16
val i32 : t -> t Core_kernel.Or_error.t
i32 x
is Ok x
iff bitwidth x = 32
val i64 : t -> t Core_kernel.Or_error.t
i64 x
is Ok x
iff bitwidth x = 64
val int : int -> t -> t Core_kernel.Or_error.t
int w v
will be Ok
if v
has width w
val of_word_size : Core_kernel.Word_size.t -> t -> t Core_kernel.Or_error.t
of_word_size w
creates a lifter for a specified word size w
, i.e. either i64
or i32
include Integer.S with type t = t Core_kernel.Or_error.t
type t = t Core_kernel.Or_error.t
include Integer.Base with type t := t
val zero : t
element neutral to the addition
val one : t
element neutral to the multiplication
lnot x
is a logical negation of x
(1-complement)
logand x y
is a conjunction of x
and y
A common set of infix operators
val (>>=) :
'a Core_kernel.Or_error.t ->
('a -> 'b Core_kernel.Or_error.t) ->
'b Core_kernel.Or_error.t
val (>>|) :
'a Core_kernel.Or_error.t ->
('a -> 'b) ->
'b Core_kernel.Or_error.t