(*
-* 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.
+ *)
module Ast0 = Ast0_cocci
let rec get_name name =
match Ast0.unwrap name with
- Ast0.Id(nm) -> Id(Ast0.unwrap_mcode nm)
- | Ast0.MetaId(nm,_,_) | Ast0.MetaFunc(nm,_,_)
- | Ast0.MetaLocalFunc(nm,_,_) -> Meta(Ast0.unwrap_mcode nm)
- | Ast0.OptIdent(id) | Ast0.UniqueIdent(id) ->
- get_name id
+ Ast0.Id(nm) -> Id(Ast0.unwrap_mcode nm)
+ | Ast0.MetaId(nm,_,_) | Ast0.MetaFunc(nm,_,_)
+ | Ast0.MetaLocalFunc(nm,_,_) -> Meta(Ast0.unwrap_mcode nm)
+ | Ast0.OptIdent(id) | Ast0.UniqueIdent(id) ->
+ get_name id
(* --------------------------------------------------------------------- *)
(* collect all of the functions *)
-let brace_to_semi (_,arity,info,mcodekind,pos) =
- (";",Ast0.NONE,info,mcodekind,pos)
+let brace_to_semi (_,arity,info,mcodekind,pos,adj) =
+ let info =
+ (* drop column information, so that with -smpl_spacing the semicolon
+ will come out right after the close parenthesis *)
+ {info with Ast0.pos_info = {info.Ast0.pos_info with Ast0.column = -1}} in
+ (";",Ast0.NONE,info,mcodekind,pos,adj)
let collect_function (stm : Ast0.statement) =
match Ast0.unwrap stm with
and strip =
let donothing r k e =
- {(Ast0.wrap (Ast0.unwrap (k e))) with Ast0.mcodekind = ref Ast0.PLUS} in
- let mcode (mc,_,_,_,_) =
- (mc,Ast0.NONE,Ast0.default_info(),Ast0.PLUS,ref Ast0.NoMetaPos) in
+ {(Ast0.wrap (Ast0.unwrap (k e))) with
+ Ast0.mcodekind = ref (Ast0.PLUS Ast.ONE)} in
+ let mcode (mc,_,_,_,_,_) =
+ (mc,Ast0.NONE,Ast0.default_info(),Ast0.PLUS Ast.ONE,
+ ref Ast0.NoMetaPos,-1) in
(* need a case for everything that has an unvisited component and can be in
a function prototype *)
match Ast0.unwrap param with
Ast0.Param(ty,Some id) when all ->
(match Ast0.unwrap id with
- Ast0.MetaId(((_,name),arity,info,mcodekind,pos),constraints,pure) ->
+ Ast0.MetaId
+ (((_,name),arity,info,mcodekind,pos,adj),constraints,pure) ->
let nm = ("__no_name__",new_name name) in
let new_id =
Ast0.rewrap id
(Ast0.MetaId
- ((nm,arity,info,mcodekind,pos),constraints,Ast0.Pure)) in
+ ((nm,arity,info,mcodekind,pos,adj),constraints,Ast0.Pure)) in
([Ast.MetaIdDecl(Ast.NONE,nm)],
Ast0.rewrap param (Ast0.Param(ty,Some new_id)))
| _ -> ([],param))
Ast0.get_mcode_mcodekind lp in
let pdots =
("...",Ast0.NONE,info,mcodekind,
- ref Ast0.NoMetaPos) in
+ ref Ast0.NoMetaPos,-1) in
Ast0.DOTS
([Ast0.rewrap params
(Ast0.Pdots(pdots))])),
let merge mproto pproto =
let mproto =
- Compute_lines.compute_lines [Ast0.copywrap mproto (Ast0.DECL mproto)] in
+ Compute_lines.compute_lines true
+ [Ast0.copywrap mproto (Ast0.DECL mproto)] in
let pproto =
- Compute_lines.compute_lines [Ast0.copywrap pproto (Ast0.DECL pproto)] in
+ Compute_lines.compute_lines true
+ [Ast0.copywrap pproto (Ast0.DECL pproto)] in
let (m,p) = List.split(Context_neg.context_neg mproto pproto) in
Insert_plus.insert_plus m p true (* no isos for protos *);
(* convert to ast so that the + code will fall down to the tokens