]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/software/lambda-delta/toplevel/metaAut.ml
fixed a bug, it used to report o wrong is_normal bit in case of match
[helm.git] / helm / software / lambda-delta / toplevel / metaAut.ml
index 767a44afb4c8b313c744f6976f366ac976771e76..7e18bd1e5332d7a64fec80ef1004198612eb56ea 100644 (file)
@@ -1,36 +1,23 @@
-(* Copyright (C) 2000, HELM Team.
- * 
- * This file is part of HELM, an Hypertextual, Electronic
- * Library of Mathematics, developed at the Computer Science
- * Department, University of Bologna, Italy.
- * 
- * HELM is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- * 
- * HELM is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with HELM; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
- * MA  02111-1307, USA.
- * 
- * For details, see the HELM World-Wide-Web page,
- * http://cs.unibo.it/helm/.
- *)
-
-module H = Hashtbl
+(*
+    ||M||  This file is part of HELM, an Hypertextual, Electronic        
+    ||A||  Library of Mathematics, developed at the Computer Science     
+    ||T||  Department, University of Bologna, Italy.                     
+    ||I||                                                                
+    ||T||  HELM is free software; you can redistribute it and/or         
+    ||A||  modify it under the terms of the GNU General Public License   
+    \   /  version 2 or (at your option) any later version.              
+     \ /   This software is distributed as is, NO WARRANTY.              
+      V_______________________________________________________________ *)
+
 module U = NUri
+module H = U.UriHash
 module M = Meta
 module A = Aut
 
-type qid = M.id * M.id list (* qualified identifier: name, qualifiers *)
+(* qualified identifier: uri, name, qualifiers *)
+type qid = U.uri * M.id * M.id list
 
-type environment = (qid, M.pars) H.t
+type environment = M.pars H.t
 
 type context_node = qid option (* context node: None = root *)
 
@@ -47,7 +34,7 @@ type status = {
 type resolver = Local of int
               | Global of M.pars
 
-let hsize = 11 (* hash tables initial size *)
+let hsize = 7000 (* hash tables initial size *)
 
 (* Internal functions *******************************************************)
 
@@ -58,13 +45,15 @@ let initial_status size = {
 
 let id_of_name (id, _, _) = id
 
-let uri_of_qid (id, path) =
-   let path = String.concat "/" path in
-   let str = Filename.concat path id in
-   U.uri_of_string ("ld:/" ^ str)
+let mk_qid id path =
+   let str = String.concat "/" path in
+   let str = Filename.concat str id in
+   U.uri_of_string ("ld:/" ^ str), id, path
+
+let uri_of_qid (uri, _, _) = uri
 
 let complete_qid f st (id, is_local, qs) =
-   let f qs = f (id, qs) in
+   let f qs = f (mk_qid id qs) in
    let f path = Cps.list_rev_append f path ~tail:qs in
    let rec skip f = function
       | phd :: ptl, qshd :: _ when phd = qshd -> f ptl
@@ -73,8 +62,8 @@ let complete_qid f st (id, is_local, qs) =
    in
    if is_local then f st.path else skip f (st.path, qs)
 
-let relax_qid f (id, path) =
-   let f path = f (id, path) in
+let relax_qid f (_, id, path) =
+   let f path = f (mk_qid id path) in
    let f = function
       | _ :: tl -> Cps.list_rev f tl
       | []      -> assert false
@@ -101,7 +90,7 @@ let resolve_lref_strict f st l lenv id =
    resolve_lref f st l lenv id
 
 let resolve_gref f st qid =
-   try let args = H.find st.henv qid in f qid (Some args)
+   try let args = H.find st.henv (uri_of_qid qid) in f qid (Some args)
    with Not_found -> f qid None
 
 let resolve_gref_relaxed f st qid =
@@ -113,8 +102,8 @@ let resolve_gref_relaxed f st qid =
 
 let get_pars f st = function
    | None              -> f [] None
-   | Some name as node ->
-      try let pars = H.find st.hcnt name in f pars None
+   | Some qid as node ->
+      try let pars = H.find st.hcnt (uri_of_qid qid) in f pars None
       with Not_found -> f [] (Some node)
 
 let get_pars_relaxed f st =
@@ -173,7 +162,7 @@ let xlate_item f st = function
       let f qid = 
          let f pars =
            let f ww = 
-              H.add st.hcnt qid ((name, ww) :: pars);
+              H.add st.hcnt (uri_of_qid qid) ((name, ww) :: pars);
               f {st with node = Some qid} None
            in
             xlate_term f st pars w
@@ -186,7 +175,7 @@ let xlate_item f st = function
          let f qid = 
             let f ww =
               let entry = (st.line, pars, uri_of_qid qid, ww, None) in
-              H.add st.henv qid pars;
+              H.add st.henv (uri_of_qid qid) pars;
               f {st with line = succ st.line} (Some entry)
            in
            xlate_term f st pars w
@@ -199,7 +188,7 @@ let xlate_item f st = function
          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 qid pars;
+              H.add st.henv (uri_of_qid qid) pars;
               f {st with line = succ st.line} (Some entry)
            in
            let f ww = xlate_term (f ww) st pars v in