Summary: Some mild refactoring to isolate the modelling part. Reviewed By: mbouaziz Differential Revision: D10406804 fbshipit-source-id: 3be76a5e9master
parent
3821be4b7f
commit
7bd4aaa819
@ -0,0 +1,41 @@
|
|||||||
|
(*
|
||||||
|
* Copyright (c) 2018-present, Facebook, Inc.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*)
|
||||||
|
open! IStd
|
||||||
|
|
||||||
|
type exec_fun = ret:Var.t -> actuals:HilExp.t list -> PulseDomain.t -> PulseDomain.access_result
|
||||||
|
|
||||||
|
type model = exec_fun
|
||||||
|
|
||||||
|
module Cplusplus = struct
|
||||||
|
let delete : model =
|
||||||
|
fun ~ret:_ ~actuals astate ->
|
||||||
|
match actuals with
|
||||||
|
| [AccessExpression deleted_access] ->
|
||||||
|
PulseDomain.invalidate deleted_access astate
|
||||||
|
| _ ->
|
||||||
|
Ok astate
|
||||||
|
end
|
||||||
|
|
||||||
|
let builtins_dispatcher =
|
||||||
|
let builtins = [(BuiltinDecl.__delete, Cplusplus.delete)] in
|
||||||
|
let builtins_map =
|
||||||
|
Hashtbl.create
|
||||||
|
( module struct
|
||||||
|
include Typ.Procname
|
||||||
|
|
||||||
|
let hash = Caml.Hashtbl.hash
|
||||||
|
|
||||||
|
let sexp_of_t _ = assert false
|
||||||
|
end )
|
||||||
|
in
|
||||||
|
List.iter builtins ~f:(fun (builtin, model) ->
|
||||||
|
let open PolyVariantEqual in
|
||||||
|
assert (Hashtbl.add builtins_map ~key:builtin ~data:model = `Ok) ) ;
|
||||||
|
fun proc_name -> Hashtbl.find builtins_map proc_name
|
||||||
|
|
||||||
|
|
||||||
|
let dispatch proc_name = builtins_dispatcher proc_name
|
@ -0,0 +1,13 @@
|
|||||||
|
(*
|
||||||
|
* Copyright (c) 2018-present, Facebook, Inc.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*)
|
||||||
|
open! IStd
|
||||||
|
|
||||||
|
type exec_fun = ret:Var.t -> actuals:HilExp.t list -> PulseDomain.t -> PulseDomain.access_result
|
||||||
|
|
||||||
|
type model = exec_fun
|
||||||
|
|
||||||
|
val dispatch : Typ.Procname.t -> model option
|
Loading…
Reference in new issue