[sledge] Add Exp.size_of

Summary:
Convenience wrapper of Typ.prim_bit_size_of to construct expressions
denoting the byte-size of sized types.

Reviewed By: mbouaziz

Differential Revision: D14481987

fbshipit-source-id: 44e2c4041
master
Josh Berdine 6 years ago committed by Facebook Github Bot
parent ae1f14044c
commit 3beb1ba2b2

@ -1227,6 +1227,11 @@ let struct_rec key =
let convert ?(signed = false) ~dst ~src exp =
app1 (Convert {signed; dst; src}) exp
let size_of t =
Option.bind (Typ.prim_bit_size_of t) ~f:(fun n ->
if n % 8 = 0 then Some (integer (Z.of_int (n / 8)) Typ.siz) else None
)
(** Transform *)
let map e ~f =

@ -186,6 +186,7 @@ val struct_rec :
stack overflow. *)
val convert : ?signed:bool -> dst:Typ.t -> src:Typ.t -> t -> t
val size_of : Typ.t -> t option
(** Access *)

Loading…
Cancel
Save