Release coccinelle-0.1.2
[bpt/coccinelle.git] / engine / ctlcocci_integration.ml
index 2b6c75f..1c04b18 100644 (file)
@@ -30,7 +30,7 @@ module F = Control_flow_c
 (* Debugging functions *)
 (*****************************************************************************)
 let show_or_not_predicate pred = 
-  if !Flag_engine.debug_engine then begin 
+  if !Flag_matcher.debug_engine then begin 
     indent_do (fun () -> 
       adjust_pp_with_indent_and_header "labeling: pred = " (fun () -> 
         Pretty_print_engine.pp_predicate pred;
@@ -39,7 +39,7 @@ let show_or_not_predicate pred =
   end
 
 let show_or_not_nodes nodes =
-  if !Flag_engine.debug_engine  then begin 
+  if !Flag_matcher.debug_engine  then begin 
     indent_do (fun () -> 
       adjust_pp_with_indent_and_header "labeling: result = " (fun () -> 
         Common.pp_do_in_box (fun () -> 
@@ -116,7 +116,7 @@ let (labels_for_ctl: string list (* dropped isos *) ->
 
       | Lib_engine.Match (re), _unwrapnode -> 
           let substs = 
-            Pattern3.match_re_node dropped_isos re node binding
+            Pattern_c.match_re_node dropped_isos re node binding
             +> List.map (fun (re', subst) -> 
               Lib_engine.Match (re'), subst
             )
@@ -327,7 +327,7 @@ module ENV =
 
 module CFG = 
   struct
-    type node = int
+    type node = Ograph_extended.nodei
     type cfg = (F.node, F.edge) Ograph_extended.ograph_mutable
     let predecessors cfg n = List.map fst ((cfg#predecessors n)#tolist)
     let successors   cfg n = List.map fst ((cfg#successors n)#tolist)
@@ -335,6 +335,24 @@ module CFG =
       Control_flow_c.extract_is_loop (cfg#nodes#find n)
     let print_node i = Format.print_string (i_to_s i)
     let size cfg = cfg#nodes#length
+
+    (* In ctl_engine, we use 'node' for the node but in the Ograph_extended 
+     * terminology, this 'node' is in fact an index to access the real
+     * node information (that ctl/ wants to abstract away to be more generic),
+     * the 'Ograph_extended.nodei'.
+     *)
+    let print_graph cfg label border_colors fill_colors filename = 
+      Ograph_extended.print_ograph_mutable_generic cfg label
+        (fun (nodei, (node: F.node)) -> 
+          (* the string julia wants to put ? *)
+          let bc = try Some(List.assoc nodei border_colors) with _ -> None in
+          let fc = try Some(List.assoc nodei fill_colors) with _ -> None in
+          (* the string yoann put as debug information in the cfg *)
+          let str = snd node in
+          (str,bc,fc)
+        )
+        ~output_file:filename
+        ~launch_gv:false
   end
 
 
@@ -408,7 +426,7 @@ let (mysat2:
       WRAPPED_ENGINE.satbis (flow, label, states) ctl (used_after, binding2)
     in
     if not (!Flag_parsing_cocci.sgrep_mode || !Flag.sgrep_mode2 ||
-            !Flag_engine.allow_inconsistent_paths)
+            !Flag_matcher.allow_inconsistent_paths)
     then Check_reachability.check_reachability triples flow;
     let (trans_info2,used_after_fresh_envs) =
       Postprocess_transinfo.process used_after binding2 trans_info2 in