let builtin_why_file () =
let table = Hashtbl.create 7 in
let register_builtin bli =
try
let name = bli.bl_name in
let name = check_acsl_name name in
let ftype = match bli.bl_type with
| Some t -> Types.mk_ltype t
| None -> Types.prop_type
in
let get_type (_, t) = Types.mk_ltype t in
let arg_types = List.map get_type bli.bl_profile in
Hashtbl.add table name (arg_types, ftype)
with Types.Unsupported msg ->
Wp_parameters.warning
"unsupported type (%s) in builtin '%s' signature : ignored"
msg bli.bl_name
in
Logic_env.iter_builtin_logic_function register_builtin;
let add_decl name (arg_types, ret_type) acc =
let fdecl = Fol.Function (name, arg_types, ret_type) in
fdecl::acc
in
let decls = Hashtbl.fold add_decl table [] in
Wp_parameters.debug "builtin declarations =@.@[<hov2> %a@]@."
(Cilutil.print_list Cilutil.newline Why_output.decl) decls;
let filename = "builtin" in
let why_file = Why_output.build_why_file filename [] decls in
Wp_parameters.result "Builtin function declarations exported in %s"
why_file