]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/software/components/ng_disambiguation/nCicDisambiguate.ml
Useless code removed.
[helm.git] / helm / software / components / ng_disambiguation / nCicDisambiguate.ml
index 03579afabb4091e3b07ae0ab01834faee73bc14a..9e9130857145c2bb84d74eb718c33625f78d0e3b 100644 (file)
@@ -27,7 +27,8 @@ let cic_name_of_name = function
   | _ -> assert false
 ;;
 
-let refine_term metasenv subst context uri ~use_coercions:_ term _ ~localization_tbl =
+let refine_term 
+ metasenv subst context uri ~coercion_db ~use_coercions term _ ~localization_tbl=
   assert (uri=None);
   debug_print (lazy (sprintf "TEST_INTERPRETATION: %s" 
     (NCicPp.ppterm ~metasenv ~subst ~context term)));
@@ -39,7 +40,12 @@ let refine_term metasenv subst context uri ~use_coercions:_ term _ ~localization
         assert false
     in
     let metasenv, subst, term, _ = 
-      NCicRefiner.typeof metasenv subst context term None ~localise 
+      NCicRefiner.typeof 
+        ~look_for_coercion:(
+          if use_coercions then 
+           NCicCoercion.look_for_coercion coercion_db
+          else (fun _ _ _ _ _ -> []))
+        metasenv subst context term None ~localise 
     in
      Disambiguate.Ok (term, metasenv, subst, ())
   with
@@ -75,8 +81,9 @@ let interpretate_term
     match t with
     | CicNotationPt.AttributedTerm (`Loc loc, term) ->
         let res = aux ~localize loc context term in
-         if localize then NCicUntrusted.NCicHash.add localization_tbl res loc;
-         res
+        if localize then 
+         NCicUntrusted.NCicHash.add localization_tbl res loc;
+       res
     | CicNotationPt.AttributedTerm (_, term) -> aux ~localize loc context term
     | CicNotationPt.Appl (CicNotationPt.Symbol (symb, i) :: args) ->
         let cic_args = List.map (aux ~localize loc context) args in
@@ -180,7 +187,7 @@ let interpretate_term
            List.nth itl indtyp_no
           with _ -> assert false in
          let rec count_prod t =
-           match NCicReduction.whd [] t with
+                 match NCicReduction.whd ~subst:[] [] t with
                NCic.Prod (_, _, t) -> 1 + (count_prod t)
              | _ -> 0 
          in 
@@ -400,14 +407,14 @@ patterns not implemented *)
     | _ -> assert false (* god bless Bologna *)
 
             in
-            prerr_endline (NCicPp.ppterm ~metasenv:[] ~context:[] ~subst:[]
-              res);
+(*             prerr_endline (NCicPp.ppterm ~metasenv:[] ~context:[] ~subst:[] res); *)
             res
   and aux_option ~localize loc context annotation = function
     | None -> NCic.Implicit annotation
     | Some (CicNotationPt.AttributedTerm (`Loc loc, term)) ->
         let res = aux_option ~localize loc context annotation (Some term) in
-        if localize then NCicUntrusted.NCicHash.add localization_tbl res loc;
+        if localize then 
+          NCicUntrusted.NCicHash.add localization_tbl res loc;
         res
     | Some (CicNotationPt.AttributedTerm (_, term)) ->
         aux_option ~localize loc context annotation (Some term)
@@ -424,16 +431,12 @@ let interpretate_term ?(create_dummy_ids=false) ~context ~env ~uri ~is_path ast
 ~localization_tbl
 ;;
 
-let domain_of_term ~context = 
-  Disambiguate.domain_of_ast_term ~context
-;; 
-
 let disambiguate_term ~context ~metasenv ~subst ?goal
    ~mk_implicit ~description_of_alias ~mk_choice
-   ~aliases ~universe ~lookup_in_library 
+   ~aliases ~universe ~coercion_db ~lookup_in_library 
    (text,prefix_len,term) 
  =
-  let localization_tbl = NCicUntrusted.NCicHash.create 503 in
+  let mk_localization_tbl x = NCicUntrusted.NCicHash.create x in
   let hint =
    match goal with
       None -> (fun _ y -> y),(fun x -> x)
@@ -456,10 +459,10 @@ let disambiguate_term ~context ~metasenv ~subst ?goal
      ~string_context_of_context:(List.map (fun (x,_) -> Some x))
      ~universe ~uri:None ~pp_thing:CicNotationPp.pp_term
      ~passes:(MultiPassDisambiguator.passes ())
-     ~lookup_in_library ~domain_of_thing:domain_of_term
+     ~lookup_in_library ~domain_of_thing:Disambiguate.domain_of_term
      ~interpretate_thing:(interpretate_term ~mk_choice (?create_dummy_ids:None))
-     ~refine_thing:refine_term (text,prefix_len,term)
-     ~localization_tbl ~hint ~subst
+     ~refine_thing:(refine_term ~coercion_db) (text,prefix_len,term)
+     ~mk_localization_tbl ~hint ~subst
    in
     List.map (function (a,b,c,d,_) -> a,b,c,d) res, b
 ;;