123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108(************************************************************************)(* * The Rocq Prover / The Rocq Development Team *)(* v * Copyright INRIA, CNRS and contributors *)(* <O___,, * (see version control and CREDITS file for authors & dates) *)(* \VV/ **************************************************************)(* // * This file is distributed under the terms of the *)(* * GNU Lesser General Public License Version 2.1 *)(* * (see LICENSE file for the text of the license) *)(************************************************************************)openLibobjecttypetac_option_locality=|Default|Global|Local|Export|GlobalAndExportlettac_option_locality=letopenAttributesinletopenAttributes.Notationsinletonex=attribute_of_list[x,single_key_parser~name:"Locality"~key:x()]inone"local"++one"global"++one"export">>=fun((local,global),export)->matchlocal,global,exportwith|None,None,None->returnDefault|Some(),Some(),_->CErrors.user_errPp.(str"Cannot combine local and global.")|Some(),_,Some()->CErrors.user_errPp.(str"Cannot combine local and export.")|Some(),None,None->returnLocal|None,Some(),None->returnGlobal|None,None,Some()->returnExport|None,Some(),Some()->returnGlobalAndExportletwarn_default_locality=CWarnings.create~name:"deprecated-tacopt-without-locality"~category:Deprecation.Version.v8_17Pp.(fun()->strbrk"The default and global localities for this command outside \
sections are currently equivalent to the combination of the \
standard meaning of \"global\" (as described in the reference \
manual), \"export\" and re-exporting for every surrounding \
module. It will change to just \"global\" (with the meaning \
used by the \"Set\" command) in a future release."++fnl()++strbrk"To preserve the current meaning in a forward compatible way, \
use the attribute \"#[global,export]\" and repeat the command \
with just \"#[export]\" in any surrounding modules. If you \
are fine with the change of semantics, disable this warning.")letdeclare_tactic_option?defaultname=letcurrent_tactic:Gentactic.glob_generic_tacticoptionref=Summary.refdefault~name:(name^"-default-tactic")inletset_current_tactict=current_tactic:=tinletcache(_,tac)=set_current_tactictacinletload_(local,tac)=matchlocalwith|Default|Global|GlobalAndExport->set_current_tactictac|Export->()|Local->assertfalse(* not allowed by classify *)inletimporti(local,tac)=matchlocalwith|GlobalAndExport|Export->ifInt.equali1thenset_current_tactictac|Default|Global->set_current_tactictac|Local->assertfalse(* not allowed by classify *)inletclassify(local,_)=matchlocalwith|Local->Dispose|Default|Global|Export|GlobalAndExport->Substituteinletsubst(s,(local,tac))=(local,Option.map(Gentactic.substs)tac)inletinput:tac_option_locality*Gentactic.glob_generic_tacticoption->obj=declare_object{(default_objectname)withcache_function=cache;load_function=load;(* can't simple_open: crappy behaviour when superglobal *)open_function=filtered_openimport;classify_function=classify;subst_function=subst}inletput?loclocaltac=let()=matchlocalwith|Default->ifnot(Lib.sections_are_opened())thenwarn_default_locality?loc()|Local->()|Export|Global|GlobalAndExport->ifLib.sections_are_opened()thenCErrors.user_err?locPp.(str"This locality is not supported inside sections by this command.")inLib.add_leaf(input(local,Sometac))inletget()=match!current_tacticwith|None->Proofview.tclUNIT()|Sometac->Gentactic.interptacinletprint()=match!current_tacticwith|None->Pp.str"<unset>"|Sometac->letenv=Global.env()inletsigma=Evd.from_envenvinGentactic.print_globenvsigmatacinput,get,print