[sledge] Improve using extended open

Summary:
OCaml 4.08 supports `open` of arbitrary module expressions. This
enables some code simplifications.

Reviewed By: ngorogiannis

Differential Revision: D18736381

fbshipit-source-id: c729dcfbd
master
Josh Berdine 5 years ago committed by Facebook Github Bot
parent 7ed8a6a260
commit cfbbacf9f1

@ -37,30 +37,29 @@ let scope_tbl :
Hashtbl.t =
Hashtbl.Poly.create ~size:32_768 ()
let ( (scan_names_and_locs : Llvm.llmodule -> unit)
, (find_name : Llvm.llvalue -> string)
, (find_loc : Llvm.llvalue -> Loc.t) ) =
open struct
open struct
let loc_of_global g =
Loc.mk
?dir:(Llvm.get_debug_loc_directory g)
?file:(Llvm.get_debug_loc_filename g)
~line:(Llvm.get_debug_loc_line g)
?col:None
in
let loc_of_function f =
Loc.mk
?dir:(Llvm.get_debug_loc_directory f)
?file:(Llvm.get_debug_loc_filename f)
~line:(Llvm.get_debug_loc_line f)
?col:None
in
let loc_of_instr i =
Loc.mk
?dir:(Llvm.get_debug_loc_directory i)
?file:(Llvm.get_debug_loc_filename i)
~line:(Llvm.get_debug_loc_line i)
~col:(Llvm.get_debug_loc_column i)
in
let add_sym llv loc =
let maybe_scope =
match Llvm.classify_value llv with
@ -121,8 +120,10 @@ let ( (scan_names_and_locs : Llvm.llmodule -> unit)
| exception _ -> name ) )
in
Hashtbl.set sym_tbl ~key:llv ~data:(name, loc)
in
let scan_names_and_locs m =
end
let scan_names_and_locs : Llvm.llmodule -> unit =
fun m ->
let scan_global g = add_sym g (loc_of_global g) in
let scan_instr i =
let loc = loc_of_instr i in
@ -152,10 +153,13 @@ let ( (scan_names_and_locs : Llvm.llmodule -> unit)
in
Llvm.iter_globals scan_global m ;
Llvm.iter_functions scan_function m
in
let find_name v = fst (Hashtbl.find_exn sym_tbl v) in
let find_loc v = snd (Hashtbl.find_exn sym_tbl v) in
(scan_names_and_locs, find_name, find_loc)
let find_name : Llvm.llvalue -> string =
fun v -> fst (Hashtbl.find_exn sym_tbl v)
let find_loc : Llvm.llvalue -> Loc.t =
fun v -> snd (Hashtbl.find_exn sym_tbl v)
end
let label_of_block : Llvm.llbasicblock -> string =
fun blk -> find_name (Llvm.value_of_block blk)

Loading…
Cancel
Save