aboutsummaryrefslogtreecommitdiffhomepage
path: root/pretyping/recordops.ml
diff options
context:
space:
mode:
authorGravatar sacerdot <sacerdot@85f007b7-540e-0410-9357-904b9bb8a0f7>2004-11-16 12:37:40 +0000
committerGravatar sacerdot <sacerdot@85f007b7-540e-0410-9357-904b9bb8a0f7>2004-11-16 12:37:40 +0000
commitd6c204c70c3b89b5bda4e7779cc4a20b5fa3f63f (patch)
treeed4d954a685588ee55f4d8902eba8a1afc864472 /pretyping/recordops.ml
parent08cb37edb71af0301a72acc834d50f24b0733db5 (diff)
IMPORTANT COMMIT: constant is now an ADT (it used to be equal to kernel_name).
MOVITATION: in a forthcoming commit the application of a substitution to a constant will return a constr and not a constant. The application of a substitution to a kernel_name will return a kernel_name. Thus "constant" should be use as a kernel name for references that can be delta-expanded. KNOWN PROBLEMS: the only problem faced is in pretyping/recordops.ml (the code that implements "Canonical Structure"s). The ADT is violated once in this ocaml module. My feeling is that the implementation of "Canonical Structure"s should be rewritten to avoid this situation. git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/coq/trunk@6303 85f007b7-540e-0410-9357-904b9bb8a0f7
Diffstat (limited to 'pretyping/recordops.ml')
-rwxr-xr-xpretyping/recordops.ml23
1 files changed, 17 insertions, 6 deletions
diff --git a/pretyping/recordops.ml b/pretyping/recordops.ml
index 339f76392..6d7921f0d 100755
--- a/pretyping/recordops.ml
+++ b/pretyping/recordops.ml
@@ -34,20 +34,20 @@ type struc_typ = {
s_PROJ : constant option list }
let structure_table = ref (Indmap.empty : struc_typ Indmap.t)
-let projection_table = ref KNmap.empty
+let projection_table = ref Cmap.empty
let option_fold_right f p e = match p with Some a -> f a e | None -> e
let cache_structure (_,(ind,struc)) =
structure_table := Indmap.add ind struc !structure_table;
projection_table :=
- List.fold_right (option_fold_right (fun proj -> KNmap.add proj struc))
+ List.fold_right (option_fold_right (fun proj -> Cmap.add proj struc))
struc.s_PROJ !projection_table
let subst_structure (_,subst,((kn,i),struc as obj)) =
let kn' = subst_kn subst kn in
let proj' = list_smartmap
- (option_smartmap (subst_kn subst))
+ (option_smartmap (subst_con subst))
struc.s_PROJ
in
if proj' == struc.s_PROJ && kn' == kn then obj else
@@ -67,7 +67,7 @@ let add_new_struc (s,c,n,l) =
let find_structure indsp = Indmap.find indsp !structure_table
let find_projection_nparams = function
- | ConstRef cst -> (KNmap.find cst !projection_table).s_PARAM
+ | ConstRef cst -> (Cmap.find cst !projection_table).s_PARAM
| _ -> raise Not_found
(*s Un "object" est une fonction construisant une instance d'une structure *)
@@ -139,12 +139,23 @@ let add_new_objdef (o,c,la,lp,l) =
let cache_objdef1 (_,sp) = ()
-let (inObjDef1,outObjDef1) =
+let (inObjDef10,outObjDef10) =
declare_object {(default_object "OBJDEF1") with
open_function = (fun i o -> if i=1 then cache_objdef1 o);
cache_function = cache_objdef1;
export_function = (function x -> Some x) }
+let outObjDef1 obj = constant_of_kn (outObjDef10 obj)
+
+let inObjDef1 con =
+ (*CSC: Here I am cheating by violating the fact that "constant" is an ADT
+ and this is the only place in the whole Coq code. My feeling is that the
+ implementation of "Canonical Structure"s should be improved to avoid this
+ situation (that is avoided for all the other non-logical objects). *)
+ let mp,sp,l = repr_con con in
+ let kn = make_kn mp sp l in
+ inObjDef10 kn
+
let objdef_info o = List.assoc o !object_table
let freeze () =
@@ -154,7 +165,7 @@ let unfreeze (s,p,o) =
structure_table := s; projection_table := p; object_table := o
let init () =
- structure_table := Indmap.empty; projection_table := KNmap.empty;
+ structure_table := Indmap.empty; projection_table := Cmap.empty;
object_table:=[]
let _ = init()