aboutsummaryrefslogtreecommitdiffhomepage
path: root/library/global.ml
diff options
context:
space:
mode:
authorGravatar Pierre-Marie Pédrot <pierre-marie.pedrot@inria.fr>2017-07-10 19:11:20 +0200
committerGravatar Pierre-Marie Pédrot <pierre-marie.pedrot@inria.fr>2017-07-11 14:50:47 +0200
commit012f5fb722a9d5dcef82c800aa54ed50c0a58957 (patch)
treefbe0e3ae6901faba4f14b8cd4dbda019ce9a7829 /library/global.ml
parentb8a7222e670f69e024d50394afd88204e15d1b29 (diff)
Safe API for accessing universe constraints of global references.
Instead of returning either an instance or the set of constraints, we rather return the corresponding abstracted context. We also push back all uses of abstraction-breaking calls from these functions out of the kernel.
Diffstat (limited to 'library/global.ml')
-rw-r--r--library/global.ml48
1 files changed, 24 insertions, 24 deletions
diff --git a/library/global.ml b/library/global.ml
index 8b59c84dd..09c202c50 100644
--- a/library/global.ml
+++ b/library/global.ml
@@ -164,49 +164,49 @@ let type_of_global_unsafe r =
match r with
| VarRef id -> Environ.named_type id env
| ConstRef c ->
- let cb = Environ.lookup_constant c env in
- let univs =
- Declareops.universes_of_polymorphic_constant
- (Environ.opaque_tables env) cb in
- let ty = Typeops.type_of_constant_type env cb.Declarations.const_type in
- Vars.subst_instance_constr (Univ.UContext.instance univs) ty
+ let cb = Environ.lookup_constant c env in
+ let inst = Univ.AUContext.instance (Declareops.constant_polymorphic_context cb) in
+ let ty = Typeops.type_of_constant_type env cb.Declarations.const_type in
+ Vars.subst_instance_constr inst ty
| IndRef ind ->
- let (mib, oib as specif) = Inductive.lookup_mind_specif env ind in
- let inst = Declareops.inductive_polymorphic_instance mib in
- Inductive.type_of_inductive env (specif, inst)
+ let (mib, oib as specif) = Inductive.lookup_mind_specif env ind in
+ let inst = Univ.AUContext.instance (Declareops.inductive_polymorphic_context mib) in
+ Inductive.type_of_inductive env (specif, inst)
| ConstructRef cstr ->
- let (mib,oib as specif) = Inductive.lookup_mind_specif env (inductive_of_constructor cstr) in
- let inst = Declareops.inductive_polymorphic_instance mib in
- Inductive.type_of_constructor (cstr,inst) specif
+ let (mib,oib as specif) = Inductive.lookup_mind_specif env (inductive_of_constructor cstr) in
+ let inst = Univ.AUContext.instance (Declareops.inductive_polymorphic_context mib) in
+ Inductive.type_of_constructor (cstr,inst) specif
let type_of_global_in_context env r =
match r with
| VarRef id -> Environ.named_type id env, Univ.UContext.empty
| ConstRef c ->
- let cb = Environ.lookup_constant c env in
- let univs =
- Declareops.universes_of_polymorphic_constant
- (Environ.opaque_tables env) cb in
- Typeops.type_of_constant_type env cb.Declarations.const_type, univs
+ let cb = Environ.lookup_constant c env in
+ let univs = Declareops.constant_polymorphic_context cb in
+ let inst = Univ.AUContext.instance univs in
+ let univs = Univ.UContext.make (inst, Univ.AUContext.instantiate inst univs) in
+ Typeops.type_of_constant_type env cb.Declarations.const_type, univs
| IndRef ind ->
- let (mib, oib as specif) = Inductive.lookup_mind_specif env ind in
- let univs = Declareops.inductive_polymorphic_context mib in
- Inductive.type_of_inductive env (specif, Univ.UContext.instance univs), univs
+ let (mib, oib as specif) = Inductive.lookup_mind_specif env ind in
+ let univs = Declareops.inductive_polymorphic_context mib in
+ let inst = Univ.AUContext.instance univs in
+ let univs = Univ.UContext.make (inst, Univ.AUContext.instantiate inst univs) in
+ Inductive.type_of_inductive env (specif, inst), univs
| ConstructRef cstr ->
let (mib,oib as specif) =
Inductive.lookup_mind_specif env (inductive_of_constructor cstr)
in
let univs = Declareops.inductive_polymorphic_context mib in
- let inst = Univ.UContext.instance univs in
+ let inst = Univ.AUContext.instance univs in
+ let univs = Univ.UContext.make (inst, Univ.AUContext.instantiate inst univs) in
Inductive.type_of_constructor (cstr,inst) specif, univs
let universes_of_global env r =
match r with
- | VarRef id -> Univ.UContext.empty
+ | VarRef id -> Univ.AUContext.empty
| ConstRef c ->
let cb = Environ.lookup_constant c env in
- Declareops.universes_of_polymorphic_constant
- (Environ.opaque_tables env) cb
+ Declareops.constant_polymorphic_context cb
| IndRef ind ->
let (mib, oib) = Inductive.lookup_mind_specif env ind in
Declareops.inductive_polymorphic_context mib