123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881(************************************************************************)(* * 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) *)(************************************************************************)openNamesopenLibnamesopenGlobnames(* to this type are mapped DirPath.t's in the nametab *)moduleGlobDirRef=structtypet=|DirOpenModuleofModPath.t|DirOpenModtypeofModPath.t|DirOpenSectionoffull_pathletequalr1r2=matchr1,r2with|DirOpenModuleop1,DirOpenModuleop2->ModPath.equalop1op2|DirOpenModtypeop1,DirOpenModtypeop2->ModPath.equalop1op2|DirOpenSectionop1,DirOpenSectionop2->eq_full_pathop1op2|(DirOpenModule_|DirOpenModtype_|DirOpenSection_),_->falseletcomparer1r2=matchr1,r2with|DirOpenModuleop1,DirOpenModuleop2->ModPath.compareop1op2|DirOpenModule_,_->-1|_,DirOpenModule_->1|DirOpenModtypeop1,DirOpenModtypeop2->ModPath.compareop1op2|DirOpenModtype_,_->-1|_,DirOpenModtype_->1|DirOpenSectionop1,DirOpenSectionop2->compare_full_pathop1op2endexceptionGlobalizationErrorofqualidleterror_global_not_found~infoqid=letinfo=Option.cata(Loc.add_locinfo)infoqid.CAst.locinExninfo.iraise(GlobalizationErrorqid,info)(* The visibility can be registered either
- for all suffixes not shorter then a given int - when the object
is loaded inside a module
or
- for a precise suffix, when the module containing (the module
containing ...) the object is open (imported)
*)typevisibility=Untilofint|Exactlyofintletmap_visibilityf=function|Untili->Until(fi)|Exactlyi->Exactly(fi)(* Data structure for nametabs *******************************************)moduletypeEqualityType=sigtypetvalequal:t->t->boolend(* A ['a t] is a map from [user_name] to ['a], with possible lookup by
partially qualified names of type [qualid]. The mapping of
partially qualified names to ['a] is determined by the [visibility]
parameter of [push].
The [shortest_qualid] function given a user_name Mylib.A.B.x, tries
to find the shortest among x, B.x, A.B.x and Mylib.A.B.x that denotes
the same object.
*)moduletypeNAMETREE=sigtypeelttypetvalempty:tvalpush:visibility->full_path->elt->t->tvallocate:qualid->t->eltvalfind:full_path->t->eltvalremove:full_path->t->tvalexists:full_path->t->boolvalshortest_qualid_gen:?loc:Loc.t->(Id.t->bool)->full_path->t->qualidvalfind_prefixes:qualid->t->eltlist(** Matches a prefix of [qualid], useful for completion *)valmatch_prefixes:qualid->t->eltlistendletmasking_absolute=CWarnings.create_warning~from:[Deprecation.Version.v8_8]~name:"masking-absolute-name"()letcoq_id=Id.of_string"Coq"letstdlib_id=Id.of_string"Stdlib"letcorelib_id=Id.of_string"Corelib"letwarn_deprecated_dirpath_Coq=CWarnings.create_with_quickfix~name:"deprecated-dirpath-Coq"~category:Deprecation.Version.v9_0(fun(old_id,new_id)->Pp.(old_id++spc()++str"has been replaced by"++spc()++new_id++str"."))(* We shadow as to create the quickfix and message at the same time *)letfix_coq_idcoq_repll=(matchlwith|_coq_id::l->coq_repl::l|_->l)(* [l] is reversed, thus [Corelib.ssr.bool] for example *)letwarn_deprecated_dirpath_Coq?loc(coq_repl,l,id)=letdpl=DirPath.make(List.revl)inletold_id=pr_qualid@@Libnames.make_qualid(DirPath.makel)idinletnew_id=pr_qualid@@Libnames.make_qualid(dp@@fix_coq_idcoq_repl(List.revl))idinletquickfix=Option.map(funloc->[Quickfix.make~locnew_id])locinwarn_deprecated_dirpath_Coq?loc?quickfix(old_id,new_id)moduleMake(E:EqualityType):NAMETREEwithtypeelt=E.t=structtypeelt=E.t(* A name became inaccessible, even with absolute qualification.
Example:
Module F (X : S). Module X.
The argument X of the functor F is masked by the inner module X.
*)letwarn_masking_absolute=CWarnings.create_inmasking_absolutePp.(funn->str"Trying to mask the absolute name \""++pr_pathn++str"\"!")typepath_status=|Relativeoffull_path*elt|Absoluteoffull_path*eltleteq_path_statuspq=matchp,qwith|Relative(u1,o1),Relative(u2,o2)->eq_full_pathu1u2&&E.equalo1o2|Absolute(u1,o1),Absolute(u2,o2)->eq_full_pathu1u2&&E.equalo1o2|(Absolute_|Relative_),_->false(* Dictionaries of short names *)typenametree={path:path_statuslist;map:nametreeId.Map.t}letpush_pathargpath=matchpathwith|[]->[arg]|arg'::_->ifeq_path_statusargarg'thenpathelsearg::pathletmktreepm={path=p;map=m}letempty_tree=mktree[]Id.Map.emptyletis_empty_treetree=tree.path=[]&&Id.Map.is_emptytree.maptypet=nametreeId.Map.tletempty=Id.Map.empty(* [push_until] is used to register [Until vis] visibility.
Example: [push_until Top.X.Y.t o (Until 1) tree [Y;X;Top]] adds the
value [Relative (Top.X.Y.t,o)] to occurrences [Y] and [Y.X] of
the tree, and [Absolute (Top.X.Y.t,o)] to occurrence [Y.X.Top] of
the tree. In particular, the tree now includes the following shape:
{ map := Y |-> {map := X |-> {map := Top |-> {map := ...;
path := Absolute (Top.X.Y.t,o)::...}
...;
path := Relative (Top.X.Y.t,o)::...}
...;
path := Relative (Top.X.Y.t,o)::...}
...;
path := ...}
where ... denotes what was there before.
[push_exactly] is to register [Exactly vis] and [push] chooses
the right one *)letrecpush_untilunameoleveltree=function|modid::path->letmodify_mc=push_untilunameo(level-1)mcpathinletmap=tryId.Map.modifymodidmodifytree.mapwithNot_found->letptab=modify ()empty_treeinId.Map.addmodidptabtree.mapinletthis=iflevel<=0thenmatchtree.pathwith|Absolute(n,_)::_->(* This is an absolute name, we must keep it
otherwise it may become unaccessible forever *)warn_masking_absoluten;tree.path|current->push_path(Relative(uname,o))currentelsetree.pathinifthis==tree.path&&map==tree.mapthentreeelsemktreethismap|[]->matchtree.pathwith|Absolute(uname',o')::_->ifE.equalo'othenbeginassert(eq_full_pathunameuname');tree(* we are putting the same thing for the second time :) *)endelse(* This is an absolute name, we must keep it otherwise it may
become unaccessible forever *)(* But ours is also absolute! This is an error! *)CErrors.user_errPp.(str"Cannot mask the absolute name \""++pr_pathuname'++str"\"!")|current->letthis=push_path(Absolute(uname,o))currentinifthis==tree.paththentreeelsemktreethistree.mapletrecpush_exactlyunameoleveltree=function|[]->CErrors.anomaly(Pp.str"Prefix longer than path! Impossible!")|modid::path->ifInt.equallevel0thenletthis=matchtree.pathwith|Absolute(n,_)::_->(* This is an absolute name, we must keep it
otherwise it may become unaccessible forever *)warn_masking_absoluten;tree.path|current->push_path(Relative(uname,o))currentinifthis==tree.paththentreeelsemktreethistree.mapelse(* not right level *)letmodify_mc=push_exactlyunameo(level-1)mcpathinletmap=tryId.Map.modifymodidmodifytree.mapwithNot_found->letptab=modify()empty_treeinId.Map.addmodidptabtree.mapinifmap==tree.mapthentreeelsemktreetree.pathmapletpushvisibilityunameotab=letdir,id=repr_pathunameinletdir=DirPath.reprdirinletmodify_ptab=matchvisibilitywith|Untili->push_untilunameo(i-1)ptabdir|Exactlyi->push_exactlyunameo(i-1)ptabdirintryId.Map.modifyidmodifytabwithNot_found->letptab=modify()empty_treeinId.Map.addidptabtab(** [remove_path uname tree dir] removes all bindings pointing to
[uname] along the path [dir] in [tree] (i.e. all such bindings are
assumed to be on this path) *)letrecremove_pathunametree=function|modid::path->letupdate=function|None->(* The name was actually not here *)None|Somemc->letmc=remove_pathunamemcpathinifis_empty_treemcthenNoneelseSomemcinletmap=Id.Map.updatemodidupdatetree.mapinletthis=lettest=functionRelative(uname',_)->not(eq_full_pathunameuname')|_->trueinList.filtertesttree.pathinmktreethismap|[]->letthis=lettest=functionAbsolute(uname',_)->not(eq_full_pathunameuname')|_->trueinList.filtertesttree.pathinmktreethistree.map(** Remove all bindings pointing to [uname] in [tab] *)letremoveunametab=letdir,id=repr_pathunameinletdir=DirPath.reprdirinletmodify_ptab=remove_pathunameptabdirintryId.Map.modifyidmodifytabwithNot_found->tabletrecsearchtree=function|modid::path->beginmatchId.Map.find_optmodidtree.mapwith|None->None|Somemodid->searchmodidpathend|[]->Sometree.pathletsearch?locidtreedir=letdirs=matchList.revdirwith|last::lwhenId.equallastcoq_id->[(Somestdlib_id,List.rev(stdlib_id::l));(Somecorelib_id,List.rev(corelib_id::l))]|_->[None,dir]inletsearch_one(warn,dir)=matchsearchtreedirwith|Somev->Some(warn,v)|None->NoneinmatchList.find_mapsearch_onedirswith|Some(coq_repl,p)->Option.iter(funcoq_repl->warn_deprecated_dirpath_Coq?loc(coq_repl,dir,id))coq_repl;p|None->raiseNot_foundletfind_nodeqidtab=letloc=qid.CAst.locinlet(dir,id)=repr_qualidqidinsearch?locid(Id.Map.findidtab)(DirPath.reprdir)letlocateqidtab=leto=matchfind_nodeqidtabwith|(Absolute(uname,o)|Relative(uname,o))::_->o|[]->raiseNot_foundinoletfindunametab=letl,id=repr_pathunameinletl=DirPath.reprlinmatchsearchid(Id.Map.findidtab)lwith|Absolute(_,o)::_->o|_->raiseNot_foundletexistsunametab=trylet_=findunametabintruewithNot_found->falseletshortest_qualid_gen?lochiddenunametab=letdir,id=repr_pathunameinletdir=DirPath.reprdirinlethidden=hiddenidinletrecfind_unameposdirtree=letis_empty=matchposwith[]->true|_->falseinmatchtree.pathwith|(Absolute(u,_)|Relative(u,_))::_wheneq_full_pathuuname&¬(is_empty&&hidden)->List.revpos|_->matchdirwith[]->raiseNot_found|id::dir->find_uname(id::pos)dir(Id.Map.findidtree.map)inletptab=Id.Map.findidtabinletfound_dir=find_uname[]dirptabinmake_qualid?loc(DirPath.makefound_dir)idletpush_nodenodel=matchnodewith|(Absolute(_,o)|Relative(_,o))::_whennot(Util.List.mem_fE.equalol)->o::l|_->lletrecflatten_treetreel=letf_treel=flatten_treetreelinId.Map.foldftree.map(push_nodetree.pathl)letrecsearch_prefixestree=function|modid::path->search_prefixes(Id.Map.findmodidtree.map)path|[]->List.rev(flatten_treetree[])letfind_prefixesqidtab=trylet(dir,id)=repr_qualidqidinsearch_prefixes(Id.Map.findidtab)(DirPath.reprdir)withNot_found->[]letmatch_prefixes=letcprefixxy=CString.(comparex(suby0(min(lengthx)(lengthy))))infunqidtab->trylet(dir,id)=repr_qualidqidinletid_prefix=cprefixId.(to_stringid)inletmatches=Id.Map.filter_range(funx->id_prefixId.(to_stringx))tabinletmatches=Id.Map.mapi(fun_keytab->search_prefixestab(DirPath.reprdir))matchesin(* Rocq's flatten is "magical", so this is not so bad perf-wise *)CList.flatten@@Id.Map.(fold(fun_rl->r::l)matches[])withNot_found->[]endmoduletypeNAMETAB_gen=sigtype'aread_tabtypewrite_tabtypeeltvalpush:visibility->full_path->elt->write_tabvalremove:full_path->elt->write_tabvalshortest_qualid_gen:?loc:Loc.t->(Id.t->bool)->elt->qualidread_tabvalshortest_qualid:?loc:Loc.t->Id.Set.t->elt->qualidread_tabvalpr:elt->Pp.tread_tabvallocate:qualid->eltread_tabvallocate_all:qualid->eltlistread_tabvalcompletion_candidates:qualid->eltlistread_tabvalto_path:elt->full_pathread_tabvalof_path:full_path->eltread_tabvalexists:full_path->boolread_tab(* XXX add src_loc table? *)endmoduletypeValueType=sigincludeEqualityTypevalis_var:t->Id.toptionmoduleMap:CSig.UMapSwithtypekey=tendmoduletypeWarnInfo=sigtypeelttypedatamoduleMap:CSig.UMapSwithtypekey=eltvalstage:Summary.Stage.tvalsummary_name:stringvalwarn:?loc:Loc.t->elt->data->unitendmoduletypeFunctional_NAMETAB=sigtypetvalempty:tincludeNAMETAB_genwithtype'aread_tab:=t->'aandtypewrite_tab:=t->tendmoduleMakeTab(E:ValueType):Functional_NAMETABwithtypeelt=E.t=structtypeelt=E.tmoduleTab=Make(E)typet={tab:Tab.t;revtab:full_pathE.Map.t;}letempty={tab=Tab.empty;revtab=E.Map.empty;}letpushvisspv{tab;revtab}=matchviswith|Until_->{tab=Tab.pushvisspvtab;revtab=E.Map.addvsprevtab;}|Exactly_->{tab=Tab.pushvisspvtab;revtab;}letremovespv{tab;revtab}={tab=Tab.removesptab;revtab=E.Map.removevrevtab;}letshortest_qualid_gen?locavoidv{tab;revtab}=matchE.is_varvwith|Someid->make_qualid?locDirPath.emptyid|None->letsp=E.Map.findvrevtabinTab.shortest_qualid_gen?locavoidsptabletshortest_qualid?locavoidvtabs=shortest_qualid_gen?loc(funid->Id.Set.memidavoid)vtabsletprvtab=pr_qualid(shortest_qualidId.Set.emptyvtab)letlocateqid{tab}=Tab.locateqidtabletlocate_allqid{tab}=Tab.find_prefixesqidtabletcompletion_candidatesqid{tab}=Tab.match_prefixesqidtabletto_pathv{revtab}=matchE.is_varvwith|Someid->make_pathDirPath.emptyid|None->E.Map.findvrevtabletof_pathsp{tab}=Tab.findsptabletexistssp{tab}=Tab.existssptabendmoduletypeNAMETAB=NAMETAB_genwithtype'aread_tab:='aandtypewrite_tab:=unitmoduletypeStateInfo=sigvalstage:Summary.Stage.tvalsummary_name:stringendmoduleMakeImperative(Tab:Functional_NAMETAB)(SI:StateInfo)():NAMETABwithtypeelt=Tab.elt=structtypeelt=Tab.eltletthe_tab=Summary.ref~stage:SI.stage~name:SI.summary_nameTab.emptyletpushvisspv=the_tab:=Tab.pushvisspv!the_tabletremovespv=the_tab:=Tab.removespv!the_tabletshortest_qualid_gen?locfv=Tab.shortest_qualid_gen?locfv!the_tabletshortest_qualid?locavoidv=Tab.shortest_qualid?locavoidv!the_tabletprv=Tab.prv!the_tabletlocateqid=Tab.locateqid!the_tabletlocate_allqid=Tab.locate_allqid!the_tabletcompletion_candidatesqid=Tab.completion_candidatesqid!the_tabletto_pathv=Tab.to_pathv!the_tabletof_pathv=Tab.of_pathv!the_tabletexistsv=Tab.existsv!the_tabendmoduletypeWarnedTab=sigincludeNAMETABtypewarning_datavalpush:?wdata:warning_data->visibility->full_path->elt->unitvalis_warned:elt->warning_dataoptionvalwarn:?loc:Loc.t->elt->warning_data->unitvallocate:?nowarn:bool->qualid->eltendmoduleMakeWarned(M:NAMETAB)(W:WarnInfowithtypeelt=M.elt)():WarnedTabwithtypeelt=M.eltandtypewarning_data:=W.data=structincludeMletwarntab=Summary.ref~stage:W.stage~name:W.summary_nameW.Map.emptyletpush?wdatavisspelt=M.pushvisspelt;matchwdatawith|None->()|Somewdata->let()=matchviswith|Until_->()|Exactly_->assertfalseinwarntab:=W.Map.addeltwdata!warntabletremovespelt=M.removespelt;warntab:=W.Map.removeelt!warntabletis_warnedelt=W.Map.find_optelt!warntabletwarn=W.warnletlocate?(nowarn=false)qid=letelt=M.locateqidinlet()=ifnowarnthen()elsematchis_warnedeltwith|None->()|Somewdata->warn?loc:qid.loceltwdataineltendmoduleEasyNoWarn(M:sigincludeValueTypeincludeStateInfoend)()=MakeImperative(MakeTab(M))(M)()moduletypeSimpleWarnS=sigvalobject_name:stringvalwarning_name_base:stringendmoduleEasy(M:sigincludeValueTypeincludeStateInfoincludeSimpleWarnSend)()=structmoduleI=EasyNoWarn(M)()moduleWInfo=structtypeelt=M.ttypedata=eltUserWarn.with_qfmoduleMap=M.Mapletstage=M.stageletsummary_name=M.summary_name^"-warnings"letwarn=UserWarn.create_depr_and_user_warnings_qf~object_name:M.object_name~warning_name_base:M.warning_name_base~pp_qf:I.prI.pr()endincludeMakeWarned(I)(WInfo)()end(* Global name tables *************************************************)moduleXRefV=structincludeExtRefOrderedletis_var=function|TrueGlobal(VarRefid)->Someid|_->NonemoduleMap=ExtRefMapletstage=Summary.Stage.Interpletsummary_name="xreftab"endmoduleXRefNoWarn=EasyNoWarn(XRefV)()moduleXRefWarn=structtypeelt=extended_global_referencetypedata=eltUserWarn.with_qfmoduleMap=ExtRefMapletpp=XRefNoWarn.prletdepr_ref=Deprecation.create_warning_with_qf~object_name:"Reference"~warning_name_if_no_since:"deprecated-reference"~pp_qf:ppppletdepr_abbrev=Deprecation.create_warning_with_qf~object_name:"Notation"~warning_name_if_no_since:"deprecated-syntactic-definition"~pp_qf:ppppletuser_warn=UserWarn.create_warning~warning_name_if_no_cats:"warn-reference"()letdepr_xref?locdeprxref=matchxrefwith|TrueGlobal_->depr_ref?loc(xref,depr)|Abbrev_->depr_abbrev?loc(xref,depr)letwarn?locxrefuwarns=uwarns.UserWarn.depr_qf|>Option.iter(fundepr->depr_xref?locdeprxref);uwarns.UserWarn.warn_qf|>List.iter(user_warn?loc)letstage=Summary.Stage.Interpletsummary_name="xrefwarntab"endmoduleXRefs=MakeWarned(XRefNoWarn)(XRefWarn)()moduleUnivsV=structincludeUniv.UGloballetis_var_=NonemoduleMap=HMap.Make(Univ.UGlobal)letstage=Summary.Stage.Interpletsummary_name="univtab"endmoduleUnivs=EasyNoWarn(UnivsV)()moduleQualityV=structincludeSorts.QGloballetis_var_=NonemoduleMap=HMap.Make(Sorts.QGlobal)letstage=Summary.Stage.Interpletsummary_name="sorttab"endmoduleQuality=EasyNoWarn(QualityV)()moduleModTypeV=structincludeModPathletis_var_=NonemoduleMap=MPmapletstage=Summary.Stage.Synterpletsummary_name="modtypetab"endmoduleModTypes=EasyNoWarn(ModTypeV)()moduleModuleV=structincludeModPathletis_var_=NonemoduleMap=MPmapletstage=Summary.Stage.Synterpletsummary_name="moduletab"endmoduleModules=EasyNoWarn(ModuleV)()moduleOpenModV=structincludeGlobDirRefletis_var_=NonemoduleMap=Map.Make(GlobDirRef)letstage=Summary.Stage.Synterpletsummary_name="openmodtab"endmoduleOpenMods=EasyNoWarn(OpenModV)()(* Push functions *********************************************************)letpush_abbreviation?user_warnsvisibilityspkn=XRefs.push?wdata:user_warnsvisibilitysp(Abbrevkn)letremove_abbreviationspkn=XRefs.removesp(Abbrevkn)letpush?user_warnsvisspkn=XRefs.push?wdata:user_warnsvissp(TrueGlobalkn)letpush_modtypevisspkn=ModTypes.pushvisspknletpush_modulevisdirmp=Modules.pushvisdirmpletpush_dirvisdirdir_ref=OpenMods.pushvisdirdir_refletpush_universevisspuniv=Univs.pushvisspuniv(* Reverse locate functions ***********************************************)letpath_of_globalref=XRefs.to_path(TrueGlobalref)letdirpath_of_globalref=fst(repr_path(path_of_globalref))letbasename_of_globalref=snd(repr_path(path_of_globalref))letpath_of_abbreviationkn=XRefs.to_path(Abbrevkn)letpath_of_modulemp=Modules.to_pathmpletpath_of_modtypemp=ModTypes.to_pathmpletpath_of_universemp=Univs.to_pathmp(* Shortest qualid functions **********************************************)letshortest_qualid_of_global?locctxref=XRefs.shortest_qualid?locctx(TrueGlobalref)letshortest_qualid_of_abbreviation?locctxkn=XRefs.shortest_qualid?locctx(Abbrevkn)letshortest_qualid_of_module?locmp=Modules.shortest_qualid?locId.Set.emptympletshortest_qualid_of_modtype?lockn=ModTypes.shortest_qualid?locId.Set.emptyknletshortest_qualid_of_dir?locsp=OpenMods.shortest_qualid?locId.Set.emptyspletshortest_qualid_of_universe?locavoidu=Univs.shortest_qualid_gen?loc(funid->Id.Map.memidavoid)uletpr_global_envenvref=trypr_qualid(shortest_qualid_of_globalenvref)withNot_foundasexn->letexn,info=Exninfo.captureexninif!Flags.in_debuggerthenGlobRef.printrefelsebeginlet()=ifCDebug.(get_flagmisc)thenFeedback.msg_debug(Pp.str"pr_global_env not found")inExninfo.iraise(exn,info)endletis_warned_xref=XRefs.is_warnedletwarn_user_warn_xref?locwdatax=XRefs.warn?locxwdataletlocate_extended_nowarnqid=XRefs.locate~nowarn:trueqidletlocate_extendedqid=XRefs.locateqidletlocateqid=matchlocate_extendedqidwith|TrueGlobalref->ref|Abbrev_->raiseNot_foundletlocate_abbreviationqid=matchlocate_extendedqidwith|TrueGlobal_->raiseNot_found|Abbrevkn->knletlocate_modtypeqid=ModTypes.locateqidletfull_name_modtypeqid=ModTypes.to_path(locate_modtypeqid)letlocate_universeqid=Univs.locateqidletlocate_dirqid=OpenMods.locateqidletlocate_moduleqid=Modules.locateqidletfull_name_moduleqid=Modules.to_path(locate_moduleqid)letfull_name_open_modqid=OpenMods.to_path(locate_dirqid)letlocate_sectionqid=matchlocate_dirqidwith|GlobDirRef.DirOpenSectiondir->dir|_->raiseNot_foundletlocate_extended_allqid=XRefs.locate_allqidletlocate_allqid=letl=locate_extended_allqidinCList.filter_map(functionTrueGlobala->Somea|Abbrev_->None)lletlocate_extended_all_dirqid=OpenMods.locate_allqidletlocate_extended_all_modtypeqid=ModTypes.locate_allqidletlocate_extended_all_moduleqid=Modules.locate_allqid(* Completion *)letcompletion_canditatesqualid=XRefs.completion_candidatesqualid(* Derived functions *)letlocate_constantqid=letopenGlobRefinmatchlocate_extendedqidwith|TrueGlobal(ConstRefkn)->kn|_->raiseNot_foundletglobal_of_pathsp=matchXRefs.of_pathspwith|TrueGlobalref->ref|_->raiseNot_foundletextended_global_of_path=XRefs.of_pathletglobalqid=trymatchlocate_extendedqidwith|TrueGlobalref->ref|Abbrev_->CErrors.user_err?loc:qid.CAst.locPp.(str"Unexpected reference to a notation: "++pr_qualidqid++str".")withNot_foundasexn->let_,info=Exninfo.captureexninerror_global_not_found~infoqidletglobal_inductiveqid=letopenGlobRefinmatchglobalqidwith|IndRefind->ind|ref->CErrors.user_err?loc:qid.CAst.locPp.(pr_qualidqid++spc()++str"is not an inductive type.")(* Exists functions ********************************************************)letexists_cci=XRefs.existsletexists_dir=OpenMods.existsletexists_module=Modules.existsletexists_modtype=ModTypes.existsletexists_universe=Univs.exists(* Source locations *)openGlobnamesletcci_loc_table:Loc.tExtRefMap.tref=Summary.ref~name:"constant-loc-table"ExtRefMap.emptyletset_cci_src_locknloc=cci_loc_table:=ExtRefMap.addknloc!cci_loc_tableletcci_src_lockn=ExtRefMap.find_optkn!cci_loc_table