123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990(**************************************************************************)(* *)(* This file is part of WP plug-in of Frama-C. *)(* *)(* Copyright (C) 2007-2025 *)(* 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). *)(* *)(**************************************************************************)openMemory(* -------------------------------------------------------------------------- *)(* --- L-Val Utility --- *)(* -------------------------------------------------------------------------- *)letindex(host,ofs)k=host,ofs@[Mindexk]letfield(host,ofs)f=host,ofs@[Mfieldf]lethost_eqab=matcha,bwith|Mvarx,Mvary->Cil_datatype.Varinfo.equalxy|Mmema,Mmemb->a==b|_->falseletofs_eqab=matcha,bwith|Mindexi,Mindexj->i=j|Mfieldf,Mfieldg->Cil_datatype.Fieldinfo.equalfg|_->falseletrecoffset_eqpq=matchp,qwith|[],[]->true|a::p,b::q->ofs_eqab&&offset_eqpq|_->falseletequalab=a==b||(host_eq(fsta)(fstb)&&offset_eq(snda)(sndb))(* -------------------------------------------------------------------------- *)(* --- Memory State Pretty Printing Information --- *)(* -------------------------------------------------------------------------- *)typestate=STATEof{model:(moduleMemory.Model);state:Sigma.state;}letcreate(moduleM:Memory.Model)sigma=STATE{model=(moduleM);state=Sigma.statesigma}letapplyf=functionSTATE{model;state}->letmoduleM=(valmodel)inletstate=Sigma.applyfstateinSTATE{model;state}letlookupse=matchswithSTATE{model;state}->letmoduleM=(valmodel)intryM.lookupstateewithNot_found->Mchunk(Lang.F.Tmap.findestate)letupdatesseqvars=matchseq.pre,seq.postwithSTATE{model;state=pre},STATE{state=post}->letmoduleM=(valmodel)inM.updates{pre;post}varsletiterfs=matchswithSTATE{model;state}->letmoduleM=(valmodel)inLang.F.Tmap.iter(funvaluechunk->matchM.lookupstatevaluewith|exceptionNot_found->f(Mchunkchunk)value|mval->fmvalvalue)state(* -------------------------------------------------------------------------- *)