11open GoblintCil
22
3+ let create_var name typ = Cilfacade. create_var @@ makeGlobalVar name typ
4+
5+ let single ~name ~typ =
6+ let vi = lazy (create_var name typ) in
7+ fun () ->
8+ Lazy. force vi
9+
310module type VarinfoMap =
411sig
512 type t
1017 val bindings : unit -> (t * varinfo ) list
1118end
1219
13- module VarinfoDescription = struct
14- (* *This type is equal to `varinfo`, but the fields are not mutable and they are optional.
15- Only the name is not optional. *)
16- type t = {
17- vname_ : string ;
18- vtype_ : typ option ;
19- vattr_ : attributes option ;
20- vstorage_ : storage option ;
21- vglob_ : bool option ;
22- vinline_ : bool option ;
23- vdecl_ : location option ;
24- vinit_ : initinfo option ;
25- vaddrof_ : bool option ;
26- vreferenced_ : bool option ;
27- }
28-
29- let from_varinfo (v : varinfo ) =
30- {vname_= v.vname;
31- vtype_= Some v.vtype;
32- vattr_= Some v.vattr;
33- vstorage_= Some v.vstorage;
34- vglob_= Some v.vglob;
35- vinline_= Some v.vinline;
36- vdecl_= Some v.vdecl;
37- vinit_= Some v.vinit;
38- vaddrof_= Some v.vaddrof;
39- vreferenced_= Some v.vreferenced}
40-
41- let empty name =
42- {vname_= name;
43- vtype_= None ;
44- vattr_= None ;
45- vstorage_= None ;
46- vglob_= None ;
47- vinline_= None ;
48- vdecl_= None ;
49- vinit_= None ;
50- vaddrof_= None ;
51- vreferenced_= None }
52-
53- let update_varinfo (v : varinfo ) (update : t ) =
54- let open Batteries in
55- {vname= update.vname_;
56- vtype= Option. default v.vtype update.vtype_;
57- vattr= Option. default v.vattr update.vattr_;
58- vstorage= Option. default v.vstorage update.vstorage_;
59- vglob= Option. default v.vglob update.vglob_;
60- vinline= Option. default v.vinline update.vinline_;
61- vdecl= Option. default v.vdecl update.vdecl_;
62- vinit= Option. default v.vinit update.vinit_;
63- vid= v.vid;
64- vaddrof= Option. default v.vaddrof update.vaddrof_;
65- vreferenced= Option. default v.vreferenced update.vreferenced_;
66- vdescr= v.vdescr;
67- vdescrpure= v.vdescrpure;
68- vhasdeclinstruction= v.vhasdeclinstruction}
69- end
70-
71- let create_var (vd : VarinfoDescription.t ) =
72- Cilfacade. create_var (
73- VarinfoDescription. update_varinfo (makeGlobalVar vd.vname_ voidType) vd
74- )
75-
76- let single ~name =
77- let vi = lazy (create_var (VarinfoDescription. empty name)) in
78- fun () ->
79- Lazy. force vi
80-
8120module type G =
8221sig
8322 include Hashtbl. HashedType
84- val varinfo_attributes : t -> VarinfoDescription .t
23+ val name_varinfo : t -> string
24+ val typ : t -> typ
8525end
8626
8727module type H =
@@ -108,7 +48,7 @@ struct
10848 try
10949 XH. find ! xh x
11050 with Not_found ->
111- let vi = create_var (X. varinfo_attributes x) in
51+ let vi = create_var (X. name_varinfo x) ( X. typ x) in
11252 store_f x vi;
11353 vi
11454
0 commit comments