method vglob_aux g =
match g with
| GFun (fundec,loc) ->
let kf = Extlib.the self#current_kf in
let vi = Kernel_function.get_vi kf in
let vi_pre = Cil_const.copy_with_new_vid vi in
vi_pre.vname <- Data_for_aorai.get_fresh (vi_pre.vname ^ "_pre_func");
Cil_datatype.Varinfo.Hashtbl.add func_orig_table vi_pre (Pre_func kf);
let (rettype,args,varargs,_) = Cil.splitFunctionTypeVI vi_pre in
vi_pre.vtype <- TFun(Cil.voidType, args, varargs,[]);
vi_pre.vattr <- [];
let arg =
if Cil.isVoidType rettype
then []
else ["res",rettype,[]]
in
let vi_post =
Cil.makeGlobalVar
(Data_for_aorai.get_fresh (vi.vname ^ "_post_func"))
(TFun(voidType,Some arg,false,[]))
in
Kernel_function.Hashtbl.add aux_post_table kf vi_post;
Cil_datatype.Varinfo.Hashtbl.add func_orig_table vi_post (Post_func kf);
let globs =
[ GVarDecl(Cil.empty_funspec (), vi_pre, loc);
GVarDecl(Cil.empty_funspec (), vi_post,loc) ]
in
fundec.sbody.bstmts <-
Cil.mkStmtOneInstr
(Call(None,Cil.evar ~loc vi_pre,
List.map (fun x -> Cil.evar ~loc x)
(Kernel_function.get_formals kf),
loc))
:: fundec.sbody.bstmts;
ChangeDoChildrenPost([g], fun x -> globs @ x)
| _ -> DoChildren