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