123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207(****************************************************************************)(* *)(* 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/>. *)(* *)(****************************************************************************)(** Generators of identifiers for domains and values *)openMopsa_utilsopenEqtype_id=..type_id+=I_stateful_domain:'aid->'aidtype_id+=I_stateless_domain:'aid->'aidtype_id+=I_value:'aid->'aidtypewitness={eq:'a'b.'aid->'bid->('a,'b)eqoption;}typewitness_chain={eq:'a'b.witness->'aid->'bid->('a,'b)eqoption;}letempty_witness:witness={eq=(fun__->None)}typepool={mutablestateful:witness;mutablestateless:witness;mutablevalue:witness;mutableothers:witness;}letpool={stateful=empty_witness;stateless=empty_witness;value=empty_witness;others=empty_witness;}letregister_id(w:witness_chain)=letold=pool.othersinpool.others<-{eq=(fun(typea)(typeb)(id1:aid)(id2:bid)->w.eqoldid1id2)}letregister_stateful_id(w:witness_chain)=letold=pool.statefulinpool.stateful<-{eq=(fun(typea)(typeb)(id1:aid)(id2:bid)->w.eqoldid1id2)}letregister_stateless_id(w:witness_chain)=letold=pool.statelessinpool.stateless<-{eq=(fun(typea)(typeb)(id1:aid)(id2:bid)->w.eqoldid1id2)}letregister_value_id(w:witness_chain)=letold=pool.valueinpool.value<-{eq=(fun(typea)(typeb)(id1:aid)(id2:bid)->w.eqoldid1id2)}(** Equality witness of domain identifiers *)letequal_id(id1:'aid)(id2:'bid):('a,'b)eqoption=matchid1,id2with|I_stateful_domaini1,I_stateful_domaini2->pool.stateful.eqi1i2|I_stateful_domain_,_|_,I_stateful_domain_->None|I_stateless_domaini1,I_stateless_domaini2->pool.stateless.eqi1i2|I_stateless_domain_,_|_,I_stateless_domain_->None|I_valuei1,I_valuei2->pool.value.eqi1i2|I_value_,_|_,I_value_->None|_->pool.others.eqid1id2(** Generator of a new identifier *)moduleGenId(Spec:sigtypetend)=structtype_id+=Id:Spec.tidletid=Idlet()=register_id{eq=(letf:typeab.witness->aid->bid->(a,b)eqoption=funnextid1id2->matchid1,id2with|Id,Id->SomeEq|_->next.eqid1id2inf);}endmoduleGenDomainId(Spec:sigtypetvalname:stringend)=structtype_id+=Id:Spec.tidletid=I_stateful_domainIdletname=Spec.nameletdebugfmt=Debug.debug~channel:Spec.namefmtlet()=register_stateful_id{eq=(letf:typeab.witness->aid->bid->(a,b)eqoption=funnextid1id2->matchid1,id2with|Id,Id->SomeEq|_->next.eqid1id2inf);}end(** Generator of a new identifier for stateless domains *)moduleGenStatelessDomainId(Spec:sigvalname:stringend)=structtype_id+=Id:unitidletid=I_stateless_domainIdletname=Spec.nameletdebugfmt=Debug.debug~channel:Spec.namefmtlet()=register_stateless_id{eq=(letf:typeab.witness->aid->bid->(a,b)eqoption=funnextid1id2->matchid1,id2with|Id,Id->SomeEq|_->next.eqid1id2inf);}end(** Generator of a new value identifier *)moduleGenValueId(Spec:sigtypetvalname:stringvaldisplay:stringend)=structtype_id+=Id:Spec.tidletid=I_valueIdletname=Spec.nameletdisplay=Spec.displayletdebugfmt=Debug.debug~channel:Spec.namefmtlet()=register_value_id{eq=(letf:typeab.witness->aid->bid->(a,b)eqoption=funnextid1id2->matchid1,id2with|Id,Id->SomeEq|_->next.eqid1id2inf);}end