X-Git-Url: http://git.hcoop.net/bpt/coccinelle.git/blobdiff_plain/c491d8eea333ab3273dc415c7d7af192e1d0b682..6756e19d8b45188ff250016a494aafe46dec86c5:/parsing_cocci/iso_pattern.ml diff --git a/parsing_cocci/iso_pattern.ml b/parsing_cocci/iso_pattern.ml index 6a63cda..ff9fb68 100644 --- a/parsing_cocci/iso_pattern.ml +++ b/parsing_cocci/iso_pattern.ml @@ -1,27 +1,3 @@ -(* - * 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 . - * - * The authors reserve the right to distribute this or future versions of - * Coccinelle under other licenses. - *) - - (* Potential problem: offset of mcode is not updated when an iso is instantiated, implying that a term may end up with many mcodes with the same offset. On the other hand, at the moment offset only seems to be used @@ -416,7 +392,9 @@ let match_maker checks_needed context_required whencode_allowed = let decl r k d = bind (bind (pure_mcodekind (Ast0.get_mcodekind d)) (k d)) (match Ast0.unwrap d with - Ast0.MetaDecl(name,pure) | Ast0.MetaField(name,pure) -> pure + Ast0.MetaDecl(name,pure) | Ast0.MetaField(name,pure) + | Ast0.MetaFieldList(name,_,pure) -> + pure | _ -> Ast0.Impure) in let stmt r k s = @@ -500,6 +478,8 @@ let match_maker checks_needed context_required whencode_allowed = if mcode_equal namea nameb then check_mcode namea nameb else return false + | (Ast0.DisjId(_,ids,_,_),_) -> + failwith "not allowed in the pattern of an isomorphism" | (Ast0.OptIdent(ida),Ast0.OptIdent(idb)) | (Ast0.UniqueIdent(ida),Ast0.UniqueIdent(idb)) -> match_ident ida idb @@ -816,7 +796,7 @@ let match_maker checks_needed context_required whencode_allowed = if mcode_equal namea nameb then check_mcode namea nameb else return false - | (Ast0.DisjType(_,typesa,_,_),Ast0.DisjType(_,typesb,_,_)) -> + | (Ast0.DisjType(_,typesa,_,_),_) -> failwith "not allowed in the pattern of an isomorphism" | (Ast0.OptType(tya),Ast0.OptType(tyb)) | (Ast0.UniqueType(tya),Ast0.UniqueType(tyb)) -> match_typeC tya tyb @@ -835,6 +815,7 @@ let match_maker checks_needed context_required whencode_allowed = add_pure_binding name pure pure_sp_code.VT0.combiner_rec_declaration (function d -> Ast0.DeclTag d) d + | Ast0.MetaFieldList(name,_,pure) -> failwith "metafieldlist not supporte" | up -> if not(checks_needed) or not(context_required) or is_context d then @@ -869,7 +850,7 @@ let match_maker checks_needed context_required whencode_allowed = | (Ast0.Typedef(stga,tya,ida,sc1),Ast0.Typedef(stgb,tyb,idb,sc)) -> conjunct_bindings (check_mcode sc1 sc) (conjunct_bindings (match_typeC tya tyb) (match_typeC ida idb)) - | (Ast0.DisjDecl(_,declsa,_,_),Ast0.DisjDecl(_,declsb,_,_)) -> + | (Ast0.DisjDecl(_,declsa,_,_),_) -> failwith "not allowed in the pattern of an isomorphism" | (Ast0.Ddots(d1,None),Ast0.Ddots(d,None)) -> check_mcode d1 d | (Ast0.Ddots(dd,None),Ast0.Ddots(d,Some wc)) -> @@ -1828,6 +1809,8 @@ let instantiate bindings mv_bindings = | Common.Right(new_mv) -> Ast0.rewrap e (Ast0.MetaField(Ast0.set_mcode_data new_mv name, pure))) + | Ast0.MetaFieldList(name,lenname,pure) -> + failwith "metafieldlist not supported" | Ast0.Ddots(d,_) -> (try (match List.assoc (dot_term d) bindings with @@ -2043,7 +2026,9 @@ let new_mv (_,s) = "_"^s^"_"^(string_of_int ct) let get_name = function - Ast.MetaIdDecl(ar,nm) -> + Ast.MetaMetaDecl(ar,nm) -> + (nm,function nm -> Ast.MetaMetaDecl(ar,nm)) + | Ast.MetaIdDecl(ar,nm) -> (nm,function nm -> Ast.MetaIdDecl(ar,nm)) | Ast.MetaFreshIdDecl(nm,seed) -> (nm,function nm -> Ast.MetaFreshIdDecl(nm,seed)) @@ -2071,6 +2056,8 @@ let get_name = function (nm,function nm -> Ast.MetaExpListDecl(ar,nm,nm1)) | Ast.MetaDeclDecl(ar,nm) -> (nm,function nm -> Ast.MetaDeclDecl(ar,nm)) + | Ast.MetaFieldListDecl(ar,nm,nm1) -> + (nm,function nm -> Ast.MetaFieldListDecl(ar,nm,nm1)) | Ast.MetaFieldDecl(ar,nm) -> (nm,function nm -> Ast.MetaFieldDecl(ar,nm)) | Ast.MetaStmDecl(ar,nm) ->