let get_behavior_annots config =
debug "build strategy for %a@." pp_strategy_info config;
let cfg = config.cfg in
let spec = Kernel_function.get_spec config.kf in
let annots = WpStrategy.create_tbl () in
let get_node_annot v =
debug "get_node_annot for node %a" Cil2cfg.pp_node v;
match Cil2cfg.node_type v with
| Cil2cfg.Vstart | Cil2cfg.Vend -> ()
| Cil2cfg.VfctIn ->
let pre = get_fct_pre_annots config spec in
WpStrategy.add_on_edges annots pre (Cil2cfg.succ_e cfg v)
| Cil2cfg.VfctOut ->
let post = get_fct_post_annots config Normal spec in
WpStrategy.add_on_edges annots post (Cil2cfg.succ_e cfg v)
| Cil2cfg.Vexit ->
let post = get_fct_post_annots config Exits spec in
WpStrategy.add_on_edges annots post (Cil2cfg.succ_e cfg v)
| Cil2cfg.VblkIn (Cil2cfg.Bstmt s, _)
| Cil2cfg.Vstmt s
| Cil2cfg.Vswitch (s,_) | Cil2cfg.Vtest (true, s, _)
->
let stmt_annots = get_stmt_annots config v s in
WpStrategy.add_node_annots annots cfg v stmt_annots
| Cil2cfg.Vcall (s,_,fct,_) ->
let stmt_annots = get_stmt_annots config v s in
WpStrategy.add_node_annots annots cfg v stmt_annots;
let call_annots = get_call_annots config v s fct in
WpStrategy.add_node_annots annots cfg v call_annots
| Cil2cfg.Vloop (_, s) ->
let stmt_annots = get_stmt_annots config v s in
let before, _after = stmt_annots in
WpStrategy.add_loop_annots annots cfg v ~entry:before
~back:WpStrategy.empty_acc ~core:WpStrategy.empty_acc;
debug "add_loop_annots stmt ok";
let (entry , back , core) = get_loop_annots config v s in
debug "get_loop_annots ok";
WpStrategy.add_loop_annots annots cfg v ~entry ~back ~core
| Cil2cfg.Vloop2 _ -> ()
| Cil2cfg.VblkIn (_, _) | Cil2cfg.VblkOut (_, _) -> ()
| Cil2cfg.Vtest (false, _s, _) -> ()
in
Cil2cfg.iter_nodes get_node_annot cfg;
annots