@@ -100,6 +100,8 @@ let create_id_from_sym ?(lowercase = false) sym =
100100
101101let create_sym_from_id id = Sym. fresh (Id. get_string id)
102102
103+ let ail_null = A. (AilEconst (ConstantInteger (IConstant (Z. zero, Decimal , None ))))
104+
103105let generate_error_msg_info_update_stats ?(cn_source_loc_opt = None ) () =
104106 let cn_source_loc_arg =
105107 match cn_source_loc_opt with
@@ -120,7 +122,7 @@ let generate_error_msg_info_update_stats ?(cn_source_loc_opt = None) () =
120122 (None , [ (Cerb_location. unknown, [ loc_str_2_escaped ^ loc_str_escaped ]) ]))
121123 in
122124 cn_source_loc_str
123- | None -> mk_expr A. ( AilEconst ConstantNull )
125+ | None -> mk_expr ail_null
124126 in
125127 let update_fn_sym = Sym. fresh " update_cn_error_message_info" in
126128 [ A. (
@@ -542,11 +544,7 @@ let cn_to_ail_const const basetype =
542544 | MemByte { alloc_id = _ ; value = i } ->
543545 wrap (A. AilEconst (ConstantInteger (IConstant (i, Decimal , None ))))
544546 | Bits ((sgn , sz ), i ) ->
545- let z_min, z_max = BT. bits_range (sgn, sz) in
546- let ity =
547- let ibt = CF.IntegerType. IntN_t sz in
548- match sgn with Signed -> C. Signed ibt | Unsigned -> C. Unsigned ibt
549- in
547+ let z_min, _ = BT. bits_range (sgn, sz) in
550548 let suffix =
551549 let size_of = Memory. size_of_integer_type in
552550 match sgn with
@@ -566,14 +564,17 @@ let cn_to_ail_const const basetype =
566564 Some A. LL
567565 in
568566 let ail_const =
569- if Z. equal i z_max then
570- A. ConstantInteger (IConstantMax ity)
571- else if Z. equal i z_min && BT. equal_sign sgn BT. Signed then
572- A. ConstantInteger (IConstantMin ity)
567+ let k a = A. (AilEconst (ConstantInteger (IConstant (a, Decimal , suffix)))) in
568+ if Z. equal i z_min && BT. equal_sign sgn BT. Signed then
569+ A. (
570+ AilEbinary
571+ ( mk_expr (k (Z. neg (Z. sub (Z. neg i) Z. one))),
572+ Arithmetic Sub ,
573+ mk_expr (k Z. one) ))
573574 else
574- ConstantInteger ( IConstant (i, Decimal , suffix))
575+ k i
575576 in
576- wrap ( A. AilEconst ail_const)
577+ wrap ail_const
577578 | Q q -> wrap (A. AilEconst (ConstantFloating (Q. to_string q, None )))
578579 | Pointer z ->
579580 let ail_const' =
@@ -584,9 +585,8 @@ let cn_to_ail_const const basetype =
584585 | Bool b ->
585586 wrap
586587 (A. AilEconst (ConstantPredefined (if b then PConstantTrue else PConstantFalse )))
587- | Unit ->
588- wrap (A. AilEconst ConstantNull ) (* Gets overridden by dest_with_unit_check *)
589- | Null -> wrap (A. AilEconst ConstantNull )
588+ | Unit -> wrap ail_null (* Gets overridden by dest_with_unit_check *)
589+ | Null -> wrap ail_null
590590 | CType_const _ -> failwith (__LOC__ ^ " : TODO CType_const" )
591591 | Default bt -> cn_to_ail_default bt
592592 in
@@ -705,10 +705,10 @@ let generate_get_or_put_ownership_function ~without_ownership_checking ctype
705705 if without_ownership_checking then
706706 ([] , [] )
707707 else (
708- let uintptr_t_type = C. uintptr_t in
709- let generic_c_ptr_binding = create_binding generic_c_ptr_sym uintptr_t_type in
708+ let void_ptr = C. mk_ctype_pointer C. no_qualifiers C. void in
709+ let generic_c_ptr_binding = create_binding generic_c_ptr_sym void_ptr in
710710 let uintptr_t_cast_expr =
711- mk_expr A. (AilEcast (C. no_qualifiers, uintptr_t_type , cast_expr))
711+ mk_expr A. (AilEcast (C. no_qualifiers, void_ptr , cast_expr))
712712 in
713713 let generic_c_ptr_assign_stat_ =
714714 A. (AilSdeclaration [ (generic_c_ptr_sym, Some uintptr_t_cast_expr) ])
@@ -2634,7 +2634,6 @@ let cn_to_ail_resource
26342634 let matching_preds =
26352635 List. filter (fun (pred_sym' , _def ) -> Sym. equal pname pred_sym') preds
26362636 in
2637- Printf. printf " Pred sym: %s\n " (Sym. pp_string pname);
26382637 let pred_sym', pred_def' =
26392638 match matching_preds with
26402639 | [] ->
0 commit comments