Release coccinelle-0.2.0rc1
[bpt/coccinelle.git] / engine / asttomember.ml
index d0c70af..9813f85 100644 (file)
@@ -1,25 +1,3 @@
-(*
-* 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.
-*)
-
-
 (* on the first pass, onlyModif is true, so we don't see all matched nodes,
 only modified ones *)
 
@@ -29,8 +7,8 @@ module CTL = Ast_ctl
 
 let mcode r (_,_,kind,_) =
   match kind with
-    Ast.MINUS(_,_) -> true
-  | Ast.PLUS -> failwith "not possible"
+    Ast.MINUS(_,_,_,_) -> true
+  | Ast.PLUS -> failwith "not possible"
   | Ast.CONTEXT(_,info) -> not (info = Ast.NOTHING)
 
 let no_mcode _ _ = false
@@ -183,11 +161,8 @@ and statement testfn mcode tail stmt : 'a list list =
        (* modifications on return are managed in some other way *)
        Ast.Return(_,_) | Ast.ReturnExpr(_,_,_) when tail -> []
       |        _ -> if testfn ast then rule_elem ast else [])
-  | Ast.Seq(lbrace,decls,body,rbrace) ->
-      let body_info =
-       conj
-         (statement_list testfn mcode false decls)
-         (statement_list testfn mcode tail body) in
+  | Ast.Seq(lbrace,body,rbrace) ->
+      let body_info = statement_list testfn mcode tail body in
       if testfn lbrace or testfn rbrace
       then conj_wrapped [lbrace;rbrace] body_info
       else body_info
@@ -200,8 +175,11 @@ and statement testfn mcode tail stmt : 'a list list =
       then conj (rule_elem header) (statement testfn mcode tail branch)
       else statement testfn mcode tail branch
 
-  | Ast.Switch(header,lb,cases,rb) ->
-      let body_info = case_lines  testfn mcode tail cases in
+  | Ast.Switch(header,lb,decls,cases,rb) ->
+      let body_info =
+       conj
+         (statement_list testfn mcode false decls)
+         (case_lines testfn mcode tail cases) in
       if testfn header or testfn lb or testfn rb
       then conj (rule_elem header) body_info
       else body_info
@@ -230,11 +208,8 @@ and statement testfn mcode tail stmt : 'a list list =
 
   | Ast.Dots(_,whencodes,_,_) -> []
 
-  | Ast.FunDecl(header,lbrace,decls,body,rbrace) ->
-      let body_info =
-       conj
-         (statement_list testfn mcode false decls)
-         (statement_list testfn mcode true body) in
+  | Ast.FunDecl(header,lbrace,body,rbrace) ->
+      let body_info = statement_list testfn mcode true body in
       if testfn header or testfn lbrace or testfn rbrace
       then conj (rule_elem header) body_info
       else body_info
@@ -321,6 +296,6 @@ let asttomemberz (_,_,l) used_after =
 
 let asttomember r used_after =
   match r with
-    Ast.ScriptRule _ -> []
+    Ast.ScriptRule _ | Ast.InitialScriptRule _ | Ast.FinalScriptRule _ -> []
   | Ast.CocciRule (a,b,c,_,_) -> asttomemberz (a,b,c) used_after