12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455(************************************************************************)(* * The Coq Proof Assistant / The Coq 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) *)(************************************************************************)openNamesletdeclareidentry=let_:Constant.t=Declare.declare_constant~name:id~kind:Decls.IsPrimitive(Declare.PrimitiveEntryentry)inFlags.if_verboseFeedback.msg_infoPp.(Id.printid++str" is declared")letdo_primitiveidudeclprimtypopt=ifLib.sections_are_opened()thenCErrors.user_errPp.(str"Declaring a primitive is not allowed in sections.");ifDumpglob.dump()thenDumpglob.dump_definitionidfalse"ax";letloc=id.CAst.locinletid=id.CAst.vinmatchtypoptwith|None->ifOption.has_someudeclthenCErrors.user_err?locPp.(strbrk"Cannot use a universe declaration without a type when declaring primitives.");lete=Declare.primitive_entryprimindeclareide|Sometyp->letenv=Global.env()inletevd,udecl=Constrintern.interp_univ_decl_optenvudeclinletauctx=CPrimitives.op_or_type_univspriminletevd,u=Evd.with_sort_context_setUState.univ_flexibleevd(UnivGen.fresh_instanceauctx)inletexpected_typ=EConstr.of_constr@@Typeops.type_of_prim_or_typeenvupriminletevd,(typ,impls)=Constrintern.(interp_type_evars_impls~impls:empty_internalization_env)envevdtypinletevd=tryEvarconv.unify_delayenvevdtypexpected_typwithEvarconv.UnableToUnify(evd,e)asexn->let_,info=Exninfo.captureexninExninfo.iraise(Pretype_errors.(PretypeError(env,evd,CannotUnify(typ,expected_typ,Somee)),info))inPretyping.check_evars_are_solved~program_mode:falseenvevd;letevd=Evd.minimize_universesevdinlet_qvars,uvars=EConstr.universes_of_constrevdtypinletevd=Evd.restrict_universe_contextevduvarsinlettyp=EConstr.to_constrevdtypinletuniv_entry=Evd.check_univ_decl~poly:(not(UVars.AbstractContext.is_emptyauctx))evdudeclinletentry=Declare.primitive_entry~types:(typ,univ_entry)primindeclareidentry