~ubuntu-branches/ubuntu/maverick/coccinelle/maverick

« back to all changes in this revision

Viewing changes to parsing_c/lib_parsing_c.ml

  • Committer: Bazaar Package Importer
  • Author(s): Daniel T Chen
  • Date: 2009-08-10 01:01:24 UTC
  • mfrom: (7.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20090810010124-9fn4c8m93ic60fqx
Tags: 0.1.9.deb-1ubuntu1
* Merge from Debian unstable, remaining changes:
  - debian/control: build-depend on python2.6-dev,
    set XB-Python-Version to 2.6
* New upstream (Debian) packaging applied fix for
  LP: #410907 (see changelog entry below)

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
 
25
25
(* todo?: al_expr doit enlever les infos de type ? et doit remettre en
26
26
 *  emptyAnnot ? 
 
27
 
 
28
No!  Keeping the type information is important to ensuring that variables
 
29
of different type and declared in different places do not seem to match
 
30
each other.  On the other hand, we don't want to keep around the
 
31
information about whether the expression is a test expression, because a
 
32
term that is a test expression should match one that is not.  The test
 
33
information is only useful for matching to the CTL.
 
34
 
27
35
 *)
28
36
 
29
37
(* drop all info information *)
30
38
 
31
39
let strip_info_visitor _ = 
 
40
  let drop_test ty =
 
41
    let (ty,_) = !ty in
 
42
    ref (ty,Ast_c.NotTest) in
 
43
 
32
44
  { Visitor_c.default_visitor_c_s with
33
45
    Visitor_c.kinfo_s =
34
46
    (* traversal should be deterministic... *)
38
50
 
39
51
    Visitor_c.kexpr_s = (fun (k,_) e -> 
40
52
      let (e', ty), ii' = k e in
41
 
      (e', Ast_c.noType()(*ref !ty*)), ii' (* keep type - jll *)
 
53
      (e', drop_test ty), ii' (* keep type - jll *)
42
54
    );
43
55
 
44
56
(*
71
83
 
72
84
 
73
85
 
 
86
let strip_inh_info_visitor _ =  (* for inherited metavariables *)
 
87
  let drop_test_lv ty =
 
88
    let (ty,_) = !ty in
 
89
    let ty =
 
90
      match ty with
 
91
        None -> None
 
92
      | Some (ty,_) -> Some (ty,Ast_c.NotLocalVar) in
 
93
    ref (ty,Ast_c.NotTest) in
 
94
 
 
95
  { Visitor_c.default_visitor_c_s with
 
96
    Visitor_c.kinfo_s =
 
97
    (* traversal should be deterministic... *)
 
98
    (let ctr = ref 0 in 
 
99
    (function (k,_) ->
 
100
    function i -> ctr := !ctr + 1; Ast_c.al_info_cpp !ctr i));
 
101
 
 
102
    Visitor_c.kexpr_s = (fun (k,_) e -> 
 
103
      let (e', ty), ii' = k e in
 
104
      (e', drop_test_lv ty), ii' (* keep type - jll *)
 
105
    );
 
106
 
 
107
(*
 
108
    Visitor_c.ktype_s = (fun (k,_) ft -> 
 
109
      let ft' = k ft in
 
110
      match Ast_c.unwrap_typeC ft' with
 
111
      | Ast_c.TypeName (s,_typ) -> 
 
112
          Ast_c.TypeName (s, Ast_c.noTypedefDef()) +> Ast_c.rewrap_typeC ft'
 
113
      | _ -> ft'
 
114
 
 
115
    );
 
116
*)
 
117
    
 
118
  }
 
119
 
 
120
let al_inh_expr      x = Visitor_c.vk_expr_s      (strip_inh_info_visitor()) x
 
121
let al_inh_statement x = Visitor_c.vk_statement_s (strip_inh_info_visitor()) x
 
122
let al_inh_type      x = Visitor_c.vk_type_s      (strip_inh_info_visitor()) x
 
123
let al_inh_init      x = Visitor_c.vk_ini_s       (strip_inh_info_visitor()) x
 
124
let al_inh_arguments x = Visitor_c.vk_arguments_s (strip_inh_info_visitor()) x
 
125
 
74
126
 
75
127
 
76
128
let semi_strip_info_visitor = (* keep position information *)
 
129
  let drop_test ty =
 
130
    let (ty,_) = !ty in
 
131
    ref (ty,Ast_c.NotTest) in
 
132
 
77
133
  { Visitor_c.default_visitor_c_s with
78
134
    Visitor_c.kinfo_s = (fun (k,_) i -> Ast_c.semi_al_info_cpp i);
79
135
 
80
136
    Visitor_c.kexpr_s = (fun (k,_) e -> 
81
137
      let (e', ty),ii' = k e in
82
 
      (e', Ast_c.noType()(*ref !ty*)), ii' (* keep type - jll *)
 
138
      (e', drop_test ty), ii' (* keep type - jll *)
83
139
    );
84
140
    
85
141
  }
99
155
 
100
156
 
101
157
(* really strip, do not keep position nor anything specificities, true
102
 
 * abstracted form. *)
 
158
 * abstracted form. This is used outside coccinelle in Yacfe and aComment *)
103
159
let real_strip_info_visitor _ = 
104
160
  { Visitor_c.default_visitor_c_s with
105
161
    Visitor_c.kinfo_s = (fun (k,_) i ->