1 (* *********************************************************************)
3 (* The Compcert verified compiler *)
5 (* Xavier Leroy, INRIA Paris-Rocquencourt *)
7 (* Copyright Institut National de Recherche en Informatique et en *)
8 (* Automatique. All rights reserved. This file is distributed *)
9 (* under the terms of the GNU General Public License as published by *)
10 (* the Free Software Foundation, either version 2 of the License, or *)
11 (* (at your option) any later version. This file is also distributed *)
12 (* under the terms of the INRIA Non-Commercial License Agreement. *)
14 (* *********************************************************************)
16 (* Compiler built-ins *)
21 let env = ref Env.empty
25 let environment () = !env
26 let identifiers () = !idents
27 let declarations () = List.rev !decls
29 let add_typedef (s, ty) =
30 let (id, env') = Env.enter_typedef !env s ty in
32 idents := id :: !idents;
33 decls := {gdesc = Gtypedef(id, ty); gloc = no_loc} :: !decls
35 let add_function (s, (res, args, va)) =
38 Some (List.map (fun ty -> (Env.fresh_ident "", ty)) args),
40 let (id, env') = Env.enter_ident !env s Storage_extern ty in
42 idents := id :: !idents;
43 decls := {gdesc = Gdecl(Storage_extern, id, ty, None); gloc = no_loc} :: !decls
46 typedefs: (string * C.typ) list;
47 functions: (string * (C.typ * C.typ list * bool)) list
53 List.iter add_typedef blt.typedefs;
54 List.iter add_function blt.functions