123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148(****************************************************************************)(* *)(* 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/>. *)(* *)(****************************************************************************)(** Extended domains signatures used by combiners *)openCore.AllopenAbstraction.SimplifiedopenMopsa_utilsmoduletypeSIMPLIFIED_COMBINER=sigincludeSIMPLIFIEDvaldomains:DomainSet.tvalsemantics:SemanticSet.tvalrouting_table:routing_tablevalmerge:t->t*teffect->t*teffect->tvalexec:DomainSet.toption->stmt->('a,t)simplified_man->'actx->t->toptionvalask:DomainSet.toption->('a,'r)query->('a,t)simplified_man->'actx->t->'roptionvalprint_state:DomainSet.toption->printer->t->unitvalprint_expr:DomainSet.toption->('a,t)simplified_man->'actx->t->printer->expr->unitendmoduleSimplifiedToCombiner(D:SIMPLIFIED):SIMPLIFIED_COMBINERwithtypet=D.t=structincludeDletdomains=DomainSet.singletonD.nameletsemantics=SemanticSet.emptyletrouting_table=empty_routing_tableletmergepre(a1,te1)(a2,te2)=lete1=get_root_effectte1inlete2=get_root_effectte2inifcompare_effecte1e2=0thena1elseifis_empty_effecte1thena2elseifis_empty_effecte2thena1elseD.mergepre(a1,e1)(a2,e2)letexecdomains=D.execletaskdomains=D.askletprint_statetargets=D.print_stateletprint_exprtargets=D.print_exprendmoduleCombinerToSimplified(T:SIMPLIFIED_COMBINER):SIMPLIFIEDwithtypet=T.t=structincludeTletmergepre(a1,e1)(a2,e2)=lette1=mk_teffecte1empty_teffectempty_teffectinlette2=mk_teffecte2empty_teffectempty_teffectinT.mergepre(a1,te1)(a2,te2)letexecstmtmanctxa=T.execNonestmtmanctxaletaskquerymanctxa=T.askNonequerymanctxaletprint_stateprintera=T.print_stateNoneprinteraletprint_exprmanctxaprintere=T.print_exprNonemanctxaprintereendmoduleSimplifiedToStandard(D:SIMPLIFIED_COMBINER):Domain.DOMAIN_COMBINERwithtypet=D.t=structincludeDletsubset__(a,_)(a',_)=D.subsetaa'letjoin__(a,_)(a',_)=D.joinaa'letmeet__(a,_)(a',_)=D.meetaa'letwiden_ctx(a,_)(a',_)=D.widenctxaa'letinitprogmanflow=leta'=D.initproginset_envT_cura'manflowletrouting_table=empty_routing_tableletchecks=[]letsimplified_manmanflow={exec=(funstmt->man.Core.Manager.execstmtflow|>post_to_flowman|>get_envT_curman);ask=(funquery->ask_and_reduceman.Core.Manager.askqueryflow);}letexecdomains=letf=D.execdomainsin(funstmtmanflow->leta=get_envT_curmanflowinifD.is_bottomathenPost.returnflow|>OptionExt.returnelsefstmt(simplified_manmanflow)(Flow.get_ctxflow)a|>OptionExt.lift@@funa'->letpost=set_envT_cura'manflow|>Post.returninifare_effects_enabled()thenpost|>Cases.map_effects(funeffects->man.set_effects(man.get_effectseffects|>add_stmt_to_teffectstmt)effects)elsepost)letevaldomainsexpmanflow=Noneletaskdomains=letf=D.askdomainsin(funquerymanflow->matchfquery(simplified_manmanflow)(Flow.get_ctxflow)(get_envT_curmanflow)with|None->None|Somer->Some(Cases.singletonrflow))letprint_exprdomains=letf=D.print_exprdomainsin(funmanflowprintere->leta=get_envT_curmanflowinifD.is_bottomathen()elsef(simplified_manmanflow)(Flow.get_ctxflow)aprintere)end