(* $Id$ *)
+let debug = ref false;;
+let indent = ref "";;
+let times = ref [];;
+let pp s =
+ if !debug then
+ prerr_endline (Printf.sprintf "%-20s" !indent ^ " " ^ Lazy.force s)
+;;
+let inside c =
+ if !debug then
+ begin
+ let time1 = Unix.gettimeofday () in
+ indent := !indent ^ String.make 1 c;
+ times := time1 :: !times;
+ prerr_endline ("{{{" ^ !indent ^ " ")
+ end
+;;
+let outside exc_opt =
+ if !debug then
+ begin
+ let time2 = Unix.gettimeofday () in
+ let time1 =
+ match !times with time1::tl -> times := tl; time1 | [] -> assert false in
+ prerr_endline ("}}} " ^ string_of_float (time2 -. time1));
+ (match exc_opt with
+ | Some e -> prerr_endline ("exception raised: " ^ Printexc.to_string e)
+ | None -> ());
+ try
+ indent := String.sub !indent 0 (String.length !indent -1)
+ with
+ Invalid_argument _ -> indent := "??"; ()
+ end
+;;
+
exception MetaSubstFailure of string Lazy.t
exception Uncertain of string Lazy.t
otherwise the occur check does not make sense in case of unification
of ?n with ?n *)
let delift ~unify metasenv subst context n l t =
+ (*D*) inside 'D'; try let rc =
let is_in_scope_meta subst = function
| NCic.Meta (i,_) ->
(try
| NotInTheList | MetaSubstFailure _ -> ms, j::tbr, tl
in
let (metasenv, subst), to_be_r, lc1' = deliftl [] 1 ms lc1 in
-(*
- prerr_endline ("TO BE RESTRICTED: " ^
- (String.concat "," (List.map string_of_int to_be_r)));
-*)
+ pp (lazy ("TO BE RESTRICTED: " ^
+ (String.concat "," (List.map string_of_int to_be_r))));
let l1 = pack_lc (0, NCic.Ctx lc1') in
-(*
- prerr_endline ("newmeta:" ^ NCicPp.ppterm
- ~metasenv ~subst ~context (NCic.Meta (999,l1)));
-*)
+ pp (lazy ("newmeta:" ^ NCicPp.ppterm
+ ~metasenv ~subst ~context (NCic.Meta (999,l1))));
+ pp (lazy (NCicPp.ppmetasenv ~subst metasenv));
if to_be_r = [] then
(metasenv, subst),
(if lc1' = lc1 then orig else NCic.Meta (i,l1))
raise (Uncertain msg)
else
raise (MetaSubstFailure msg)
+ (*D*) in outside None; rc with exn -> outside (Some exn); raise exn
;;
let mk_meta ?(attrs=[]) metasenv context ?with_type kind =
(fun mi () -> NTacStatus.debug := mi#active);
addDebugCheckbox "auto logging"
(fun mi () -> NAuto.debug := mi#active);
- addDebugCheckbox "disambiguation/refiner/unification logging"
+ addDebugCheckbox "disambiguation/refiner/unification/metasubst logging"
(fun mi () -> NCicRefiner.debug := mi#active; NCicUnification.debug :=
- mi#active; MultiPassDisambiguator.debug := mi#active);
+ mi#active; MultiPassDisambiguator.debug := mi#active; NCicMetaSubst.debug := mi#active);
addDebugCheckbox "reduction logging"
(fun mi () -> NCicReduction.debug := mi#active; CicReduction.ndebug := mi#active);
addDebugSeparator ();