]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/matita/matitaScript.ml
fixed a finalization issue for connections closed twice
[helm.git] / helm / matita / matitaScript.ml
index 987e60560d8bc9b4c0f741b5693b20df78684778..8bd0d60d1f2df270cdfcb582778fcd2b564aef40 100644 (file)
@@ -57,7 +57,7 @@ let first_line s =
   (** creates a statement AST for the Goal tactic, e.g. "goal 7" *)
 let goal_ast n =
   let module A = GrafiteAst in
-  let loc = Disambiguate.dummy_floc in
+  let loc = DisambiguateTypes.dummy_floc in
   A.Executable (loc, A.Tactical (loc, A.Tactic (loc, A.Goal (loc, n))))
 
 type guistuff = {
@@ -109,14 +109,16 @@ let eval_with_engine guistuff status user_goal parsed_text st =
   let new_aliases =
     match ex with
       | TA.Command (_, TA.Alias _)
-      | TA.Command (_, TA.Include _) -> DisambiguateTypes.Environment.empty
+      | TA.Command (_, TA.Include _)
+      | TA.Command (_, TA.Interpretation _) ->
+          DisambiguateTypes.Environment.empty
       | _ -> MatitaSync.alias_diff ~from:status new_status
   in
   (* we remove the defined object since we consider them "automatic aliases" *)
   let initial_space,status,new_status_and_text_list_rev = 
     let module DTE = DisambiguateTypes.Environment in
     let module UM = UriManager in
-    DTE.fold (
+    DTE.fold_flatten (
       fun k ((v,_) as value) (initial_space,status,acc) -> 
         let b = 
           try
@@ -131,9 +133,9 @@ let eval_with_engine guistuff status user_goal parsed_text st =
           let initial_space =
            if initial_space = "" then "\n" else initial_space in
             initial_space ^
-             DisambiguatePp.pp_environment(DTE.add k value DTE.empty) in
+             DisambiguatePp.pp_environment(DTE.cons k value DTE.empty) in
          let new_status =
-          {status with aliases = DTE.add k value status.aliases}
+          {status with aliases = DTE.cons k value status.aliases}
          in
           "\n",new_status,((new_status, new_text)::acc)
     ) new_aliases (initial_space,status,[]) in
@@ -207,7 +209,7 @@ let disambiguate term status =
   let aliases = MatitaMisc.get_proof_aliases status in
   let interps = MD.disambiguate_term dbd context metasenv aliases term in
   match interps with 
-  | [_,_,x,_] -> x
+  | [_,_,x,_], _ -> x
   | _ -> assert false
  
 let eval_macro guistuff status unparsed_text parsed_text script mac =
@@ -299,7 +301,7 @@ let eval_macro guistuff status unparsed_text parsed_text script mac =
       in
       let _, metasenv , term, ugraph =
         match interps with 
-        | [x] -> x
+        | [x], _ -> x
         | _ -> assert false
       in
       let ty,_ = CTC.type_of_aux' metasenv context term ugraph in
@@ -447,7 +449,7 @@ object (self)
     
   method private ppFilename =
     match guistuff.filenamedata with 
-    | Some f,_ -> f 
+    | Some f,_ -> Filename.basename 
     | None,_ -> sprintf ".unnamed%d.ma" scriptId
   
   initializer 
@@ -584,7 +586,7 @@ object (self)
 
   method loadFromFile f =
     buffer#set_text (MatitaMisc.input_file f);
-    self#goto_top;
+    self#reset_buffer;
     buffer#set_modified false
     
   method assignFileName file =
@@ -611,21 +613,23 @@ object (self)
       end
   
   method private goto_top =
-    MatitaSync.time_travel ~present:self#status ~past:init;
+    MatitaSync.time_travel ~present:self#status ~past:init
+
+  method private reset_buffer = 
     statements <- [];
     history <- [ init ];
     userGoal <- ~-1;
+    self#notify;
     buffer#remove_tag locked_tag ~start:buffer#start_iter ~stop:buffer#end_iter;
     buffer#move_mark (`MARK locked_mark) ~where:buffer#start_iter
 
   method reset () =
-    self#goto_top;
+    self#reset_buffer;
     source_buffer#begin_not_undoable_action ();
     buffer#delete ~start:buffer#start_iter ~stop:buffer#end_iter;
     source_buffer#end_not_undoable_action ();
-    self#notify;
     buffer#set_modified false
-
+  
   method template () =
     let template = MatitaMisc.input_file BuildTimeConf.script_template in 
     buffer#insert ~iter:(buffer#get_iter `START) template;
@@ -643,7 +647,11 @@ object (self)
     let getoldpos _ = buffer#get_iter_at_mark old_locked_mark in 
     let dispose_old_locked_mark () = buffer#delete_mark old_locked_mark in
     match pos with
-    | `Top -> dispose_old_locked_mark (); self#goto_top; self#notify
+    | `Top -> 
+        dispose_old_locked_mark (); 
+        self#goto_top; 
+        self#reset_buffer;
+        self#notify
     | `Bottom ->
         (try 
           let rec dowhile () =