]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/software/lambda-delta/toplevel/metaAut.ml
- common/entity: new format for kernel entities
[helm.git] / helm / software / lambda-delta / toplevel / metaAut.ml
index db18ade47742dfd95b63d041bdf59a49d71d750d..75aaa71e6508d61949795300082bfb0b0afe9225 100644 (file)
 
 module U = NUri
 module H = U.UriHash
+module C = Cps
+module Y = Entity
 module M = Meta
 module A = Aut
 
 (* qualified identifier: uri, name, qualifiers *)
-type qid = U.uri * M.id * M.id list
+type qid = M.uri * M.id * M.id list
 
 type environment = M.pars H.t
 
@@ -34,13 +36,13 @@ type status = {
 type resolver = Local of int
               | Global of M.pars
 
-let hsize = 7000 (* hash tables initial size *)
+let henv_size, hcnt_size = 7000, 4300 (* hash tables initial sizes *)
 
 (* Internal functions *******************************************************)
 
-let initial_status size cover = {
+let initial_status cover = {
    path = []; node = None; nodes = []; line = 1; cover = cover;
-   henv = H.create size; hcnt = H.create size
+   henv = H.create henv_size; hcnt = H.create hcnt_size
 }
 
 let id_of_name (id, _, _) = id
@@ -55,7 +57,7 @@ let uri_of_qid (uri, _, _) = uri
 
 let complete_qid f st (id, is_local, qs) =
    let f qs = f (mk_qid st id qs) in
-   let f path = Cps.list_rev_append f path ~tail:qs in
+   let f path = C.list_rev_append f path ~tail:qs in
    let rec skip f = function
       | phd :: ptl, qshd :: _ when phd = qshd -> f ptl
       | _ :: ptl, _ :: _                      -> skip f (ptl, qs)
@@ -66,10 +68,10 @@ let complete_qid f st (id, is_local, qs) =
 let relax_qid f st (_, id, path) =
    let f path = f (mk_qid st id path) in
    let f = function
-      | _ :: tl -> Cps.list_rev f tl
+      | _ :: tl -> C.list_rev f tl
       | []      -> assert false
    in
-   Cps.list_rev f path
+   C.list_rev f path
 
 let relax_opt_qid f st = function
    | None     -> f None
@@ -133,10 +135,10 @@ let rec xlate_term f st lenv = function
         let map2 f (id, _) = resolve_lref_strict f st l lenv id in
          let f tail = 
            let f args = f (M.GRef (l, uri_of_qid qid, args)) in
-            let f defs = Cps.list_rev_map_append f map2 defs ~tail in
-           Cps.list_sub_strict f defs args
+            let f defs = C.list_rev_map_append f map2 defs ~tail in
+           C.list_sub_strict f defs args
         in   
-        Cps.list_map f map1 args
+        C.list_map f map1 args
       in
       let g qid = resolve_gref_relaxed g st qid in
       let f = function
@@ -145,26 +147,26 @@ let rec xlate_term f st lenv = function
       in
       resolve_lref f st l lenv (id_of_name name)
 
-let xlate_entity f st = function
+let xlate_entity err f st = function
    | A.Section (Some (_, name))     ->
-      f {st with path = name :: st.path; nodes = st.node :: st.nodes} None
+      err {st with path = name :: st.path; nodes = st.node :: st.nodes}
    | A.Section None            ->
       begin match st.path, st.nodes with
         | _ :: ptl, nhd :: ntl -> 
-           f {st with path = ptl; node = nhd; nodes = ntl} None
+           err {st with path = ptl; node = nhd; nodes = ntl}
          | _                    -> assert false
       end
    | A.Context None            ->
-      f {st with node = None} None
+      err {st with node = None}
    | A.Context (Some name)     ->
-      let f name = f {st with node = Some name} None in
+      let f name = err {st with node = Some name} in
       complete_qid f st name 
    | A.Block (name, w)         ->
       let f qid = 
          let f pars =
            let f ww = 
               H.add st.hcnt (uri_of_qid qid) ((name, ww) :: pars);
-              f {st with node = Some qid} None
+              err {st with node = Some qid}
            in
             xlate_term f st pars w
         in
@@ -175,9 +177,11 @@ let xlate_entity f st = function
       let f pars = 
          let f qid = 
             let f ww =
-              let entry = (st.line, pars, uri_of_qid qid, ww, None) in
               H.add st.henv (uri_of_qid qid) pars;
-              f {st with line = succ st.line} (Some entry)
+              let a = [Y.Mark st.line] in
+              let entry = pars, ww, None in
+              let entity = a, uri_of_qid qid, Y.Abst entry in
+              f {st with line = succ st.line} entity
            in
            xlate_term f st pars w
         in
@@ -188,9 +192,11 @@ let xlate_entity f st = function
       let f pars = 
          let f qid = 
             let f ww vv = 
-              let entry = (st.line, pars, uri_of_qid qid, ww, Some (trans, vv)) in
               H.add st.henv (uri_of_qid qid) pars;
-              f {st with line = succ st.line} (Some entry)
+              let a = Y.Mark st.line :: if trans then [] else [Y.Priv] in 
+              let entry = pars, ww, Some vv in
+              let entity = a, uri_of_qid qid, Y.Abbr entry in
+              f {st with line = succ st.line} entity
            in
            let f ww = xlate_term (f ww) st pars v in
            xlate_term f st pars w
@@ -202,6 +208,6 @@ let xlate_entity f st = function
 (* Interface functions ******************************************************)
 
 let initial_status ?(cover="") () =
-   initial_status hsize cover
+   initial_status cover
 
 let meta_of_aut = xlate_entity