(*
- * Copyright 2010, INRIA, University of Copenhagen
+ * 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
val default_token_info : token_info
type mcodekind =
- MINUS of (Ast_cocci.anything list list * token_info) ref
+ MINUS of (Ast_cocci.anything Ast_cocci.replacement * token_info) ref
| PLUS of Ast_cocci.count
| CONTEXT of (Ast_cocci.anything Ast_cocci.befaft *
token_info * token_info) ref
mcode_start : mcodekind list; mcode_end : mcodekind list;
(* the following are only for + code *)
strings_before : (Ast_cocci.added_string * position_info) list;
- strings_after : (Ast_cocci.added_string * position_info) list }
+ strings_after : (Ast_cocci.added_string * position_info) list;
+ isSymbolIdent : bool; (* is the token a symbol identifier or not *) }
type 'a mcode =
- 'a * arity * info * mcodekind * meta_pos list ref (* pos, - only *) *
+ 'a * arity * info * mcodekind * anything list ref (* pos, - only *) *
int (* adjacency_index *)
and 'a wrap =
and base_ident =
Id of string mcode
- | MetaId of Ast_cocci.meta_name mcode * Ast_cocci.idconstraint * pure
+ | MetaId of Ast_cocci.meta_name mcode * Ast_cocci.idconstraint *
+ Ast_cocci.seed * pure
| MetaFunc of Ast_cocci.meta_name mcode * Ast_cocci.idconstraint * pure
| MetaLocalFunc of Ast_cocci.meta_name mcode * Ast_cocci.idconstraint * pure
| DisjId of string mcode * ident list *
expression dots * string mcode (* ) *)
| Assignment of expression * Ast_cocci.assignOp mcode * expression *
bool (* true if it can match an initialization *)
+ | Sequence of expression * string mcode (* , *) * expression
| CondExpr of expression * string mcode (* ? *) * expression option *
string mcode (* : *) * expression
| Postfix of expression * Ast_cocci.fixOp mcode
| SizeOfType of string mcode (* sizeof *) * string mcode (* ( *) *
typeC * string mcode (* ) *)
| TypeExp of typeC
+ | Constructor of string mcode (* ( *) * typeC * string mcode (* ) *) *
+ initialiser
| MetaErr of Ast_cocci.meta_name mcode * constraints * pure
| MetaExpr of Ast_cocci.meta_name mcode * constraints *
Type_cocci.typeC list option * Ast_cocci.form * pure
| MetaExprList of Ast_cocci.meta_name mcode (* only in arglists *) *
listlen * pure
+ | AsExpr of expression * expression (* as expr, always metavar *)
| EComma of string mcode (* only in arglists *)
| DisjExpr of string mcode * expression list * string mcode list *
string mcode
string mcode (* { *) * declaration dots * string mcode (* } *)
| TypeName of string mcode
| MetaType of Ast_cocci.meta_name mcode * pure
+ | AsType of typeC * typeC (* as type, always metavar *)
| DisjType of string mcode * typeC list * (* only after iso *)
string mcode list (* the |s *) * string mcode
| OptType of typeC
MetaDecl of Ast_cocci.meta_name mcode * pure (* variables *)
| MetaField of Ast_cocci.meta_name mcode * pure (* structure fields *)
| MetaFieldList of Ast_cocci.meta_name mcode * listlen * pure
+ | AsDecl of declaration * declaration
| Init of Ast_cocci.storage mcode option * typeC * ident *
string mcode (*=*) * initialiser * string mcode (*;*)
| UnInit of Ast_cocci.storage mcode option * typeC * ident *
| TyDecl of typeC * string mcode (* ; *)
| MacroDecl of ident (* name *) * string mcode (* ( *) *
expression dots * string mcode (* ) *) * string mcode (* ; *)
+ | MacroDeclInit of ident (* name *) * string mcode (* ( *) *
+ expression dots * string mcode (* ) *) * string mcode (*=*) *
+ initialiser * string mcode (* ; *)
| Typedef of string mcode (* typedef *) * typeC * typeC * string mcode (*;*)
| DisjDecl of string mcode * declaration list * string mcode list *
string mcode
and base_initialiser =
MetaInit of Ast_cocci.meta_name mcode * pure
| MetaInitList of Ast_cocci.meta_name mcode * listlen * pure
+ | AsInit of initialiser * initialiser (* as init, always metavar *)
| InitExpr of expression
| InitList of string mcode (*{*) * initialiser_list * string mcode (*}*) *
bool (* true if ordered, false if unordered *)
Decl of (info * mcodekind) (* before the decl *) * declaration
| Seq of string mcode (* { *) * statement dots *
string mcode (* } *)
- | ExprStatement of expression * string mcode (*;*)
+ | ExprStatement of expression option * string mcode (*;*)
| IfThen of string mcode (* if *) * string mcode (* ( *) *
expression * string mcode (* ) *) *
statement * (info * mcodekind)
| MetaStmt of Ast_cocci.meta_name mcode * pure
| MetaStmtList of Ast_cocci.meta_name mcode (*only in statement lists*) *
pure
+ | AsStmt of statement * statement (* as statement, always metavar *)
| Exp of expression (* only in dotted statement lists *)
| TopExp of expression (* for macros body *)
| Ty of typeC (* only at top level *)
(* Top-level code *)
and base_top_level =
- DECL of statement
+ NONDECL of statement (* cannot match all of a top-level declaration *)
+ | TOPCODE of statement dots
| CODE of statement dots
| FILEINFO of string mcode (* old file *) * string mcode (* new file *)
| ERRORWORDS of expression list
(* --------------------------------------------------------------------- *)
+and dependency =
+ Dep of string (* rule applies for the current binding *)
+ | AntiDep of dependency (* rule doesn't apply for the current binding *)
+ | EverDep of string (* rule applies for some binding *)
+ | NeverDep of string (* rule never applies for any binding *)
+ | AndDep of dependency * dependency
+ | OrDep of dependency * dependency
+ | NoDep | FailDep
+
+(* --------------------------------------------------------------------- *)
+
and anything =
DotsExprTag of expression dots
| DotsInitTag of initialiser dots
| IsoWhenTag of Ast_cocci.when_modifier (*only for when code, in iso phase*)
| IsoWhenTTag of expression(*only for when code, in iso phase*)
| IsoWhenFTag of expression(*only for when code, in iso phase*)
- | MetaPosTag of meta_pos (* only in iso phase *)
+ | MetaPosTag of meta_pos
+ | HiddenVarTag of anything list (* in iso_compile/pattern only *)
val dotsExpr : expression dots -> anything
val dotsInit : initialiser dots -> anything
val rewrap : 'a wrap -> 'b -> 'b wrap
val rewrap_mcode : 'a mcode -> 'b -> 'b mcode
val copywrap : 'a wrap -> 'b -> 'b wrap
-val get_pos : 'a mcode -> meta_pos list
-val get_pos_ref : 'a mcode -> meta_pos list ref
-val set_pos : meta_pos list -> 'a mcode -> 'a mcode
+val get_pos : 'a mcode -> anything list
+val get_pos_ref : 'a mcode -> anything list ref
+val set_pos : anything list -> 'a mcode -> 'a mcode
val get_info : 'a wrap -> info
val set_info : 'a wrap -> info -> 'a wrap
val get_index : 'a wrap -> int
val make_mcode_info : 'a -> info -> 'a mcode
val make_minus_mcode : 'a -> 'a mcode
+val meta_pos_name : anything -> Ast_cocci.meta_name mcode
+
val ast0_type_to_type : typeC -> Type_cocci.typeC
val reverse_type : Type_cocci.typeC -> base_typeC
exception TyConv