aboutsummaryrefslogtreecommitdiffhomepage
path: root/library/global.ml
diff options
context:
space:
mode:
authorGravatar Pierre-Marie Pédrot <pierre-marie.pedrot@inria.fr>2017-07-11 15:42:43 +0200
committerGravatar Pierre-Marie Pédrot <pierre-marie.pedrot@inria.fr>2017-07-11 15:54:46 +0200
commit91df402729f70144a4e4d198c4384dc515920e59 (patch)
treec750afbc9119b7da597235bb62432ff42c871e25 /library/global.ml
parentc401fc96c3271746448600ca097876bd139b10e9 (diff)
Moving the last bits of abtraction-breaking code out of the kernel.
Diffstat (limited to 'library/global.ml')
-rw-r--r--library/global.ml17
1 files changed, 16 insertions, 1 deletions
diff --git a/library/global.ml b/library/global.ml
index 09c202c50..e90151bff 100644
--- a/library/global.ml
+++ b/library/global.ml
@@ -122,7 +122,22 @@ let lookup_modtype kn = lookup_modtype kn (env())
let exists_objlabel id = Safe_typing.exists_objlabel id (safe_env ())
let opaque_tables () = Environ.opaque_tables (env ())
-let body_of_constant_body cb = Declareops.body_of_constant (opaque_tables ()) cb
+
+let instantiate cb c =
+ let open Declarations in
+ match cb.const_universes with
+ | Monomorphic_const _ -> c
+ | Polymorphic_const ctx ->
+ Vars.subst_instance_constr (Univ.AUContext.instance ctx) c
+
+let body_of_constant_body cb =
+ let open Declarations in
+ let otab = opaque_tables () in
+ match cb.const_body with
+ | Undef _ -> None
+ | Def c -> Some (instantiate cb (Mod_subst.force_constr c))
+ | OpaqueDef o -> Some (instantiate cb (Opaqueproof.force_proof otab o))
+
let body_of_constant cst = body_of_constant_body (lookup_constant cst)
(** Operations on kernel names *)