[pulse][easy] code factorisation

Summary: Two bits of code were re-implementing [eval_access].

Reviewed By: skcho

Differential Revision: D24832080

fbshipit-source-id: f6b0723c6
master
Jules Villard 4 years ago committed by Facebook GitHub Bot
parent e32f6ca360
commit 47e9f8ffec

@ -101,13 +101,11 @@ let eval location exp0 astate =
Ok (eval_var [ValueHistory.VariableAccessed (pvar, location)] (Var.of_pvar pvar) astate) Ok (eval_var [ValueHistory.VariableAccessed (pvar, location)] (Var.of_pvar pvar) astate)
| Lfield (exp', field, _) -> | Lfield (exp', field, _) ->
let* astate, addr_hist = eval exp' astate in let* astate, addr_hist = eval exp' astate in
let+ astate = check_addr_access location addr_hist astate in eval_access location addr_hist (FieldAccess field) astate
Memory.eval_edge addr_hist (FieldAccess field) astate
| Lindex (exp', exp_index) -> | Lindex (exp', exp_index) ->
let* astate, addr_hist_index = eval exp_index astate in let* astate, addr_hist_index = eval exp_index astate in
let* astate, addr_hist = eval exp' astate in let* astate, addr_hist = eval exp' astate in
let+ astate = check_addr_access location addr_hist astate in eval_access location addr_hist (ArrayAccess (StdTyp.void, fst addr_hist_index)) astate
Memory.eval_edge addr_hist (ArrayAccess (StdTyp.void, fst addr_hist_index)) astate
| Closure {name; captured_vars} -> | Closure {name; captured_vars} ->
let+ astate, rev_captured = let+ astate, rev_captured =
List.fold_result captured_vars ~init:(astate, []) List.fold_result captured_vars ~init:(astate, [])

Loading…
Cancel
Save