Release coccinelle-0.2.0
[bpt/coccinelle.git] / engine / lib_engine.ml
CommitLineData
9f8e26f4
C
1(*
2 * Copyright 2005-2009, Ecole des Mines de Nantes, University of Copenhagen
3 * Yoann Padioleau, Julia Lawall, Rene Rydhof Hansen, Henrik Stuart, Gilles Muller, Nicolas Palix
4 * This file is part of Coccinelle.
5 *
6 * Coccinelle is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, according to version 2 of the License.
9 *
10 * Coccinelle is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with Coccinelle. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * The authors reserve the right to distribute this or future versions of
19 * Coccinelle under other licenses.
20 *)
21
22
34e49164
C
23open Ograph_extended
24
25(*****************************************************************************)
26(* the different ctl formula related types *)
27(*****************************************************************************)
28type mvar = Ast_cocci.meta_name
29
30type predicate =
31 InLoop | TrueBranch | FalseBranch
32 | After (* pointer to the code after an if or while *)
951c7801 33 | FallThrough | LoopFallThrough
34e49164
C
34 | Return (* any exit from the current function *)
35 | FunHeader | Top | Exit | ErrorExit | Goto
36 | Paren of Ast_cocci.meta_name
37 | Match of Ast_cocci.rule_elem
38 | Label of Ast_cocci.meta_name
39 | BCLabel of Ast_cocci.meta_name (* parent of break or continue *)
40 | PrefixLabel of Ast_cocci.meta_name
41 | BindGood of Ast_cocci.meta_name (* used to implement \+ *)
42 | BindBad of Ast_cocci.meta_name
43 | FakeBrace
44
485bce71 45(* coccionly: *)
34e49164
C
46type ctlcocci = (predicate, Ast_cocci.meta_name) Wrapper_ctl.wrapped_ctl
47
48
49(*****************************************************************************)
50(* the different binding types *)
51(*****************************************************************************)
52type metavars_binding = Ast_c.metavars_binding
53
54(* used in ctlcocci_integration *)
55type metavar_binding_kind2 =
56 | NormalMetaVal of Ast_c.metavar_binding_kind
57 | ParenVal of Ast_cocci.meta_name
7f004419 58 | LabelVal of labelval
34e49164
C
59 | GoodVal | BadVal (* used to implement \+ *)
60
7f004419
C
61and labelval = Absolute of int list | Prefix of int list
62
34e49164
C
63and metavars_binding2 = (mvar, metavar_binding_kind2) Common.assoc
64
65
66
67(*****************************************************************************)
68(* the CTL model related types *)
69(*****************************************************************************)
485bce71 70(* coccionly: *)
34e49164
C
71type label_ctlcocci =
72 predicate ->
73 (nodei *
74 (predicate * (mvar, metavar_binding_kind2) Ast_ctl.generic_substitution))
75 list
76
77type model = Control_flow_c.cflow * label_ctlcocci * nodei list
78
79type transformation_info =
80 (nodei * metavars_binding * Ast_cocci.rule_elem) list
81
708f4980
C
82type numbered_transformation_info =
83 (int list * (nodei * metavars_binding * Ast_cocci.rule_elem)) list
84
34e49164
C
85
86(*****************************************************************************)
87(* comparing binding *)
88(*****************************************************************************)
89
90let equal_binding xs ys =
91 List.sort compare xs = List.sort compare ys