diff options
author | Gabriel Scherer <gabriel.scherer@gmail.com> | 2019-05-24 15:24:33 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-24 15:24:33 +0200 |
commit | 101cd9e274b5b368ee7494d8508cd2d5862e0b02 (patch) | |
tree | 5b431218557d4129bd76b04609f83c0bd7005ab5 /middle_end | |
parent | e973cde5a479af088b31de7a1f295256242d3fac (diff) | |
parent | d3ae49c9aad3a620a7878468bf3ce575fb36a78f (diff) | |
download | ocaml-101cd9e274b5b368ee7494d8508cd2d5862e0b02.tar.gz |
Merge pull request #8692 from lpw25/remove-may-map
Remove Misc.may_map and similar
Diffstat (limited to 'middle_end')
-rw-r--r-- | middle_end/closure/closure.ml | 8 | ||||
-rw-r--r-- | middle_end/flambda/closure_conversion.ml | 4 | ||||
-rw-r--r-- | middle_end/flambda/effect_analysis.ml | 6 | ||||
-rw-r--r-- | middle_end/flambda/export_info_for_pack.ml | 2 | ||||
-rw-r--r-- | middle_end/flambda/flambda.ml | 8 | ||||
-rw-r--r-- | middle_end/flambda/flambda_invariants.ml | 4 | ||||
-rw-r--r-- | middle_end/flambda/flambda_iterators.ml | 4 | ||||
-rw-r--r-- | middle_end/flambda/flambda_to_clambda.ml | 2 | ||||
-rw-r--r-- | middle_end/flambda/inconstant_idents.ml | 4 | ||||
-rw-r--r-- | middle_end/flambda/inlining_cost.ml | 2 | ||||
-rw-r--r-- | middle_end/flambda/ref_to_variables.ml | 4 | ||||
-rw-r--r-- | middle_end/flambda/simple_value_approx.ml | 2 | ||||
-rw-r--r-- | middle_end/flambda/un_anf.ml | 8 |
13 files changed, 28 insertions, 30 deletions
diff --git a/middle_end/closure/closure.ml b/middle_end/closure/closure.ml index 20767f623f..ef657569f3 100644 --- a/middle_end/closure/closure.ml +++ b/middle_end/closure/closure.ml @@ -184,7 +184,7 @@ let lambda_smaller lam threshold = size := !size+2 ; lambda_size lam) sw ; - Misc.may lambda_size d + Option.iter lambda_size d | Ustaticfail (_,args) -> lambda_list_size args | Ucatch(_, _, body, handler) -> incr size; lambda_size body; lambda_size handler @@ -627,7 +627,7 @@ let rec substitute loc ((backend, fpc) as st) sb rn ulam = Ustringswitch (substitute loc st sb rn arg, List.map (fun (s,act) -> s,substitute loc st sb rn act) sw, - Misc.may_map (substitute loc st sb rn) d) + Option.map (substitute loc st sb rn) d) | Ustaticfail (nfail, args) -> let nfail = match rn with @@ -1116,7 +1116,7 @@ let rec close ({ backend; fenv; cenv } as env) lam = s,uact) sw in let ud = - Misc.may_map + Option.map (fun d -> let ud,_ = close env d in ud) d in @@ -1433,7 +1433,7 @@ let collect_exported_structured_constants a = | Ustringswitch (u,sw,d) -> ulam u ; List.iter (fun (_,act) -> ulam act) sw ; - Misc.may ulam d + Option.iter ulam d | Ustaticfail (_, ul) -> List.iter ulam ul | Ucatch (_, _, u1, u2) | Utrywith (u1, _, u2) diff --git a/middle_end/flambda/closure_conversion.ml b/middle_end/flambda/closure_conversion.ml index 9bdd30ead9..a89d755e0e 100644 --- a/middle_end/flambda/closure_conversion.ml +++ b/middle_end/flambda/closure_conversion.ml @@ -502,14 +502,14 @@ let rec close t env (lam : Lambda.lambda) : Flambda.t = consts = List.map aux sw.sw_consts; numblocks = nums sw.sw_numblocks sw.sw_blocks sw.sw_failaction; blocks = List.map aux sw.sw_blocks; - failaction = Misc.may_map (close t env) sw.sw_failaction; + failaction = Option.map (close t env) sw.sw_failaction; })) | Lstringswitch (arg, sw, def, _) -> let scrutinee = Variable.create Names.string_switch in Flambda.create_let scrutinee (Expr (close t env arg)) (String_switch (scrutinee, List.map (fun (s, e) -> s, close t env e) sw, - Misc.may_map (close t env) def)) + Option.map (close t env) def)) | Lstaticraise (i, args) -> Lift_code.lifting_helper (close_list t env args) ~evaluation_order:`Right_to_left diff --git a/middle_end/flambda/effect_analysis.ml b/middle_end/flambda/effect_analysis.ml index d0cbd44180..2ddba764bc 100644 --- a/middle_end/flambda/effect_analysis.ml +++ b/middle_end/flambda/effect_analysis.ml @@ -37,12 +37,10 @@ let rec no_effects (flam : Flambda.t) = let aux (_, flam) = no_effects flam in List.for_all aux sw.blocks && List.for_all aux sw.consts - && Misc.Stdlib.Option.value_default no_effects sw.failaction - ~default:true + && Option.fold ~some:no_effects ~none:true sw.failaction | String_switch (_, sw, def) -> List.for_all (fun (_, lam) -> no_effects lam) sw - && Misc.Stdlib.Option.value_default no_effects def - ~default:true + && Option.fold ~some:no_effects ~none:true def | Static_catch (_, _, body, _) | Try_with (body, _, _) -> (* If there is a [raise] in [body], the whole [Try_with] may have an effect, so there is no need to test the handler. *) diff --git a/middle_end/flambda/export_info_for_pack.ml b/middle_end/flambda/export_info_for_pack.ml index 42a8155347..ebed559369 100644 --- a/middle_end/flambda/export_info_for_pack.ml +++ b/middle_end/flambda/export_info_for_pack.ml @@ -89,7 +89,7 @@ let import_set_of_closures units pack Closure_id.Map.map (import_approx_for_pack units pack) set_of_closures.results; aliased_symbol = - Misc.may_map + Option.map (import_symbol_for_pack units pack) set_of_closures.aliased_symbol; } diff --git a/middle_end/flambda/flambda.ml b/middle_end/flambda/flambda.ml index aea872f901..70adfcb939 100644 --- a/middle_end/flambda/flambda.ml +++ b/middle_end/flambda/flambda.ml @@ -565,11 +565,11 @@ let rec variables_usage ?ignore_uses_as_callee ?ignore_uses_as_argument free_variable scrutinee; List.iter (fun (_, e) -> aux e) switch.consts; List.iter (fun (_, e) -> aux e) switch.blocks; - Misc.may aux switch.failaction + Option.iter aux switch.failaction | String_switch (scrutinee, cases, failaction) -> free_variable scrutinee; List.iter (fun (_, e) -> aux e) cases; - Misc.may aux failaction + Option.iter aux failaction | Static_raise (_, es) -> List.iter free_variable es | Static_catch (_, vars, e1, e2) -> @@ -789,10 +789,10 @@ let iter_general ~toplevel f f_named maybe_named = | Switch (_, sw) -> List.iter (fun (_,l) -> aux l) sw.consts; List.iter (fun (_,l) -> aux l) sw.blocks; - Misc.may aux sw.failaction + Option.iter aux sw.failaction | String_switch (_, sw, def) -> List.iter (fun (_,l) -> aux l) sw; - Misc.may aux def + Option.iter aux def and aux_named (named : named) = f_named named; match named with diff --git a/middle_end/flambda/flambda_invariants.ml b/middle_end/flambda/flambda_invariants.ml index 250a2e9af7..6c2b572d96 100644 --- a/middle_end/flambda/flambda_invariants.ml +++ b/middle_end/flambda/flambda_invariants.ml @@ -213,14 +213,14 @@ let variable_and_symbol_invariants (program : Flambda.program) = ignore_int n; loop env e) (consts @ blocks); - Misc.may (loop env) failaction + Option.iter (loop env) failaction | String_switch (arg, cases, e_opt) -> check_variable_is_bound env arg; List.iter (fun (label, case) -> ignore_string label; loop env case) cases; - Misc.may (loop env) e_opt + Option.iter (loop env) e_opt | Static_raise (static_exn, es) -> ignore_static_exception static_exn; List.iter (check_variable_is_bound env) es diff --git a/middle_end/flambda/flambda_iterators.ml b/middle_end/flambda/flambda_iterators.ml index a69575da63..6edc4bba3b 100644 --- a/middle_end/flambda/flambda_iterators.ml +++ b/middle_end/flambda/flambda_iterators.ml @@ -32,10 +32,10 @@ let apply_on_subexpressions f f_named (flam : Flambda.t) = | Switch (_, sw) -> List.iter (fun (_,l) -> f l) sw.consts; List.iter (fun (_,l) -> f l) sw.blocks; - Misc.may f sw.failaction + Option.iter f sw.failaction | String_switch (_, sw, def) -> List.iter (fun (_,l) -> f l) sw; - Misc.may f def + Option.iter f def | Static_catch (_,_,f1,f2) -> f f1; f f2; | Try_with (f1,_,f2) -> diff --git a/middle_end/flambda/flambda_to_clambda.ml b/middle_end/flambda/flambda_to_clambda.ml index 9d6ea1518f..d53034c8ed 100644 --- a/middle_end/flambda/flambda_to_clambda.ml +++ b/middle_end/flambda/flambda_to_clambda.ml @@ -313,7 +313,7 @@ let rec to_clambda t env (flam : Flambda.t) : Clambda.ulambda = | String_switch (arg, sw, def) -> let arg = subst_var env arg in let sw = List.map (fun (s, e) -> s, to_clambda t env e) sw in - let def = Misc.may_map (to_clambda t env) def in + let def = Option.map (to_clambda t env) def in Ustringswitch (arg, sw, def) | Static_raise (static_exn, args) -> Ustaticfail (Static_exception.to_int static_exn, diff --git a/middle_end/flambda/inconstant_idents.ml b/middle_end/flambda/inconstant_idents.ml index 59f8aa8a8c..28efb3e94a 100644 --- a/middle_end/flambda/inconstant_idents.ml +++ b/middle_end/flambda/inconstant_idents.ml @@ -286,12 +286,12 @@ module Inconstants (P:Param) (Backend:Backend_intf.S) = struct mark_var arg curr; List.iter (fun (_,l) -> mark_loop ~toplevel [] l) sw.consts; List.iter (fun (_,l) -> mark_loop ~toplevel [] l) sw.blocks; - Misc.may (fun l -> mark_loop ~toplevel [] l) sw.failaction + Option.iter (fun l -> mark_loop ~toplevel [] l) sw.failaction | String_switch (arg,sw,def) -> mark_curr curr; mark_var arg curr; List.iter (fun (_,l) -> mark_loop ~toplevel [] l) sw; - Misc.may (fun l -> mark_loop ~toplevel [] l) def + Option.iter (fun l -> mark_loop ~toplevel [] l) def | Send { kind = _; meth; obj; args; dbg = _; } -> mark_curr curr; mark_var meth curr; diff --git a/middle_end/flambda/inlining_cost.ml b/middle_end/flambda/inlining_cost.ml index 33e870f90a..3ca1d2225a 100644 --- a/middle_end/flambda/inlining_cost.ml +++ b/middle_end/flambda/inlining_cost.ml @@ -99,7 +99,7 @@ let lambda_smaller' lam ~than:threshold = size := !size + 2; lambda_size lam) sw; - Misc.may lambda_size def + Option.iter lambda_size def | Static_raise _ -> () | Static_catch (_, _, body, handler) -> incr size; lambda_size body; lambda_size handler diff --git a/middle_end/flambda/ref_to_variables.ml b/middle_end/flambda/ref_to_variables.ml index f93948f912..aa2a73c630 100644 --- a/middle_end/flambda/ref_to_variables.ml +++ b/middle_end/flambda/ref_to_variables.ml @@ -60,11 +60,11 @@ let variables_not_used_as_local_reference (tree:Flambda.t) = set := Variable.Set.add cond !set; List.iter (fun (_, branch) -> loop branch) consts; List.iter (fun (_, branch) -> loop branch) blocks; - Misc.may loop failaction + Option.iter loop failaction | String_switch (cond, branches, default) -> set := Variable.Set.add cond !set; List.iter (fun (_, branch) -> loop branch) branches; - Misc.may loop default + Option.iter loop default | Static_catch (_, _, body, handler) -> loop body; loop handler diff --git a/middle_end/flambda/simple_value_approx.ml b/middle_end/flambda/simple_value_approx.ml index 34fc5ce056..fcd8e4d77c 100644 --- a/middle_end/flambda/simple_value_approx.ml +++ b/middle_end/flambda/simple_value_approx.ml @@ -290,7 +290,7 @@ let value_closure ?closure_var ?set_of_closures_var ?set_of_closures_symbol let approx_set_of_closures = { descr = Value_set_of_closures value_set_of_closures; var = set_of_closures_var; - symbol = Misc.may_map (fun s -> s, None) set_of_closures_symbol; + symbol = Option.map (fun s -> s, None) set_of_closures_symbol; } in let value_closure = diff --git a/middle_end/flambda/un_anf.ml b/middle_end/flambda/un_anf.ml index 19b04d85a4..c9a095b5cb 100644 --- a/middle_end/flambda/un_anf.ml +++ b/middle_end/flambda/un_anf.ml @@ -152,7 +152,7 @@ let make_var_info (clam : Clambda.ulambda) : var_info = ignore_string str; loop branch) branches; - Misc.may loop default + Option.iter loop default | Ustaticfail (static_exn, args) -> ignore_int static_exn; List.iter loop args @@ -354,7 +354,7 @@ let let_bound_vars_that_can_be_moved var_info (clam : Clambda.ulambda) = loop branch) branches; let_stack := []; - Misc.may loop default; + Option.iter loop default; let_stack := [] | Ustaticfail (static_exn, args) -> ignore_int static_exn; @@ -516,7 +516,7 @@ let rec substitute_let_moveable is_let_moveable env (clam : Clambda.ulambda) branches in let default = - Misc.may_map (substitute_let_moveable is_let_moveable env) default + Option.map (substitute_let_moveable is_let_moveable env) default in Ustringswitch (cond, branches, default) | Ustaticfail (n, args) -> @@ -735,7 +735,7 @@ let rec un_anf_and_moveable var_info env (clam : Clambda.ulambda) List.map (fun (s, branch) -> s, un_anf var_info env branch) branches in - let default = Misc.may_map (un_anf var_info env) default in + let default = Option.map (un_anf var_info env) default in Ustringswitch (cond, branches, default), Fixed | Ustaticfail (n, args) -> let args = un_anf_list var_info env args in |