123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175(****************************************************************************)(* *)(* 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/>. *)(* *)(****************************************************************************)(** Simplified signature of a value abstraction. *)openCore.AllopenValue(*==========================================================================*)(** {2 Value domain} *)(*==========================================================================*)moduletypeSIMPLIFIED_VALUE=sig(** {2 Header of the abstraction} *)(** ***************************** *)typet(** Type of the abstract value. *)valid:tid(** Identifier of the value domain *)valaccept_type:typ->bool(** Predicate of types abstracted by the value domain *)valname:string(** Name of the value domain *)valdisplay:string(** Display name used in debug messages *)valbottom:t(** Least abstract element of the lattice. *)valtop:t(** Greatest abstract element of the lattice. *)(** {2 Lattice operators} *)(** ********************* *)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]. *)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. *)(** {2 Forward semantics} *)(** ********************* *)valconstant:constant->typ->tvalunop:operator->typ->t->typ->tvalbinop:operator->typ->t->typ->t->typ->tvalfilter:bool->typ->t->tvalavalue:'ravalue_kind->t->'roption(** {2 Backward semantics} *)(** ********************** *)valbackward_unop:operator->typ->t->typ->t->tvalbackward_binop:operator->typ->t->typ->t->typ->t->t*tvalcompare:operator->bool->typ->t->typ->t->(t*t)(** {2 Pretty printer} *)(** ****************** *)valprint:printer->t->unit(** Printer of an abstract element. *)endletdefault_backward_unopoptartr=aletdefault_backward_binopopt1a1t2a2rtr=(a1,a2)letdefault_filterbta=aletdefault_compareopbt1a1t2a2=(a1,a2)moduleDefaultValueFunctions=structletfilter=default_filterletbackward_unop=default_backward_unopletbackward_binop=default_backward_binopletcompare=default_compareletavalueavkv=Noneend(*==========================================================================*)(** {2 Lifter to VALUE Signature} *)(*==========================================================================*)moduleMakeValue(V:SIMPLIFIED_VALUE):VALUEwithtypet=V.t=structincludeValue.DefaultValueFunctionsincludeVletevalmane=matchekindewith|E_constantc->constantce.etyp|E_unop(op,ee)whenaccept_typeee.etyp->unopopee.etyp(man.evalee|>man.get)e.etyp|E_binop(op,e1,e2)whenaccept_typee1.etyp&&accept_typee2.etyp->binopope1.etyp(man.evale1|>man.get)e2.etyp(man.evale2|>man.get)e.etyp|_->topletbackwardmanever=ifnot(accept_typee.etyp)thenveelsematchekindewith|E_unop(op,ee)whenaccept_typeee.etyp->letvv,_=find_vexpreeveinletvv'=backward_unopopee.etypvve.etyp(man.getr)inrefine_vexpreevv've|E_binop(op,e1,e2)whenaccept_typee1.etyp&&accept_typee2.etyp->letv1,_=find_vexpre1veinletv2,_=find_vexpre2veinletv1',v2'=backward_binopope1.etypv1e2.etypv2e.etyp(man.getr)inrefine_vexpre1v1've|>refine_vexpre2v2'|_->veletcomparemanopbe1v1e2v2=compareopbe1.etypv1e2.etypv2end(*==========================================================================*)(** {2 Registration} *)(*==========================================================================*)letregister_simplified_value_abstractiondom=register_value_abstraction(moduleMakeValue(valdom:SIMPLIFIED_VALUE))