File: isomorphisms_c_c.ml

package info (click to toggle)
coccinelle 1.0.8.deb-5
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 26,148 kB
  • sloc: ml: 136,392; ansic: 23,594; sh: 2,189; makefile: 2,157; perl: 1,576; lisp: 840; python: 823; awk: 70; csh: 12
file content (55 lines) | stat: -rw-r--r-- 1,659 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
(*
 * This file is part of Coccinelle, licensed under the terms of the GPL v2.
 * See copyright.txt in the Coccinelle source code for more information.
 * The Coccinelle source code can be obtained at http://coccinelle.lip6.fr
 *)

open Common

(* When in a semantic patch there is f(X) ... f(X) we want to force
 * the two X to be equal in the concrete code, but we would like that
 * there be equal modulo some isomorphisms, so that the following
 * concrete code also match: f(a && b) g(); f(b && a)

 * Maybe would be easier to transform ast_c in ast_cocci and call the
 * iso engine of julia. *)

open Ast_c

let (iso_e_e: expression -> expression -> bool) = fun a b ->
  raise Todo
    (*
      let rec (=~=) a b =
      match (a, b) with
      | (Ident a, typa, iia), (Ident b, typb, iib) -> a = b
      | (Constant a, typa, iia), (Constant b, typb, iib) -> a = b
      | (FunCall  (ea, eas), typa, iia), (FunCall  (eb, ebs), typb, iib)        ->
      ea =~= eb &&
      List.length eas = List.length ebs &&
      List.for_all (fun (a, b) ->
      match (a, b) with
      | (Left ea, iia), (Left eb, iib) -> ea =~= eb
      | _ -> raise Todo
      )
      (zip eas ebs)
      | (Binary (ea1,Logical AndLog,ea2),typa, iia), (Binary (eb1,Logical AndLog, eb2), typb, iib) ->
      (ea1 =~= eb1  && ea2 =~= eb2)
      ||
      (ea1 =~= eb2  && ea2 =~= eb1)

      | _ -> raise Todo
      in
      a =~= b
    *)

and (iso_st_st: statement -> statement -> bool) = fun a b ->
  raise Todo
and (iso_t_t: fullType -> fullType -> bool) = fun a b ->
  raise Todo


(*
let _ = assert (iso_e_e
  (cexpression_of_string "a&&b")
  (cexpression_of_string "b&&a")
*)