1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798(****************************************************************************)(* *)(* This file is part of MOPSA, a Modular Open Platform for Static Analysis. *)(* *)(* Copyright (C) 2017-2019 The MOPSA Project. *)(* *)(* This program is free software: 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, either version 3 of the License, or *)(* (at your option) any later version. *)(* *)(* This program 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. *)(* *)(* You should have received a copy of the GNU Lesser General Public License *)(* along with this program. If not, see <http://www.gnu.org/licenses/>. *)(* *)(****************************************************************************)(** Standard signature of functor domains *)openCore.AllopenDomainopenMopsa_utilsmoduletypeDOMAIN_FUNCTOR=sigvalname:stringmoduleFunctor:functor(D:DOMAIN)->DOMAINend(*==========================================================================*)(** {2 Registration} *)(*==========================================================================*)(** Instrument transfer functions with some useful pre/post processing *)moduleInstrument(F:DOMAIN_FUNCTOR):DOMAIN_FUNCTOR=structletname=F.namemoduleFunctor(D:DOMAIN)=structmoduleI=F.Functor(D)includeI(* Add stmt to the changes of the domain *)letexecstmtmanflow=ifis_change_tracker_enabled()thenI.execstmtmanflow|>OptionExt.lift@@funres->Cases.map_changes(funchangesflow->man.add_changestmt[]flowchanges)reselseI.execstmtmanflow(* Remove duplicate evaluations *)letevalexpmanflow=I.evalexpmanflow|>OptionExt.lift@@Eval.remove_duplicatesman.latticeendendletfunctors:(moduleDOMAIN_FUNCTOR)listref=ref[]letregister_domain_functorf=letmoduleF=(valf:DOMAIN_FUNCTOR)inletmoduleFF=Instrument(F)infunctors:=(moduleFF)::!functorsletfind_domain_functorname=List.find(fundom->letmoduleD=(valdom:DOMAIN_FUNCTOR)incompareD.namename=0)!functorsletmem_domain_functorname=List.exists(fundom->letmoduleD=(valdom:DOMAIN_FUNCTOR)incompareD.namename=0)!functorsletdomain_functor_names()=List.map(fundom->letmoduleD=(valdom:DOMAIN_FUNCTOR)inD.name)!functors