Release coccinelle-0.2.0
[bpt/coccinelle.git] / parsing_cocci / unitary_ast0.ml
index 4002eb9..77d3bc4 100644 (file)
@@ -1,23 +1,23 @@
 (*
-* Copyright 2005-2009, Ecole des Mines de Nantes, University of Copenhagen
-* Yoann Padioleau, Julia Lawall, Rene Rydhof Hansen, Henrik Stuart, Gilles Muller
-* This file is part of Coccinelle.
-* 
-* Coccinelle is free software: you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation, according to version 2 of the License.
-* 
-* Coccinelle is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-* GNU General Public License for more details.
-* 
-* You should have received a copy of the GNU General Public License
-* along with Coccinelle.  If not, see <http://www.gnu.org/licenses/>.
-* 
-* The authors reserve the right to distribute this or future versions of
-* Coccinelle under other licenses.
-*)
+ * Copyright 2005-2009, Ecole des Mines de Nantes, University of Copenhagen
+ * Yoann Padioleau, Julia Lawall, Rene Rydhof Hansen, Henrik Stuart, Gilles Muller, Nicolas Palix
+ * This file is part of Coccinelle.
+ *
+ * Coccinelle is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, according to version 2 of the License.
+ *
+ * Coccinelle is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Coccinelle.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * The authors reserve the right to distribute this or future versions of
+ * Coccinelle under other licenses.
+ *)
 
 
 (* find unitary metavariables *)
@@ -40,8 +40,8 @@ let rec nub = function
 let minus_checker name = let id = Ast0.unwrap_mcode name in [id]
 
 (* take only what is in the plus code *)
-let plus_checker (nm,_,_,mc,_) =
-  match mc with Ast0.PLUS -> [nm] | _ -> []
+let plus_checker (nm,_,_,mc,_,_) =
+  match mc with Ast0.PLUS -> [nm] | _ -> []
 
 let get_free checker t =
   let bind x y = x @ y in
@@ -115,6 +115,12 @@ let get_free checker t =
        detect_unitary_frees(List.map r.VT0.combiner_rec_declaration decls)
     | _ -> k d in
 
+  let case_line r k c =
+    match Ast0.unwrap c with
+      Ast0.DisjCase(starter,case_lines,mids,ender) ->
+       detect_unitary_frees(List.map r.VT0.combiner_rec_case_line case_lines)
+    | _ -> k c in
+
   let statement r k s =
     match Ast0.unwrap s with
       Ast0.MetaStmt(name,_) | Ast0.MetaStmtList(name,_) -> checker name
@@ -146,7 +152,8 @@ let get_free checker t =
        VT0.combiner_tyfn = typeC;
        VT0.combiner_paramfn = parameter;
        VT0.combiner_declfn = declaration;
-       VT0.combiner_stmtfn = statement} in
+       VT0.combiner_stmtfn = statement;
+       VT0.combiner_casefn = case_line} in
 
   collect_unitary_nonunitary
     (List.concat (List.map res.VT0.combiner_rec_top_level t))