Core.Std.Array

Reviewed By: cristianoc

Differential Revision: D4232437

fbshipit-source-id: a9a1406
master
Josh Berdine 8 years ago committed by Facebook Github Bot
parent 7708fc7c56
commit c2abce7e3a

@ -52,5 +52,5 @@ let load_issues_to_errlog_map dir =
) !errLogMap map
| None -> () in
match children_opt with
| Some children -> Array.iter load_issues_to_map children
| Some children -> Array.iter ~f:load_issues_to_map children
| None -> ()

@ -106,13 +106,12 @@ let print_stack_info = ref false
(* replace a dollar sign in a name with a D. We need this because dotty get confused if there is*)
(* a dollar sign i a label*)
let strip_special_chars s =
let b = Bytes.of_string s in
let strip_special_chars b =
let replace st c c' =
if Bytes.contains st c then begin
let idx = Bytes.index st c in
if String.contains st c then begin
let idx = String.index_exn st c in
try
Bytes.set st idx c';
String.set st idx c';
st
with Invalid_argument _ -> L.out "@\n@\n Invalid argument!!! @\n @.@.@."; assert false
end else st in
@ -124,7 +123,7 @@ let strip_special_chars s =
let s5 = replace s4 ')' 'B' in
let s6 = replace s5 '+' 'P' in
let s7 = replace s6 '-' 'M' in
Bytes.to_string s7
s7
let rec strexp_to_string pe coo f se =
match se with

@ -113,7 +113,7 @@ let rec slink ~stats ~skiplevels src dst =
then Unix.mkdir dst ~perm:0o700;
let items = Sys.readdir src in
Array.iter
(fun item ->
~f:(fun item ->
slink ~stats ~skiplevels:(skiplevels - 1)
(Filename.concat src item) (Filename.concat dst item))
items

@ -188,8 +188,8 @@ module Results_dir = struct
let clean_specs_dir () =
create_dir specs_dir; (* create dir just in case it doesn't exist to avoid errors *)
let files_to_remove = Array.map (Filename.concat specs_dir) (Sys.readdir specs_dir) in
Array.iter Sys.remove files_to_remove
let files_to_remove = Array.map ~f:(Filename.concat specs_dir) (Sys.readdir specs_dir) in
Array.iter ~f:Sys.remove files_to_remove
(** create a file at the given path, creating any missing directories *)
let create_file pk path =
@ -245,13 +245,13 @@ let mark_file_updated fname =
(** Fold over all file paths recursively under [dir] which match [p]. *)
let fold_paths_matching ~dir ~p ~init ~f =
let rec paths path_list dir =
Array.fold_left
(fun acc file ->
Array.fold
~f:(fun acc file ->
let path = dir // file in
if Sys.is_directory path = `Yes then (paths acc path)
else if p path then f path acc
else acc)
path_list
~init:path_list
(Sys.readdir dir) in
paths init dir

@ -51,7 +51,7 @@ let compute_statistics values => {
let average = sum /. float_of_int num_elements;
let values_arr = Array.of_list values;
Array.sort
(
cmp::(
fun a b =>
if (a == b) {
0

@ -10,7 +10,10 @@
(** General utility functions and definition with global scope *)
module Arg = Core.Std.Arg
module Array = Core.Std.Array
module Bool = Core.Std.Bool
module Bytes = Core.Std.Bytes
module Caml = Core.Std.Caml
module Filename = Core.Std.Filename
module Fn = Core.Std.Fn
@ -465,7 +468,7 @@ let directory_fold f init path =
match dirs with
| [] -> accu
| d:: tl ->
let (new_accu, new_dirs) = Array.fold_left (collect d) (accu, tl) (Sys.readdir d) in
let (new_accu, new_dirs) = Array.fold ~f:(collect d) ~init:(accu, tl) (Sys.readdir d) in
loop new_accu new_dirs in
if Sys.is_directory path = `Yes then
loop init [path]
@ -488,7 +491,7 @@ let directory_iter f path =
match dirs with
| [] -> ()
| d:: tl ->
let new_dirs = Array.fold_left (apply d) tl (Sys.readdir d) in
let new_dirs = Array.fold ~f:(apply d) ~init:tl (Sys.readdir d) in
loop new_dirs in
if Sys.is_directory path = `Yes then
loop [path]

@ -10,7 +10,10 @@
(** General utility functions *)
module Arg = Core.Std.Arg
module Array = Core.Std.Array
module Bool = Core.Std.Bool
module Bytes = Core.Std.Bytes
module Caml = Core.Std.Caml
module Filename = Core.Std.Filename
module Fn = Core.Std.Fn

@ -515,7 +515,7 @@ let define_condition_side_effects e_cond instrs_cond sil_loc =
let fix_param_exps_mismatch params_stmt exps_param =
let diff = IList.length params_stmt - IList.length exps_param in
let args = if diff >0 then Array.make diff dummy_exp
let args = if diff >0 then Array.create ~len:diff dummy_exp
else assert false in
let exps'= exps_param @ (Array.to_list args) in
exps'

@ -71,7 +71,7 @@ let add_edges
if not super_call then
(* the exceptions node is just before the exit node *)
Procdesc.node_set_succs_exn context.procdesc exn_node exit_nodes exit_nodes;
Array.iteri connect_nodes method_body_nodes
Array.iteri ~f:connect_nodes method_body_nodes
(** Add a concrete method. *)
@ -90,7 +90,7 @@ let add_cmethod source_file program linereader icfg cm proc_name =
let instrs = JBir.code jbir_code in
let context =
JContext.create_context icfg procdesc jbir_code cn source_file program in
let method_body_nodes = Array.mapi (JTrans.instruction context) instrs in
let method_body_nodes = Array.mapi ~f:(JTrans.instruction context) instrs in
add_edges context start_node exn_node [exit_node] method_body_nodes jbir_code false

@ -172,11 +172,11 @@ let translate_locals program tenv formals bytecode jbir_code =
(* TODO (#4040807): Needs to add the JBir temporary variables since other parts of the
code are still relying on those *)
let with_jbir_vars =
Array.fold_left
(fun accu jbir_var ->
Array.fold
~f:(fun accu jbir_var ->
let var = Mangled.from_string (JBir.var_name_g jbir_var) in
collect accu (var, Typ.Tvoid))
with_bytecode_vars
~init:with_bytecode_vars
(JBir.vars jbir_code) in
snd with_jbir_vars
@ -245,7 +245,7 @@ let get_implementation cm =
let bytecode = Lazy.force t in
let c_code =
Array.map
(function
~f:(function
| (JCode.OpInvoke (`Dynamic _, ms)) ->
JCode.OpInvoke (`Static JBasics.java_lang_object, ms)
| opcode ->

Loading…
Cancel
Save