(*
-* 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 2010, 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.
+ *)
(* --------------------------------------------------------------------- *)
| Ast0.Array(ty,lb,size,rb) -> array_type (ty,lb,size,rb) []
| Ast0.EnumName(kind,name) ->
let (kind_n,kind) = string_mcode kind in
- let (name_n,name) = ident name in
+ let (name_n,name) = get_option ident name in
(bind kind_n name_n, Ast0.EnumName(kind,name))
+ | Ast0.EnumDef(ty,lb,ids,rb) ->
+ let (ty_n,ty) = typeC ty in
+ let (lb_n,lb) = string_mcode lb in
+ let (ids_n,ids) = expression_dots ids in
+ let (rb_n,rb) = string_mcode rb in
+ (multibind [ty_n;lb_n;ids_n;rb_n], Ast0.EnumDef(ty,lb,ids,rb))
| Ast0.StructUnionName(kind,name) ->
let (kind_n,kind) = struct_mcode kind in
let (name_n,name) = get_option ident name in
let k d =
rewrap d
(match Ast0.unwrap d with
- Ast0.Init(stg,ty,id,eq,ini,sem) ->
+ Ast0.MetaDecl(name,pure) ->
+ let (n,name) = meta_mcode name in
+ (n,Ast0.MetaDecl(name,pure))
+ | Ast0.MetaField(name,pure) ->
+ let (n,name) = meta_mcode name in
+ (n,Ast0.MetaField(name,pure))
+ | Ast0.Init(stg,ty,id,eq,ini,sem) ->
let (stg_n,stg) = get_option storage_mcode stg in
let ((ty_id_n,ty),id) = named_type ty id in
let (eq_n,eq) = string_mcode eq in
| Ast0.InitExpr(exp) ->
let (exp_n,exp) = expression exp in
(exp_n,Ast0.InitExpr(exp))
- | Ast0.InitList(lb,initlist,rb) ->
+ | Ast0.InitList(lb,initlist,rb,ordered) ->
let (lb_n,lb) = string_mcode lb in
let (initlist_n,initlist) = initialiser_list initlist in
let (rb_n,rb) = string_mcode rb in
- (multibind [lb_n;initlist_n;rb_n], Ast0.InitList(lb,initlist,rb))
+ (multibind [lb_n;initlist_n;rb_n],
+ Ast0.InitList(lb,initlist,rb,ordered))
| Ast0.InitGccExt(designators,eq,ini) ->
let (dn,designators) = map_split_bind designator designators in
let (eq_n,eq) = string_mcode eq in
(match Ast0.unwrap p with
Ast0.VoidParam(ty) ->
let (n,ty) = typeC ty in (n,Ast0.VoidParam(ty))
- | Ast0.Param(ty,id) ->
+ | Ast0.Param(ty,Some id) ->
+ let ((ty_id_n,ty),id) = named_type ty id in
+ (ty_id_n, Ast0.Param(ty,Some id))
+ | Ast0.Param(ty,None) ->
let (ty_n,ty) = typeC ty in
- let (id_n,id) = get_option ident id in
- (bind ty_n id_n, Ast0.Param(ty,id))
+ (ty_n, Ast0.Param(ty,None))
| Ast0.MetaParam(name,pure) ->
let (n,name) = meta_mcode name in
(n,Ast0.MetaParam(name,pure))
rewrap s
(match Ast0.unwrap s with
Ast0.FunDecl(bef,fi,name,lp,params,rp,lbrace,body,rbrace) ->
- let (fi_n,fi) = map_split_bind fninfo fi in
+ let (fi_n,fi) = map_split_bind fninfo fi in
let (name_n,name) = ident name in
- let (lp_n,lp) = string_mcode lp in
+ let (lp_n,lp) = string_mcode lp in
let (params_n,params) = parameter_list params in
- let (rp_n,rp) = string_mcode rp in
+ let (rp_n,rp) = string_mcode rp in
let (lbrace_n,lbrace) = string_mcode lbrace in
- let (body_n,body) = statement_dots body in
+ let (body_n,body) = statement_dots body in
let (rbrace_n,rbrace) = string_mcode rbrace in
(multibind
[fi_n;name_n;lp_n;params_n;rp_n;lbrace_n;body_n;rbrace_n],
let (decl_n,decl) = declaration decl in
(decl_n,Ast0.Decl(bef,decl))
| Ast0.Seq(lbrace,body,rbrace) ->
- let (lbrace_n,lbrace) = string_mcode lbrace in
+ let (lbrace_n,lbrace) = string_mcode lbrace in
let (body_n,body) = statement_dots body in
let (rbrace_n,rbrace) = string_mcode rbrace in
(multibind [lbrace_n;body_n;rbrace_n],
Ast0.Seq(lbrace,body,rbrace))
| Ast0.ExprStatement(exp,sem) ->
- let (exp_n,exp) = expression exp in
+ let (exp_n,exp) = expression exp in
let (sem_n,sem) = string_mcode sem in
(bind exp_n sem_n, Ast0.ExprStatement(exp,sem))
| Ast0.IfThen(iff,lp,exp,rp,branch1,aft) ->
- let (iff_n,iff) = string_mcode iff in
- let (lp_n,lp) = string_mcode lp in
+ let (iff_n,iff) = string_mcode iff in
+ let (lp_n,lp) = string_mcode lp in
let (exp_n,exp) = expression exp in
let (rp_n,rp) = string_mcode rp in
let (branch1_n,branch1) = statement branch1 in
(multibind [iff_n;lp_n;exp_n;rp_n;branch1_n],
Ast0.IfThen(iff,lp,exp,rp,branch1,aft))
| Ast0.IfThenElse(iff,lp,exp,rp,branch1,els,branch2,aft) ->
- let (iff_n,iff) = string_mcode iff in
+ let (iff_n,iff) = string_mcode iff in
let (lp_n,lp) = string_mcode lp in
let (exp_n,exp) = expression exp in
- let (rp_n,rp) = string_mcode rp in
- let (branch1_n,branch1) = statement branch1 in
+ let (rp_n,rp) = string_mcode rp in
+ let (branch1_n,branch1) = statement branch1 in
let (els_n,els) = string_mcode els in
let (branch2_n,branch2) = statement branch2 in
(multibind [iff_n;lp_n;exp_n;rp_n;branch1_n;els_n;branch2_n],
(multibind [fr_n;lp_n;e1_n;sem1_n;e2_n;sem2_n;e3_n;rp_n;body_n],
Ast0.For(fr,lp,e1,sem1,e2,sem2,e3,rp,body,aft))
| Ast0.Iterator(nm,lp,args,rp,body,aft) ->
- let (nm_n,nm) = ident nm in
+ let (nm_n,nm) = ident nm in
let (lp_n,lp) = string_mcode lp in
let (args_n,args) = expression_dots args in
let (rp_n,rp) = string_mcode rp in
let (body_n,body) = statement body in
(multibind [nm_n;lp_n;args_n;rp_n;body_n],
Ast0.Iterator(nm,lp,args,rp,body,aft))
- | Ast0.Switch(switch,lp,exp,rp,lb,cases,rb) ->
- let (switch_n,switch) = string_mcode switch in
+ | Ast0.Switch(switch,lp,exp,rp,lb,decls,cases,rb) ->
+ let (switch_n,switch) = string_mcode switch in
let (lp_n,lp) = string_mcode lp in
let (exp_n,exp) = expression exp in
- let (rp_n,rp) = string_mcode rp in
+ let (rp_n,rp) = string_mcode rp in
let (lb_n,lb) = string_mcode lb in
- let (cases_n,cases) = case_line_dots cases in
+ let (decls_n,decls) = statement_dots decls in
+ let (cases_n,cases) = case_line_dots cases in
let (rb_n,rb) = string_mcode rb in
- (multibind [switch_n;lp_n;exp_n;rp_n;lb_n;cases_n;rb_n],
- Ast0.Switch(switch,lp,exp,rp,lb,cases,rb))
+ (multibind [switch_n;lp_n;exp_n;rp_n;lb_n;decls_n;cases_n;rb_n],
+ Ast0.Switch(switch,lp,exp,rp,lb,decls,cases,rb))
| Ast0.Break(br,sem) ->
let (br_n,br) = string_mcode br in
let (sem_n,sem) = string_mcode sem in
let (inc_n,inc) = string_mcode inc in
let (name_n,name) = inc_mcode name in
(bind inc_n name_n, Ast0.Include(inc,name))
+ | Ast0.Undef(def,id) ->
+ let (def_n,def) = string_mcode def in
+ let (id_n,id) = ident id in
+ (multibind [def_n;id_n],Ast0.Undef(def,id))
| Ast0.Define(def,id,params,body) ->
let (def_n,def) = string_mcode def in
let (id_n,id) = ident id in
let (code_n,code) = statement_dots code in
(multibind [case_n;exp_n;colon_n;code_n],
Ast0.Case(case,exp,colon,code))
+ | Ast0.DisjCase(starter,case_lines,mids,ender) ->
+ let (starter_n,starter) = string_mcode starter in
+ let (case_lines_n,case_lines) = map_split case_line case_lines in
+ let (mids_n,mids) = map_split string_mcode mids in
+ let (ender_n,ender) = string_mcode ender in
+ (multibind
+ [starter_n;List.hd case_lines_n;
+ multibind (List.map2 bind mids_n (List.tl case_lines_n));
+ ender_n],
+ Ast0.DisjCase(starter,case_lines,mids,ender))
| Ast0.OptCase(case) ->
let (n,case) = case_line case in (n,Ast0.OptCase(case))) in
casefn all_functions k c
let (params_n,params) = parameter_list params in
(params_n,Ast0.DotsParamTag(params))
| Ast0.DotsStmtTag(stmts) ->
- let (stmts_n,stmts) = statement_dots stmts in
+ let (stmts_n,stmts) = statement_dots stmts in
(stmts_n,Ast0.DotsStmtTag(stmts))
| Ast0.DotsDeclTag(decls) ->
let (decls_n,decls) = declaration_dots decls in