Use Utils in jTransExn and jTransStaticField

Summary: public

Reviewed By: jeremydubreil

Differential Revision: D2938303

fb-gh-sync-id: c8c8ef6
shipit-source-id: c8c8ef6
master
Josh Berdine 9 years ago committed by facebook-github-bot-1
parent 7f231b8aa0
commit 8a9f221119

@ -8,6 +8,7 @@
* of patent rights can be found in the PATENTS file in the same directory.
*)
open Utils
open Javalib_pack
open Sawja_pack
@ -21,7 +22,7 @@ let create_handler_table impl =
Hashtbl.replace handler_tb pc (exn_handler:: handlers)
with Not_found ->
Hashtbl.add handler_tb pc [exn_handler] in
List.iter collect (JBir.exception_edges impl);
IList.iter collect (JBir.exception_edges impl);
handler_tb
let translate_exceptions context exit_nodes get_body_nodes handler_table =
@ -95,7 +96,8 @@ let translate_exceptions context exit_nodes get_body_nodes handler_table =
is_last_handler := false;
collect succ_nodes remove_temps rethrow_exception handler in
let nodes_first_handler = List.fold_left process_handler exit_nodes (List.rev handler_list) in
let nodes_first_handler =
IList.fold_left process_handler exit_nodes (IList.rev handler_list) in
let loc = match nodes_first_handler with
| n:: _ -> Cfg.Node.get_loc n
| [] -> Location.dummy in

@ -8,6 +8,7 @@
* of patent rights can be found in the PATENTS file in the same directory.
*)
open Utils
open Javalib_pack
open Sawja_pack
@ -23,8 +24,8 @@ let reset_pcs () =
field_nonfinal_pcs := []
let sort_pcs () =
field_final_pcs := (List.sort Pervasives.compare !field_final_pcs);
field_nonfinal_pcs := (List.sort Pervasives.compare !field_nonfinal_pcs)
field_final_pcs := (IList.sort Pervasives.compare !field_final_pcs);
field_nonfinal_pcs := (IList.sort Pervasives.compare !field_nonfinal_pcs)
let is_basic_type fs =
let vt = (JBasics.fs_type fs) in
@ -50,7 +51,7 @@ let collect_field_pc instrs field_pc_list =
field_pc_list := (fs, pc)::!field_pc_list
| _ -> () in
(Array.iteri aux instrs);
(List.rev !field_pc_list)
(IList.rev !field_pc_list)
(** Changes every position in the code where a static field is set to a value,
to returning that value *)
@ -70,7 +71,7 @@ let rec find_pc field list =
| (fs, pc):: rest ->
if JBasics.fs_equal field fs then
try
let (nfs, npc) = List.hd rest in
let (nfs, npc) = IList.hd rest in
npc + 1
with hd -> 1
else (find_pc field rest)
@ -82,14 +83,14 @@ let remove_nonfinal_instrs code end_pc =
sort_pcs ();
let rec aux2 pc =
let next_pc = pc + 1 in
if not (List.mem pc !field_final_pcs) && not (List.mem pc !field_nonfinal_pcs) then
if not (IList.mem (=) pc !field_final_pcs) && not (IList.mem (=) pc !field_nonfinal_pcs) then
begin
Array.set code pc JBir.Nop;
if next_pc < end_pc then aux2 next_pc
end
else () in
let aux pc instr =
if List.mem pc !field_nonfinal_pcs then
if IList.mem (=) pc !field_nonfinal_pcs then
begin
Array.set code pc JBir.Nop;
aux2 (pc +1)

Loading…
Cancel
Save