Safety before Techfest
[SXSI/xpathcomp.git] / ata.ml
diff --git a/ata.ml b/ata.ml
index eed81bc..a5d4a3f 100644 (file)
--- a/ata.ml
+++ b/ata.ml
@@ -531,7 +531,9 @@ let tags_of_state a q =
       external create_empty : int -> bits = "caml_result_set_create"
       external set : bits -> int -> unit = "caml_result_set_set"
       external next : bits -> int -> int = "caml_result_set_next"
+      external count : bits -> int  = "caml_result_set_count"
       external clear : bits -> elt -> elt -> unit = "caml_result_set_clear"
+        
       external set_tag_bits : bits -> Tag.t -> Tree.t -> elt -> elt = "caml_set_tag_bits"
       type t = 
         { segments : elt list;
@@ -589,8 +591,9 @@ let tags_of_state a q =
        in loop (next t.bits 0) acc
 
       let map _ _ = failwith "noop"
-      let length t = let cpt = ref 0 in
-      iter (fun _ -> incr cpt) t; !cpt
+      (*let length t = let cpt = ref 0 in
+      iter (fun _ -> incr cpt) t; !cpt *)
+      let length t = count t.bits 
       
       let clear_bits t = 
        let rec loop l = match l with
@@ -1069,7 +1072,6 @@ END
                   let cont =
                     match f_kind,n_kind with
                       | `NIL,`NIL ->
-                         Printf.eprintf "Using %i\n" (Loc.start_line  __LOCATION__);
                          (fun t _ -> eval_fold2_slist fl_list t (Tree.tag tree t) empty_res empty_res)
                      |  _,`NIL -> (
                            match f_kind with
@@ -1084,16 +1086,10 @@ END
                                if (Algebra.is_rec a s fst) && (Algebra.is_rec a s snd)
                                && (Algebra.is_final_marking a s)
                                then 
-                               let _ = Printf.eprintf "Using %i\n" (Loc.start_line  __LOCATION__) in
                                RS.mk_quick_tag_loop default llist 1 tree tag' 
-                               else 
-                               let _ = Printf.eprintf "Using %i\n" (Loc.start_line  __LOCATION__) in
-                               default
-                               else
-                               let _ = Printf.eprintf "Using %i\n" (Loc.start_line  __LOCATION__) in
-                               default
+                               else default
+                               else default
                             | _ ->
-                                let _ = Printf.eprintf "Using %i\n" (Loc.start_line  __LOCATION__) in  
                                 (fun t _ -> eval_fold2_slist fl_list t (Tree.tag tree t) empty_res
                                   (loop (first t) llist t ))
                         )
@@ -1105,44 +1101,35 @@ END
                                 if t == Tree.nil then empty_res else 
                                 let res2 = loop (next t ctx) ctx in                               
                                 eval_fold2_slist fl_list t tag res2 empty_res            
-                              in Printf.eprintf "Using %i\n" (Loc.start_line  __LOCATION__);loop
+                              in loop
                               else
-                              let _ = Printf.eprintf "Using %i\n" (Loc.start_line  __LOCATION__) in
                                (fun t ctx -> eval_fold2_slist fl_list t (Tree.tag tree t)
                                  (loop_tag tag' (next t ctx) rlist ctx ) empty_res)
                                                                                             
                             | _ ->
-                               let _ = Printf.eprintf "Using %i\n" (Loc.start_line  __LOCATION__) in
                                 (fun t ctx -> eval_fold2_slist fl_list t (Tree.tag tree t)
                                    (loop (next t ctx) rlist ctx ) empty_res)
                        )
                          
                       | `TAG(tag1),`TAG(tag2) ->
-                         let _ = Printf.eprintf "Using %i %s %s\n" (Loc.start_line  __LOCATION__)
-                           (Tag.to_string tag1)
-                         (Tag.to_string tag2) 
-                         in
                           (fun t ctx ->
                             eval_fold2_slist fl_list t (Tree.tag tree t)
                                (loop_tag tag2 (next t ctx) rlist ctx )
                                (loop_tag tag1 (first t) llist t ))
  
                       | `TAG(tag'),`ANY ->
-                         let _ = Printf.eprintf "Using %i\n" (Loc.start_line  __LOCATION__) in
                          (fun t ctx ->
                            eval_fold2_slist fl_list t (Tree.tag tree t)
                               (loop (next t ctx) rlist ctx )
                               (loop_tag tag' (first t) llist t ))
                                                                           
                       | `ANY,`TAG(tag') ->
-                         let _ = Printf.eprintf "Using %i\n" (Loc.start_line  __LOCATION__) in
                           (fun t ctx ->
                             eval_fold2_slist fl_list t (Tree.tag tree t)
                               (loop_tag tag' (next t ctx) rlist ctx )
                               (loop (first t) llist t ))
                                                                   
                       | `ANY,`ANY ->
-                         let _ = Printf.eprintf "Using %i\n" (Loc.start_line  __LOCATION__) in
                          if SList.equal slist rlist && SList.equal slist llist
                          then
                          let rec loop t ctx = 
@@ -1151,17 +1138,13 @@ END
                            and r2 = loop (next t ctx) ctx
                            in
                            eval_fold2_slist fl_list t (Tree.tag tree t) r2 r1
-                         in 
-                         let _ = Printf.eprintf "Using %i\n" (Loc.start_line  __LOCATION__) in
-                         loop
+                         in loop
                          else
-                         let _ = Printf.eprintf "Using %i\n" (Loc.start_line  __LOCATION__) in
                           (fun t ctx ->
                              eval_fold2_slist fl_list t (Tree.tag tree t)
                                (loop (next t ctx) rlist ctx )
                                (loop (first t) llist t ))
                      | _,_ -> 
-                         let _ = Printf.eprintf "Using %i\n" (Loc.start_line  __LOCATION__) in
                          (fun t ctx ->
                              eval_fold2_slist fl_list t (Tree.tag tree t)
                                (loop (next t ctx) rlist ctx )
@@ -1415,7 +1398,7 @@ END
     let top_down_count a t = let module RI = Run(Integer) in Integer.length (RI.run_top_down a t)
     let top_down a t = let module RI = Run(IdSet) in (RI.run_top_down a t)
     let bottom_up_count a t k = let module RI = Run(Integer) in Integer.length (RI.run_bottom_up a t k)
-
+    let bottom_up a t k = let module RI = Run(IdSet) in (RI.run_bottom_up a t k)
 
     module Test (Doc : sig val doc : Tree.t end) =
       struct