Coccinelle release 0.2.5-rc9
[bpt/coccinelle.git] / engine / isomorphisms_c_c.ml
CommitLineData
34e49164
C
1open Common
2
3(* When in a semantic patch there is f(X) ... f(X) we want to force
4 * the two X to be equal in the concrete code, but we would like that
5 * there be equal modulo some isomorphisms, so that the following
6 * concrete code also match: f(a && b) g(); f(b && a)
7
8 * Maybe would be easier to transform ast_c in ast_cocci and call the
9 * iso engine of julia. *)
10
11open Ast_c
12
ae4735db 13let rec (iso_e_e: expression -> expression -> bool) = fun a b ->
34e49164
C
14 raise Todo
15 (*
ae4735db 16 let rec (=~=) a b =
34e49164
C
17 match (a, b) with
18 | (Ident a, typa, iia), (Ident b, typb, iib) -> a = b
19 | (Constant a, typa, iia), (Constant b, typb, iib) -> a = b
ae4735db 20 | (FunCall (ea, eas), typa, iia), (FunCall (eb, ebs), typb, iib) ->
34e49164 21 ea =~= eb &&
ae4735db
C
22 List.length eas = List.length ebs &&
23 List.for_all (fun (a, b) ->
34e49164
C
24 match (a, b) with
25 | (Left ea, iia), (Left eb, iib) -> ea =~= eb
26 | _ -> raise Todo
27 )
28 (zip eas ebs)
ae4735db
C
29 | (Binary (ea1,Logical AndLog,ea2),typa, iia), (Binary (eb1,Logical AndLog, eb2), typb, iib) ->
30 (ea1 =~= eb1 && ea2 =~= eb2)
34e49164
C
31 ||
32 (ea1 =~= eb2 && ea2 =~= eb1)
33
34 | _ -> raise Todo
35 in
36 a =~= b
37 *)
38
ae4735db 39and (iso_st_st: statement -> statement -> bool) = fun a b ->
34e49164 40 raise Todo
ae4735db 41and (iso_t_t: fullType -> fullType -> bool) = fun a b ->
34e49164
C
42 raise Todo
43
ae4735db 44
34e49164 45(*
ae4735db 46let _ = assert (iso_e_e
34e49164
C
47 (cexpression_of_string "a&&b")
48 (cexpression_of_string "b&&a")
49*)
50