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 Common |
28 | ||
29 | (* When in a semantic patch there is f(X) ... f(X) we want to force | |
30 | * the two X to be equal in the concrete code, but we would like that | |
31 | * there be equal modulo some isomorphisms, so that the following | |
32 | * concrete code also match: f(a && b) g(); f(b && a) | |
33 | ||
34 | * Maybe would be easier to transform ast_c in ast_cocci and call the | |
35 | * iso engine of julia. *) | |
36 | ||
37 | open Ast_c | |
38 | ||
ae4735db | 39 | let rec (iso_e_e: expression -> expression -> bool) = fun a b -> |
34e49164 C |
40 | raise Todo |
41 | (* | |
ae4735db | 42 | let rec (=~=) a b = |
34e49164 C |
43 | match (a, b) with |
44 | | (Ident a, typa, iia), (Ident b, typb, iib) -> a = b | |
45 | | (Constant a, typa, iia), (Constant b, typb, iib) -> a = b | |
ae4735db | 46 | | (FunCall (ea, eas), typa, iia), (FunCall (eb, ebs), typb, iib) -> |
34e49164 | 47 | ea =~= eb && |
ae4735db C |
48 | List.length eas = List.length ebs && |
49 | List.for_all (fun (a, b) -> | |
34e49164 C |
50 | match (a, b) with |
51 | | (Left ea, iia), (Left eb, iib) -> ea =~= eb | |
52 | | _ -> raise Todo | |
53 | ) | |
54 | (zip eas ebs) | |
ae4735db C |
55 | | (Binary (ea1,Logical AndLog,ea2),typa, iia), (Binary (eb1,Logical AndLog, eb2), typb, iib) -> |
56 | (ea1 =~= eb1 && ea2 =~= eb2) | |
34e49164 C |
57 | || |
58 | (ea1 =~= eb2 && ea2 =~= eb1) | |
59 | ||
60 | | _ -> raise Todo | |
61 | in | |
62 | a =~= b | |
63 | *) | |
64 | ||
ae4735db | 65 | and (iso_st_st: statement -> statement -> bool) = fun a b -> |
34e49164 | 66 | raise Todo |
ae4735db | 67 | and (iso_t_t: fullType -> fullType -> bool) = fun a b -> |
34e49164 C |
68 | raise Todo |
69 | ||
ae4735db | 70 | |
34e49164 | 71 | (* |
ae4735db | 72 | let _ = assert (iso_e_e |
34e49164 C |
73 | (cexpression_of_string "a&&b") |
74 | (cexpression_of_string "b&&a") | |
75 | *) | |
76 |