123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111(**************************************************************************)(* *)(* This file is part of WP plug-in of Frama-C. *)(* *)(* Copyright (C) 2007-2024 *)(* CEA (Commissariat a l'energie atomique et aux energies *)(* 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). *)(* *)(**************************************************************************)(* -------------------------------------------------------------------------- *)(* --- Fresh Variable Management --- *)(* -------------------------------------------------------------------------- *)moduletypeType=sigtypetvaldummy:tvalequal:t->t->boolvalcompare:t->t->intendmoduleMake(T:Type)=structtypevar={vid:int;vbase:string;vrank:int;vtau:T.t;}lethash_varx=Hcons.hash_pairx.vrank(Hashtbl.hashx.vbase)letprettyfmtx=Format.fprintffmt"%s_%d"x.vbasex.vrank(* HASHCONSING *)moduleW=Weak.Make(structtypet=varlethash=hash_varletequalxy=x.vbase=y.vbase&&x.vrank=y.vrank&&T.equalx.vtauy.vtauend)letkid=ref0lethmap=W.create32993(* 3-th Leyland Prime number *)letinsertbaseranktau=letx0={vid=0;vbase=base;vrank=rank;vtau=tau;}intryW.findhmapx0withNot_found->letk=leti=!kidin(assert(i<>-1);incrkid;i)inletx={x0withvid=k}inW.addhmapx;xletdummy=insert""0T.dummylethashx=x.vidletequal=(==)letcomparexy=letcmp=String.comparex.vbasey.vbaseinifcmp<>0thencmpelseletcmp=Stdlib.comparex.vranky.vrankinifcmp<>0thencmpelseT.comparex.vtauy.vtau(* POOL *)typepool=(string,intref)Hashtbl.tletcreate?copy()=matchcopywith|None->Hashtbl.create131|Somepool->Hashtbl.copypoolletcounterpoolbase=tryHashtbl.findpoolbasewithNot_found->letc=ref0inHashtbl.addpoolbasec;cletaddpoolx=letc=counterpoolx.vbaseinif!c<=x.vrankthenc:=succx.vrankletnextpoolbase=letc=counterpoolbaseinletk=!cinincrc;kletfreshpoolbasetau=letrank=nextpoolbaseininsertbaseranktauletalphapoolx=freshpoolx.vbasex.vtauend