let get_fct_bhv_from_annots cfg bhv nth assign =
let kf = Cil2cfg.cfg_kf cfg in
let asked_bhv = bhv.b_name in
let annots = WpStrategy.create_tbl () in
let add_post v tk = match mk_assign_post kf bhv nth tk assign with
| None -> ()
| Some post ->
let edges = Cil2cfg.succ_e cfg v in
let acc = WpStrategy.empty_acc in
let kind = WpStrategy.Agoal in
let labels = NormAtLabels.labels_fct_assigns in
let id = WpPropId.mk_fct_from_id kf bhv tk assign in
let post = Logic_const.pred_of_id_pred post in
let acc = WpStrategy.add_prop acc kind labels id post in
WpStrategy.add_on_edges annots acc edges
in
let add_stmt_annots v s =
let l_post = Cil2cfg.get_post_logic_label cfg v in
let stmt_annots = get_stmt_hyp kf asked_bhv s l_post in
WpStrategy.add_node_annots annots cfg v stmt_annots
in
let get_node_annot v =
match Cil2cfg.node_type v with
| Cil2cfg.VfctIn -> ()
| Cil2cfg.VfctOut -> add_post v Normal
| Cil2cfg.Vexit -> add_post v Exits
| Cil2cfg.VblkIn (Cil2cfg.Bstmt s, _)
| Cil2cfg.Vstmt s
| Cil2cfg.Vswitch (s,_) | Cil2cfg.Vtest (true, s, _)
-> add_stmt_annots v s
| Cil2cfg.Vcall (s,_,fct,_) ->
let l_post = Cil2cfg.get_post_logic_label cfg v in
let call_annots = get_call_hyp kf s l_post fct in
WpStrategy.add_node_annots annots cfg v call_annots
| Cil2cfg.Vloop (_, s) ->
add_stmt_annots v s;
let loop_core =
add_loop_assigns_hyp kf asked_bhv s WpStrategy.empty_acc in
let edges_to_head = Cil2cfg.succ_e cfg v in
WpStrategy.add_on_edges annots loop_core edges_to_head
| _ -> ()
in
let _ = Cil2cfg.iter_nodes get_node_annot cfg in
annots