123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172(****************************************************************************)(* *)(* 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/>. *)(* *)(****************************************************************************)(** Leaf domains have a simplified interface that gives access to
their local abstractions. The global manager and the flow abstraction are
not accessible.
*)openCore.AllopenMopsa_utils(*==========================================================================*)(** {2 Domain manager} *)(*==========================================================================*)(** Simplified domains are given a simplified manager providing access to
queries on the pre-condition only
*)type('a,'t)simplified_man={exec:stmt->'t;ask:'r.('a,'r)query->'r;}moduletypeSIMPLIFIED=sig(** {2 Domain header} *)(** ***************** *)typet(** Type of an abstract elements. *)valid:tid(** Domain identifier *)valname:string(** Domain name *)valbottom:t(** Least abstract element of the lattice. *)valtop:t(** Greatest abstract element of the lattice. *)(** {2 Predicates} *)(** ************** *)valis_bottom:t->bool(** [is_bottom a] tests whether [a] is bottom or not. *)valsubset:t->t->bool(** Partial order relation. [subset a1 a2] tests whether [a1] is
related to (or included in) [a2]. *)(** {2 Operators} *)(** ************* *)valjoin:t->t->t(** [join a1 a2] computes an upper bound of [a1] and [a2]. *)valmeet:t->t->t(** [meet a1 a2] computes a lower bound of [a1] and [a2]. *)valwiden:'actx->t->t->t(** [widen ctx a1 a2] computes an upper bound of [a1] and [a2] that
ensures stabilization of ascending chains. *)valmerge:t->t*change->t*change->t(** [merge pre (post1, change1) (post2, change2)] synchronizes two divergent
post-conditions [post1] and [post2] using a common pre-condition [pre].
Diverging post-conditions emerge after a fork-join trajectory in the
abstraction DAG (e.g., a reduced product).
The changes [change1] and [change2] represent a journal of internal statements
executed during the the computation of the post-conditions over the
two trajectories.
*)(** {2 Transfer functions} *)(** ********************** *)valinit:program->t(** Initial abstract element *)valexec:stmt->('a,t)simplified_man->'actx->t->toption(** Computation of post-conditions *)valask:('a,'r)query->('a,t)simplified_man->'actx->t->'roption(** Handler of queries *)(** {2 Printing} *)(** ************ *)valprint_state:printer->t->unit(** Printer of an abstract element. *)valprint_expr:('a,t)simplified_man->'actx->t->printer->expr->unit(** Printer of an expression's value *)end(*==========================================================================*)(** {2 Registration} *)(*==========================================================================*)letdomains:(moduleSIMPLIFIED)listref=ref[]letregister_simplified_domaindom=letmoduleDom=(valdom:SIMPLIFIED)inletreciter=function|[]->[dom]|hd::tl->letmoduleHd=(valhd:SIMPLIFIED)inifHd.name=Dom.namethendom::tlelsehd::itertlindomains:=iter!domainsletfind_simplified_domainname=List.find(fundom->letmoduleD=(valdom:SIMPLIFIED)incompareD.namename=0)!domainsletmem_simplified_domainname=List.exists(fundom->letmoduleD=(valdom:SIMPLIFIED)incompareD.namename=0)!domainsletsimplified_domain_names()=List.map(fundom->letmoduleD=(valdom:SIMPLIFIED)inD.name)!domains