2 * Copyright 2012, INRIA
3 * Julia Lawall, Gilles Muller
4 * Copyright 2010-2011, INRIA, University of Copenhagen
5 * Julia Lawall, Rene Rydhof Hansen, Gilles Muller, Nicolas Palix
6 * Copyright 2005-2009, Ecole des Mines de Nantes, University of Copenhagen
7 * Yoann Padioleau, Julia Lawall, Rene Rydhof Hansen, Henrik Stuart, Gilles Muller, Nicolas Palix
8 * This file is part of Coccinelle.
10 * Coccinelle is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, according to version 2 of the License.
14 * Coccinelle is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with Coccinelle. If not, see <http://www.gnu.org/licenses/>.
22 * The authors reserve the right to distribute this or future versions of
23 * Coccinelle under other licenses.
30 (*****************************************************************************)
31 (* the different ctl formula related types *)
32 (*****************************************************************************)
33 type mvar
= Ast_cocci.meta_name
36 InLoop
| TrueBranch
| FalseBranch
37 | After
(* pointer to the code after an if or while *)
38 | FallThrough
| LoopFallThrough
39 | Return
(* any exit from the current function *)
40 | FunHeader
| UnsafeBrace
| Top
| Exit
| ErrorExit
| Goto
41 | Paren
of Ast_cocci.meta_name
42 | Match
of Ast_cocci.rule_elem
43 | Label
of Ast_cocci.meta_name
44 | BCLabel
of Ast_cocci.meta_name
(* parent of break or continue *)
45 | PrefixLabel
of Ast_cocci.meta_name
46 | BindGood
of Ast_cocci.meta_name
(* used to implement \+ *)
47 | BindBad
of Ast_cocci.meta_name
51 type ctlcocci
= (predicate
, Ast_cocci.meta_name
) Wrapper_ctl.wrapped_ctl
54 (*****************************************************************************)
55 (* the different binding types *)
56 (*****************************************************************************)
57 type metavars_binding
= Ast_c.metavars_binding
59 (* used in ctlcocci_integration *)
60 type metavar_binding_kind2
=
61 | NormalMetaVal
of Ast_c.metavar_binding_kind
62 | ParenVal
of Ast_cocci.meta_name
63 | LabelVal
of labelval
64 | GoodVal
| BadVal
(* used to implement \+ *)
66 and labelval
= Absolute
of int list
| Prefix
of int list
68 and metavars_binding2
= (mvar
, metavar_binding_kind2
) Common.assoc
72 (*****************************************************************************)
73 (* the CTL model related types *)
74 (*****************************************************************************)
79 (predicate
* (mvar
, metavar_binding_kind2
) Ast_ctl.generic_substitution
))
82 type model
= Control_flow_c.cflow
* label_ctlcocci
* nodei list
84 type transformation_info
=
85 (nodei
* metavars_binding
* Ast_cocci.rule_elem
) list
87 type numbered_transformation_info
=
88 (int list
* (nodei
* metavars_binding
* Ast_cocci.rule_elem
)) list
91 (*****************************************************************************)
92 (* comparing binding *)
93 (*****************************************************************************)
95 let equal_binding xs ys
=
96 List.sort compare xs
= List.sort compare ys