refactoring procCfg API to make it easier to mock

Reviewed By: jeremydubreil

Differential Revision: D2984618

fb-gh-sync-id: b332ddb
shipit-source-id: b332ddb
master
Sam Blackshear 9 years ago committed by Facebook Github Bot 6
parent 2d89426170
commit 65de2d9946

@ -19,16 +19,16 @@ module type Wrapper = sig
type node type node
type node_id type node_id
val get_node_id : node -> node_id val node_id : node -> node_id
val get_succs : node -> node list val succs : t -> node -> node list
val get_exn_succs : node -> node list val exn_succs : t -> node -> node list
val get_preds : node -> node list val preds : t -> node -> node list
val get_start_node : t -> node val start_node : t -> node
val get_exit_node : t -> node val exit_node : t -> node
val get_instrs : node -> Sil.instr list val instrs : node -> Sil.instr list
val get_kind : node -> Cfg.Node.nodekind val kind : node -> Cfg.Node.nodekind
val get_proc_desc : t -> Cfg.Procdesc.t val proc_desc : t -> Cfg.Procdesc.t
val get_nodes : t -> node list val nodes : t -> node list
val from_pdesc : Cfg.Procdesc.t -> t val from_pdesc : Cfg.Procdesc.t -> t
@ -44,16 +44,16 @@ module Forward : Wrapper with type node = Cfg.node = struct
type node = Cfg.node type node = Cfg.node
type node_id = int type node_id = int
let get_node_id = Cfg.Node.get_id let node_id = Cfg.Node.get_id
let get_succs = Cfg.Node.get_succs let succs _ n = Cfg.Node.get_succs n
let get_exn_succs = Cfg.Node.get_exn let exn_succs _ n = Cfg.Node.get_exn n
let get_preds = Cfg.Node.get_preds let preds _ n = Cfg.Node.get_preds n
let get_start_node = Cfg.Procdesc.get_start_node let start_node = Cfg.Procdesc.get_start_node
let get_exit_node = Cfg.Procdesc.get_exit_node let exit_node = Cfg.Procdesc.get_exit_node
let get_instrs = Cfg.Node.get_instrs let instrs = Cfg.Node.get_instrs
let get_kind = Cfg.Node.get_kind let kind = Cfg.Node.get_kind
let get_proc_desc t = t let proc_desc t = t
let get_nodes = Cfg.Procdesc.get_nodes let nodes = Cfg.Procdesc.get_nodes
let from_pdesc pdesc = pdesc let from_pdesc pdesc = pdesc
@ -67,14 +67,14 @@ end
module Backward (W : Wrapper) : Wrapper = struct module Backward (W : Wrapper) : Wrapper = struct
include W include W
let get_succs = W.get_preds let succs = W.preds
let get_preds = W.get_succs let preds = W.succs
let get_start_node = W.get_exit_node let start_node = W.exit_node
let get_exit_node = W.get_start_node let exit_node = W.start_node
let get_instrs t = IList.rev (W.get_instrs t) let instrs t = IList.rev (W.instrs t)
(* TODO: we'll need to change the CFG to implement this correctly *) (* TODO: we'll need to change the CFG to implement this correctly *)
let get_exn_succs _ = let exn_succs _ =
failwith "Getting exceptional preds in backward analysis" failwith "Getting exceptional preds in backward analysis"
end end

Loading…
Cancel
Save