123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081(**************************************************************************)(* *)(* This file is part of WP plug-in of Frama-C. *)(* *)(* Copyright (C) 2007-2023 *)(* CEA (Commissariat a l'energie atomique et aux energies *)(* alternatives) *)(* *)(* 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, version 2.1. *)(* *)(* It 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. *)(* *)(* See the GNU Lesser General Public License version 2.1 *)(* for more details (enclosed in the file licenses/LGPLv2.1). *)(* *)(**************************************************************************)openLangopenLang.FopenTactical(* -------------------------------------------------------------------------- *)(* --- Range Tactical --- *)(* -------------------------------------------------------------------------- *)letrecrangepooleab=ifa<=bthenletdescr=Printf.sprintf"Value %d"binletcond=p_equale(e_intb)inrange((descr,cond)::pool)ea(predb)elsepoolletenum?ateabsequent=letlower=Printf.sprintf"Lower %d"a,p_lte(e_inta)inletupper=Printf.sprintf"Upper %d"b,p_lt(e_intb)einletcases=lower::range[upper]eabinTactical.insert?atcasessequentletvmin,pmin=Tactical.spinner~id:"inf"~title:"Inf"~descr:"Range Lower Bound (inclusive)"()letvmax,pmax=Tactical.spinner~id:"sup"~title:"Sup"~descr:"Range Upper Bound (inclusive)"()classrange=object(self)inheritTactical.make~id:"Wp.range"~title:"Range"~descr:"Enumerate a range of values for an integer term"~params:[pmin;pmax]methodselectfeedback(s:Tactical.selection)=letat=Tactical.atsinlete=Tactical.selectedsinifF.is_intethenbeginleta=self#get_fieldvmininletb=self#get_fieldvmaxinifnot(a<=b)then(feedback#set_error"Empty Range (shall have Inf <= Sup)";Not_configured)else(feedback#set_title"Range (%d-%d)"ab;feedback#set_descr"Enumerate (lower,%d-%d,upper)"ab;Applicable(enum?ateab))endelseNot_applicableendlettactical=Tactical.export(newrange)letstrategy?(priority=1.0)selection~vmin:a~vmax:b=Strategy.{priority;tactical;selection;arguments=[argvmina;argvmaxb];}