Commit | Line | Data |
---|---|---|
f537ebc4 | 1 | (* |
17ba0788 C |
2 | * Copyright 2012, INRIA |
3 | * Julia Lawall, Gilles Muller | |
4 | * Copyright 2010-2011, INRIA, University of Copenhagen | |
f537ebc4 C |
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. | |
9 | * | |
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. | |
13 | * | |
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. | |
18 | * | |
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/>. | |
21 | * | |
22 | * The authors reserve the right to distribute this or future versions of | |
23 | * Coccinelle under other licenses. | |
24 | *) | |
25 | ||
26 | ||
34e49164 C |
27 | open Ograph_extended |
28 | ||
29 | (*****************************************************************************) | |
30 | (* the different ctl formula related types *) | |
31 | (*****************************************************************************) | |
32 | type mvar = Ast_cocci.meta_name | |
33 | ||
34 | type predicate = | |
35 | InLoop | TrueBranch | FalseBranch | |
36 | | After (* pointer to the code after an if or while *) | |
951c7801 | 37 | | FallThrough | LoopFallThrough |
34e49164 | 38 | | Return (* any exit from the current function *) |
5427db06 | 39 | | FunHeader | UnsafeBrace | Top | Exit | ErrorExit | Goto |
34e49164 C |
40 | | Paren of Ast_cocci.meta_name |
41 | | Match of Ast_cocci.rule_elem | |
42 | | Label of Ast_cocci.meta_name | |
43 | | BCLabel of Ast_cocci.meta_name (* parent of break or continue *) | |
44 | | PrefixLabel of Ast_cocci.meta_name | |
45 | | BindGood of Ast_cocci.meta_name (* used to implement \+ *) | |
46 | | BindBad of Ast_cocci.meta_name | |
47 | | FakeBrace | |
48 | ||
485bce71 | 49 | (* coccionly: *) |
34e49164 C |
50 | type ctlcocci = (predicate, Ast_cocci.meta_name) Wrapper_ctl.wrapped_ctl |
51 | ||
52 | ||
53 | (*****************************************************************************) | |
54 | (* the different binding types *) | |
55 | (*****************************************************************************) | |
56 | type metavars_binding = Ast_c.metavars_binding | |
57 | ||
58 | (* used in ctlcocci_integration *) | |
ae4735db | 59 | type metavar_binding_kind2 = |
34e49164 C |
60 | | NormalMetaVal of Ast_c.metavar_binding_kind |
61 | | ParenVal of Ast_cocci.meta_name | |
7f004419 | 62 | | LabelVal of labelval |
34e49164 C |
63 | | GoodVal | BadVal (* used to implement \+ *) |
64 | ||
7f004419 C |
65 | and labelval = Absolute of int list | Prefix of int list |
66 | ||
34e49164 C |
67 | and metavars_binding2 = (mvar, metavar_binding_kind2) Common.assoc |
68 | ||
69 | ||
70 | ||
71 | (*****************************************************************************) | |
72 | (* the CTL model related types *) | |
73 | (*****************************************************************************) | |
485bce71 | 74 | (* coccionly: *) |
ae4735db C |
75 | type label_ctlcocci = |
76 | predicate -> | |
77 | (nodei * | |
78 | (predicate * (mvar, metavar_binding_kind2) Ast_ctl.generic_substitution)) | |
34e49164 | 79 | list |
ae4735db | 80 | |
34e49164 C |
81 | type model = Control_flow_c.cflow * label_ctlcocci * nodei list |
82 | ||
ae4735db | 83 | type transformation_info = |
34e49164 C |
84 | (nodei * metavars_binding * Ast_cocci.rule_elem) list |
85 | ||
ae4735db | 86 | type numbered_transformation_info = |
708f4980 C |
87 | (int list * (nodei * metavars_binding * Ast_cocci.rule_elem)) list |
88 | ||
34e49164 C |
89 | |
90 | (*****************************************************************************) | |
91 | (* comparing binding *) | |
92 | (*****************************************************************************) | |
93 | ||
ae4735db | 94 | let equal_binding xs ys = |
34e49164 | 95 | List.sort compare xs = List.sort compare ys |