method vstmt_aux stmt =
let treat_loop body_ref stmt =
let vi_init =
Data_for_aorai.get_varinfo
(Data_for_aorai.loopInit^"_"^(string_of_int stmt.sid))
in
let loc = Cil_datatype.Stmt.loc stmt in
let stmt_varset =
Cil.mkStmtOneInstr
(Set((Var vi_init,NoOffset), Cil.zero ~loc, loc))
in
stmt_varset.sid<-(Cil.Sid.next ());
stmt_varset.ghost<-true;
begin
try
let rec skipEmpty = function
[] -> []
| {skind=Instr (Skip _);labels=[]} :: rest -> skipEmpty rest
| x -> x
in
match skipEmpty !body_ref.bstmts with
| {skind=If(_,tb,fb,_)} as head:: _ ->
begin
match skipEmpty tb.bstmts, skipEmpty fb.bstmts with
| _, {skind=Break _}:: _
| _, {skind=Goto _} :: _
| {skind=Goto _} :: _, _
| {skind=Break _} :: _, _ ->
!body_ref.bstmts <-
head :: stmt_varset :: List.tl !body_ref.bstmts
| _ ->
raise Not_found
end
| _ -> raise Not_found
with
| Not_found ->
!body_ref.bstmts<-stmt_varset::!body_ref.bstmts
end;
let new_loop = mkStmt stmt.skind in
new_loop.sid<-(Cil.Sid.next ());
let stmt_varset =
Cil.mkStmtOneInstr
(Set((Var(vi_init),NoOffset), Cil.one ~loc, loc))
in
stmt_varset.sid <- Cil.Sid.next ();
stmt_varset.ghost <- true;
let block = mkBlock [stmt_varset;new_loop] in
stmt.skind<-Block(block);
let mk_imply operator predicate =
pimplies
(prel(operator,
Aorai_utils.mk_term_from_vi vi_init,
Aorai_utils.zero_term()),
predicate)
in
let kf = Extlib.the self#current_kf in
let global_loop_inv = Aorai_utils.get_global_loop_inv stmt in
condition_to_invariant kf global_loop_inv new_loop;
let pre2 = Aorai_utils.get_restricted_int_pre_bc stmt in
if pre2.content <> Ptrue then
predicate_to_invariant kf new_loop pre2;
let pre1 = Aorai_utils.get_restricted_ext_pre_bc stmt in
if pre1.content <> Ptrue then
predicate_to_invariant kf new_loop (mk_imply Rneq pre1);
let post2 = Aorai_utils.get_restricted_int_post_bc stmt in
if post2.content <> Ptrue then
predicate_to_invariant kf new_loop (mk_imply Req post2);
let action_state =
Spec_tools.double_bool_array_or_bycase
(Data_for_aorai.get_loop_int_post_bycase stmt)
(Data_for_aorai.get_loop_ext_pre_bycase stmt)
in
let action_inv = get_action_invariant kf (Kstmt stmt) action_state in
List.iter (predicate_to_invariant kf new_loop) action_inv;
Hashtbl.add post_treatment_loops (ref stmt) (ref new_loop);
stmt
in
self#enter_block ();
let after s =
if self#leave_block () then
begin
let annots = Annotations.get_all_annotations stmt in
let annots =
List.map Annotations.get_code_annotation annots in
let specs =
snd (List.split (Logic_utils.extract_contract annots))
in
List.iter (update_assigns (Cil_datatype.Stmt.loc stmt)) specs;
s
end
else s
in
if treatloops then
match stmt.skind with
| Loop (_,block,_,_,_) ->
ChangeDoChildrenPost(stmt, after $ (treat_loop (ref block)))
| _ -> ChangeDoChildrenPost(stmt, after)
else
ChangeDoChildrenPost(stmt,after)