1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162(**************************************************************************)(* This file is part of BINSEC. *)(* *)(* Copyright (C) 2016-2026 *)(* CEA (Commissariat à l'énergie atomique et aux énergies *)(* alternatives) *)(* *)(* you can redistribute it and/or modify it under the terms of the GNU *)(* Lesser General Public License as published by the Free Software *)(* Foundation, version 2.1. *)(* *)(* It is distributed in the hope that it will be useful, *)(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *)(* GNU Lesser General Public License for more details. *)(* *)(* See the GNU Lesser General Public License version 2.1 *)(* for more details (enclosed in the file licenses/LGPLv2.1). *)(* *)(**************************************************************************)openBasic_types.IntegersincludeCollection.Hashed(Z)letzero=Z.zeroletcreate=Z.of_intletto_int=Z.to_intletto_int32=Z.to_int32_unsignedletto_int64=Z.to_int64_unsignedletof_int32=Z.of_int32_unsignedletof_uint32=Uint32.to_bigintletof_int64=Z.of_int64_unsignedletof_uint64=Uint64.to_bigintletof_bigint=Fun.idletof_strings=Z.of_stringsletto_bigint=Fun.idletof_bitvector=Bitvector.value_of(* FIXME: we may want to check for overflow? *)letadd=Z.addletadd_intnt=Z.addt(createn)letadd_bigint=Z.addletsucc=Z.succletpred=Z.pred(* FIXME: hope that t and t' are close enough *)letdifftt'=Z.to_int(Z.subtt')letmoditi=Z.to_intZ.(tmodcreatei)letto_stringv=Z.format"%#08x"vletppppfv=Format.pp_print_stringppf(to_stringv)letpp16ppfv=Format.pp_print_stringppf(Z.format"%04x"v)letpp32=ppletpp64ppfv=Format.pp_print_stringppf(Z.format"%016x"v)letpp_printf=matchfwith`x16->pp16|`x32->pp32|`x64->pp64letpp_setppfvs=letopenFormatinpp_open_hovboxppf0;pp_print_stringppf"{";Set.iter(funv->fprintfppf"%a;@ "ppv)vs;pp_print_stringppf"}";pp_close_boxppf()