From 44ccb088991b937c54cbe13f0a135e36da9d5d8d Mon Sep 17 00:00:00 2001 From: Claudio Sacerdoti Coen Date: Sat, 19 Apr 2008 10:52:50 +0000 Subject: [PATCH] Added to flags to activate/disactivate pretty-printing and exception catching. --- helm/software/components/ng_kernel/check.ml | 74 ++++++++++++--------- 1 file changed, 42 insertions(+), 32 deletions(-) diff --git a/helm/software/components/ng_kernel/check.ml b/helm/software/components/ng_kernel/check.ml index cbb451bb3..2540e408e 100644 --- a/helm/software/components/ng_kernel/check.ml +++ b/helm/software/components/ng_kernel/check.ml @@ -1,16 +1,24 @@ -let _ = - let indent = ref 0 in -(* let do_indent () = String.make !indent ' ' in *) - NCicTypeChecker.set_logger +let debug = false +let ignore_exc = false + +let indent = ref 0;; + +let logger = + let do_indent () = String.make !indent ' ' in (function | `Start_type_checking s -> (); -(* prerr_endline (do_indent () ^ "Start: " ^ NUri.string_of_uri s); *) + if debug then + prerr_endline (do_indent () ^ "Start: " ^ NUri.string_of_uri s); incr indent | `Type_checking_completed s -> (); decr indent; -(* prerr_endline (do_indent () ^ "End: " ^ NUri.string_of_uri s) *) - ); + if debug then + prerr_endline (do_indent () ^ "End: " ^ NUri.string_of_uri s)) +;; + +let _ = + NCicTypeChecker.set_logger logger; NCicPp.set_ppterm NCicPp.trivial_pp_term; Helm_registry.load_from "conf.xml"; let alluris = @@ -46,30 +54,32 @@ let _ = in let who_uses u = uniq (List.map (fun (uri,_) -> UriManager.strip_xpointer uri) - (MetadataDeps.inverse_deps ~dbd u)) - in + (MetadataDeps.inverse_deps ~dbd u)) in let roots_alluris = - let rec fix acc l = - let acc, todo = - List.fold_left (fun (acc,todo) x -> - let w = who_uses x in - if w = [] then (x::acc,todo) else (acc,uniq (todo@w))) - (acc,[]) l - in - if todo = [] then uniq acc else fix acc todo - in - (fix [] alluris) + let rec fix acc l = + let acc, todo = + List.fold_left (fun (acc,todo) x -> + let w = who_uses x in + if w = [] then (x::acc,todo) else (acc,uniq (todo@w))) + (acc,[]) l + in + if todo = [] then uniq acc else fix acc todo + in + (fix [] alluris) in +(* + BARO! + let roots_alluris = alluris in *) prerr_endline "generating Coq graphs..."; CicEnvironment.set_trust (fun _ -> false); List.iter (fun u -> - prerr_endline (" - " ^ UriManager.string_of_uri u); - try - ignore(CicTypeChecker.typecheck u); - with - | CicTypeChecker.AssertFailure s - | CicTypeChecker.TypeCheckerFailure s -> prerr_endline (Lazy.force s) - ) roots_alluris; + prerr_endline (" - " ^ UriManager.string_of_uri u); + try + ignore(CicTypeChecker.typecheck u); + with + | CicTypeChecker.AssertFailure s + | CicTypeChecker.TypeCheckerFailure s -> prerr_endline (Lazy.force s) + ) roots_alluris; prerr_endline "loading..."; List.iter (fun u -> @@ -84,24 +94,24 @@ let _ = List.iter (fun uu -> let uu= NUri.nuri_of_ouri uu in indent := 0; -(* prerr_endline ("************* INIZIO **************** " ^ NUri.string_of_uri uu); *) + logger (`Start_type_checking uu); let _,o = NCicEnvironment.get_obj uu in -(* prerr_endline (NCicPp.ppobj o); *) try NCicTypeChecker.typecheck_obj o; -(* prerr_endline ("************* FINE ****************" ^ NUri.string_of_uri uu); *) + logger (`Type_checking_completed uu); with | NCicTypeChecker.AssertFailure s | NCicTypeChecker.TypeCheckerFailure s as e -> -(* prerr_endline ("Obj: " ^ NCicPp.ppobj o); *) - prerr_endline ("######### " ^ Lazy.force s); raise e + prerr_endline ("######### " ^ Lazy.force s); + if not ignore_exc then raise e | CicEnvironment.Object_not_found s -> - prerr_endline ("Obj not found: " ^ UriManager.string_of_uri s); + prerr_endline ("Obj not found: " ^ UriManager.string_of_uri s) ) alluris; NCicEnvironment.invalidate (); Gc.compact (); HExtlib.profiling_enabled := true; + NCicTypeChecker.set_logger (fun _ -> ()); prerr_endline "typechecking, first with the new and then with the old kernel"; let prima = Unix.gettimeofday () in List.iter -- 2.39.2