123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990(**************************************************************************)(* *)(* This file is part of WP plug-in of Frama-C. *)(* *)(* Copyright (C) 2007-2023 *)(* 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). *)(* *)(**************************************************************************)(* -------------------------------------------------------------------------- *)(* --- Location --- *)(* -------------------------------------------------------------------------- *)letwith_current_loclocphix=lettmp=Cil_const.CurrentLoc.get()intryCil_const.CurrentLoc.setloc;lety=phixinCil_const.CurrentLoc.settmp;ywitherror->Cil_const.CurrentLoc.settmp;raiseerror(* -------------------------------------------------------------------------- *)(* --- Local Context --- *)(* -------------------------------------------------------------------------- *)type'avalue={name:string;(* Descriptive *)mutablecurrent:'aoption;}letcreate?defaultname={name=name;current=default}letnames=s.nameletdefinedenv=matchenv.currentwithNone->false|Some_->trueletgetenv=matchenv.currentwith|Somee->e|None->Wp_parameters.fatal"Context '%s' non-initialized."env.nameletget_optenv=env.currentletsetenvs=env.current<-Somesletclearenv=env.current<-Noneletupdateenvf=matchenv.currentwith|Somee->env.current<-Some(fe)|None->Wp_parameters.fatal"Context '%s' non-initialized."env.nameletbind_withenvwfe=lettmp=env.currentinenv.current<-w;trylete=feinenv.current<-tmp;ewitherror->env.current<-tmp;raiseerrorletbindenvsfe=bind_withenv(Somes)feletfreeenvfe=bind_withenvNonefeletpushenvx=letold=env.currentinenv.current<-Somex;oldletpopenvold=env.current<-oldletdemon=ref[]letregisterf=demon:=!demon@[f]letconfigure=letclosure,state=State_builder.apply_once"Wp.Context.configure"[Ast.self](fun()->List.iter(funf->f())!demon)inignorestate;closure(* -------------------------------------------------------------------------- *)