let expr_cast tyv tyr v =
if Typ.equal tyv tyr then v else
match object_of tyv, object_of tyr with
| C_int i1 , C_int i2 ->
M.V_int(i2,F.i_convert i1 i2 (int_of_value v))
| C_float _f1 , C_float f2 ->
M.V_float(f2,float_of_value v)
| C_int _ , C_float f2 ->
let z = int_of_value v in
let r = F.real_of_integer z in
M.V_float(f2,r)
| C_float _ , C_int i2 ->
let r = float_of_value v in
let z = F.integer_of_real r in
M.V_int(i2,M.F.modulo i2 z)
| C_pointer t1 , C_pointer t2 ->
M.V_pointer
(Ctypes.object_of t2,
M.cast_loc_to_loc t1 t2 (loc_of_value v))
| C_pointer t1 , C_int i2 ->
M.V_int (i2,M.cast_loc_to_int t1 (loc_of_value v)i2)
| C_int i1 , C_pointer t2 ->
M.V_pointer
(Ctypes.object_of t2,
M.cast_int_to_loc i1 (int_of_value v) t2)
| a,b ->
WpLog.not_yet_implemented "cast from %a to %a"
pp_object a pp_object b