(*
-* Copyright 2005-2008, 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 2012, INRIA
+ * Julia Lawall, Gilles Muller
+ * Copyright 2010-2011, INRIA, University of Copenhagen
+ * Julia Lawall, Rene Rydhof Hansen, Gilles Muller, Nicolas Palix
+ * 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.
+ *)
module Ast = Ast_cocci
module Ast0 = Ast0_cocci
module V0 = Visitor_ast0
+module VT0 = Visitor_ast0_types
(* call set_test_pos on test expressions *)
the annotations in the C file. *)
let rec process_exp e =
- let e = Ast0.set_test_pos e in
+ let e = Ast0.set_test_pos e in(* allow test isos *)
+ let e = Ast0.set_test_exp e in(* require that a test expression is matched *)
match Ast0.unwrap e with
- Ast0.Paren(lp,e,rp) ->
- Ast0.rewrap e (Ast0.Paren(lp,process_exp e,rp))
+ Ast0.Paren(lp,e1,rp) ->
+ Ast0.rewrap e (Ast0.Paren(lp,process_exp e1,rp))
| _ -> e
let set_test_poss =
- let donothing r k e = k e in
- let mcode x = x in
-
let expression r k e =
let e = k e in
match Ast0.unwrap e with
| _ -> e)
| _ -> e in
+ let process_wc = function
+ Ast0.WhenNotTrue(e) -> Ast0.WhenNotTrue(process_exp e)
+ | Ast0.WhenNotFalse(e) -> Ast0.WhenNotFalse(process_exp e)
+ | wc -> wc in
+
let statement r k s =
let s = k s in
match Ast0.unwrap s with
| Ast0.For(f,lp,e1,sc1,Some e2,sc2,e3,rp,s1,aft) ->
Ast0.rewrap s
(Ast0.For(f,lp,e1,sc1,Some (process_exp e2),sc2,e3,rp,s1,aft))
+ | Ast0.Dots(d,wc) ->
+ Ast0.rewrap s (Ast0.Dots(d,List.map process_wc wc))
+ | Ast0.Nest(l,s1,r,wc,m) ->
+ Ast0.rewrap s (Ast0.Nest(l,s1,r,List.map process_wc wc,m))
| _ -> s in
V0.rebuilder
- mcode mcode mcode mcode mcode mcode mcode mcode mcode mcode mcode mcode
- mcode
- donothing donothing donothing donothing donothing donothing
- donothing expression donothing donothing donothing donothing statement
- donothing donothing
+ {V0.rebuilder_functions with
+ VT0.rebuilder_exprfn = expression; VT0.rebuilder_stmtfn = statement}
-let process = List.map set_test_poss.V0.rebuilder_top_level
+let process = List.map set_test_poss.VT0.rebuilder_rec_top_level
-let process_anything = set_test_poss.V0.rebuilder_anything
+let process_anything = set_test_poss.VT0.rebuilder_rec_anything