123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153(****************************************************************************)(* *)(* 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:path->t->t*change_map->t*change_map->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_tableletmergepathpre(a1,m1)(a2,m2)=lete1=get_changepathm1inlete2=get_changepathm2inifcompare_changee1e2=0thena1elseifis_empty_changee1thena2elseifis_empty_changee2thena1elseD.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=singleton_change_mapempty_pathe1inlette2=singleton_change_mapempty_pathe2inT.mergeempty_pathpre(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'manflow|>Option.someletrouting_table=empty_routing_tableletchecks=[]letsimplified_manmanflow={exec=(funstmt->letflow=man.Core.Manager.execstmtflow|>post_to_flowmaninletcases=get_envT_curmanflowinCases.reduce_result(funa_->a)~join:D.join~meet:D.meet~bottom:(fun()->D.bottom)cases);ask=(funquery->ask_and_reduceman.Core.Manager.askqueryflow);}letexecdomains=letf=D.execdomainsin(funstmtmanflow->get_envT_curmanflow>>$?funaflow->ifD.is_bottomathenPost.returnflow|>OptionExt.returnelsefstmt(simplified_manmanflow)(Flow.get_ctxflow)a|>OptionExt.lift@@funa'->letpost=set_envT_cura'manflowinifis_change_tracker_enabled()thenpost|>Cases.map_changes(funchangesflow->man.add_changestmt[]flowchanges)elsepost)letevaldomainsexpmanflow=Noneletaskdomains=letf=D.askdomainsin(funquerymanflow->get_envT_curmanflow>>$?funaflow->matchfquery(simplified_manmanflow)(Flow.get_ctxflow)awith|None->None|Somer->Some(Cases.singletonrflow))letprint_exprdomains=letf=D.print_exprdomainsin(funmanflowprintere->get_envT_curmanflow|>Cases.iter_result(funaflow->ifD.is_bottomathen()elsef(simplified_manmanflow)(Flow.get_ctxflow)aprintere))end