Summary: `State` is used by the AI framework, which isn't supposed to know about biabduction/. Split the biabduction-specific parts into biabduction/State.ml and keep the rest in absint/AnalysisState.ml. Reviewed By: ngorogiannis Differential Revision: D21257470 fbshipit-source-id: e01d1fed3master
parent
0859f61695
commit
be101b6bb4
@ -0,0 +1,60 @@
|
||||
(*
|
||||
* Copyright (c) 2009-2013, Monoidics ltd.
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*)
|
||||
|
||||
open! IStd
|
||||
|
||||
(** State of symbolic execution *)
|
||||
|
||||
type t =
|
||||
{ mutable last_instr: Sil.instr option (** Last instruction seen *)
|
||||
; mutable last_node: Procdesc.Node.t option (** Last node seen *)
|
||||
; mutable last_session: int (** Last session seen *) }
|
||||
|
||||
let initial () = {last_instr= None; last_node= None; last_session= 0}
|
||||
|
||||
(** Global state *)
|
||||
let gs = ref (initial ())
|
||||
|
||||
let get_instr () = !gs.last_instr
|
||||
|
||||
let set_instr instr = !gs.last_instr <- Some instr
|
||||
|
||||
let get_node_exn () = Option.value_exn !gs.last_node
|
||||
|
||||
let get_node () = !gs.last_node
|
||||
|
||||
let set_node (node : Procdesc.Node.t) =
|
||||
!gs.last_instr <- None ;
|
||||
!gs.last_node <- Some node
|
||||
|
||||
|
||||
let get_session () = !gs.last_session
|
||||
|
||||
let set_session (session : int) = !gs.last_session <- session
|
||||
|
||||
let get_loc_exn () =
|
||||
match !gs.last_instr with
|
||||
| Some instr ->
|
||||
Sil.location_of_instr instr
|
||||
| None ->
|
||||
get_node_exn () |> Procdesc.Node.get_loc
|
||||
|
||||
|
||||
let get_loc () =
|
||||
match !gs.last_instr with Some instr -> Some (Sil.location_of_instr instr) | None -> None
|
||||
|
||||
|
||||
(** Return the old state, and revert the current state to the initial one. *)
|
||||
let save () =
|
||||
let old = !gs in
|
||||
gs := initial () ;
|
||||
old
|
||||
|
||||
|
||||
(** Restore the old state. *)
|
||||
let restore st = gs := st
|
@ -0,0 +1,48 @@
|
||||
(*
|
||||
* Copyright (c) 2009-2013, Monoidics ltd.
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*)
|
||||
|
||||
open! IStd
|
||||
|
||||
(** State of symbolic execution *)
|
||||
|
||||
type t
|
||||
|
||||
val get_instr : unit -> Sil.instr option
|
||||
(** Get last instruction seen in symbolic execution *)
|
||||
|
||||
val get_loc_exn : unit -> Location.t
|
||||
(** Get last location seen in symbolic execution *)
|
||||
|
||||
val get_loc : unit -> Location.t option
|
||||
(** Get last location seen in symbolic execution *)
|
||||
|
||||
val get_node_exn : unit -> Procdesc.Node.t
|
||||
(** Get last node seen in symbolic execution *)
|
||||
|
||||
val get_node : unit -> Procdesc.Node.t option
|
||||
(** Get last node seen in symbolic execution *)
|
||||
|
||||
val get_session : unit -> int
|
||||
(** Get last session seen in symbolic execution *)
|
||||
|
||||
val set_instr : Sil.instr -> unit
|
||||
(** Set last instruction seen in symbolic execution *)
|
||||
|
||||
val set_node : Procdesc.Node.t -> unit
|
||||
(** Set last node seen in symbolic execution *)
|
||||
|
||||
val set_session : int -> unit
|
||||
(** Set last session seen in symbolic execution *)
|
||||
|
||||
(** {2 State management} *)
|
||||
|
||||
val restore : t -> unit
|
||||
(** Restore the old state. *)
|
||||
|
||||
val save : unit -> t
|
||||
(** Return the old state, and revert the current state to the initial one. *)
|
Loading…
Reference in new issue