Skip to content

Commit d7a9e1c

Browse files
committed
not saving empty submodule's arity
it is not useful in general
1 parent 2b63cbc commit d7a9e1c

12 files changed

+130
-111
lines changed

jscomp/core/builtin_cmj_datasets.ml

+5-5
Large diffs are not rendered by default.

jscomp/core/lam_arity_analysis.ml

+4-4
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,17 @@ let rec get_arity (meta : Lam_stats.t) (lam : Lam.t) : Lam_arity.t =
4444
| Lvar v -> arity_of_var meta v
4545
| Lconst _ -> Lam_arity.non_function_arity_info
4646
| Llet(_,_,_, l ) -> get_arity meta l
47-
| Lprim {primitive = Pfield (_, Fld_module {name = fld_name});
47+
| Lprim {primitive = Pfield (_, Fld_module {name });
4848
args = [ Lglobal_module id ]; _} ->
49-
begin match (Lam_compile_env.query_external_id_info id fld_name).arity with
49+
begin match (Lam_compile_env.query_external_id_info id name).arity with
5050
| Single x -> x
5151
| Submodule _ -> Lam_arity.na
5252
end
5353
| Lprim {primitive = Pfield (m,_);
54-
args = [ Lprim{primitive = Pfield(n,Fld_module {name = fld_name});
54+
args = [ Lprim{primitive = Pfield(_,Fld_module {name });
5555
args = [ Lglobal_module id]} ]
5656
; _} ->
57-
begin match (Lam_compile_env.query_external_id_info id fld_name ).arity with
57+
begin match (Lam_compile_env.query_external_id_info id name).arity with
5858
| Submodule subs -> subs.(m) (* TODO: shall we store it as array?*)
5959
| Single _ -> Lam_arity.na
6060
end

jscomp/core/lam_compile.ml

+6-4
Original file line numberDiff line numberDiff line change
@@ -177,14 +177,14 @@ let rec
177177
compile_external_field (* Like [List.empty]*)
178178
(lamba_cxt : Lam_compile_context.t)
179179
(id : Ident.t)
180-
pos
180+
name
181181
: Js_output.t =
182-
match Lam_compile_env.query_external_id_info id pos with
182+
match Lam_compile_env.query_external_id_info id name with
183183
| { persistent_closed_lambda = Some lam}
184184
when Lam_util.not_function lam
185185
->
186186
compile_lambda lamba_cxt lam
187-
| { name} ->
187+
| _ ->
188188
Js_output.output_of_expression lamba_cxt.continuation
189189
~no_effects:no_effects_const
190190
(E.ml_var_dot id name )
@@ -254,7 +254,9 @@ and compile_external_field_apply
254254
E.call ~info:(call_info_of_ap_status ap_status) fn args
255255
| App_na ->
256256
match ident_info.arity with
257-
| Submodule _ -> E.call ~info:Js_call_info.dummy fn args
257+
| Submodule _
258+
| Single Arity_na
259+
-> E.call ~info:Js_call_info.dummy fn args
258260
| Single x ->
259261
apply_with_arity
260262
fn ~arity:(Lam_arity.extract_arity x) args

jscomp/core/lam_pass_remove_alias.ml

+2-3
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,8 @@ let simplify_alias
135135
end
136136
| _ -> true
137137
) ->
138-
simpl @@
139-
Lam_beta_reduce.propogate_beta_reduce
140-
meta params body args
138+
simpl (Lam_beta_reduce.propogate_beta_reduce
139+
meta params body args)
141140
| _ ->
142141
Lam.apply (simpl l1) (Ext_list.map args simpl) loc status
143142

jscomp/core/lam_stats_export.ml

+1-3
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,7 @@ let values_of_export
9999
match arity, persistent_closed_lambda with
100100
| Single Arity_na,
101101
(None | Some (Lconst (Const_pointer (_, Pt_module_alias)))) -> acc
102-
(* TODO: empty module can be saved too
103-
This is common since we have a module of externals quite common
104-
*)
102+
| Submodule [||], None -> acc
105103
| _ ->
106104
let cmj_value : Js_cmj_format.cmj_value =
107105
{arity ; persistent_closed_lambda } in

lib/4.06.1/bsb.ml

+3-1
Original file line numberDiff line numberDiff line change
@@ -6522,7 +6522,9 @@ type file_kind =
65226522
| Upper_bs
65236523
| Little_js
65246524
| Little_bs
6525-
(** [js_name_of_modulename ~little A-Ns]
6525+
6526+
6527+
(** [js_name_of_modulename ~little A-Ns]
65266528
*)
65276529
val js_name_of_modulename :
65286530
string ->

lib/4.06.1/bsb_helper.ml

+3-1
Original file line numberDiff line numberDiff line change
@@ -3760,7 +3760,9 @@ type file_kind =
37603760
| Upper_bs
37613761
| Little_js
37623762
| Little_bs
3763-
(** [js_name_of_modulename ~little A-Ns]
3763+
3764+
3765+
(** [js_name_of_modulename ~little A-Ns]
37643766
*)
37653767
val js_name_of_modulename :
37663768
string ->

lib/4.06.1/unstable/all_ounit_tests.ml

+3-1
Original file line numberDiff line numberDiff line change
@@ -16393,7 +16393,9 @@ type file_kind =
1639316393
| Upper_bs
1639416394
| Little_js
1639516395
| Little_bs
16396-
(** [js_name_of_modulename ~little A-Ns]
16396+
16397+
16398+
(** [js_name_of_modulename ~little A-Ns]
1639716399
*)
1639816400
val js_name_of_modulename :
1639916401
string ->

lib/4.06.1/unstable/bsb_native.ml

+3-1
Original file line numberDiff line numberDiff line change
@@ -6522,7 +6522,9 @@ type file_kind =
65226522
| Upper_bs
65236523
| Little_js
65246524
| Little_bs
6525-
(** [js_name_of_modulename ~little A-Ns]
6525+
6526+
6527+
(** [js_name_of_modulename ~little A-Ns]
65266528
*)
65276529
val js_name_of_modulename :
65286530
string ->

lib/4.06.1/unstable/js_compiler.ml

+35-31
Large diffs are not rendered by default.

lib/4.06.1/unstable/js_refmt_compiler.ml

+35-31
Large diffs are not rendered by default.

lib/4.06.1/whole_compiler.ml

+30-26
Original file line numberDiff line numberDiff line change
@@ -61650,7 +61650,9 @@ type file_kind =
6165061650
| Upper_bs
6165161651
| Little_js
6165261652
| Little_bs
61653-
(** [js_name_of_modulename ~little A-Ns]
61653+
61654+
61655+
(** [js_name_of_modulename ~little A-Ns]
6165461656
*)
6165561657
val js_name_of_modulename :
6165661658
string ->
@@ -83656,18 +83658,18 @@ val runtime_package_path:
8365683658
string ->
8365783659
string
8365883660

83659-
type package_info
83660-
=
83661-
{
83662-
module_system : module_system ;
83663-
path : string
83664-
}
83661+
type package_info = {
83662+
module_system : module_system ;
83663+
path : string
83664+
}
8366583665

8366683666
type t
8366783667

8366883668
val is_runtime_package:
8366983669
t ->
8367083670
bool
83671+
83672+
8367183673

8367283674
val same_package_by_name :
8367383675
t ->
@@ -86913,10 +86915,12 @@ val make:
8691386915
cmj_case:cmj_case ->
8691486916
t
8691586917

86916-
type keyed_cmj_value =
86917-
{ name : string ;
86918-
arity : arity ;
86919-
persistent_closed_lambda : Lam.t option}
86918+
type keyed_cmj_value = {
86919+
name : string ;
86920+
arity : arity ;
86921+
persistent_closed_lambda : Lam.t option
86922+
}
86923+
8692086924
val query_by_name :
8692186925
t ->
8692286926
string ->
@@ -86944,7 +86948,8 @@ val from_file_with_digest :
8694486948

8694586949
val from_string : string -> t
8694686950

86947-
(* Note writing the file if its content is not chnaged
86951+
(*
86952+
Note writing the file if its content is not changed
8694886953
*)
8694986954
val to_file :
8695086955
string -> check_exists:bool -> t -> unit
@@ -106647,17 +106652,17 @@ let rec get_arity (meta : Lam_stats.t) (lam : Lam.t) : Lam_arity.t =
106647106652
| Lvar v -> arity_of_var meta v
106648106653
| Lconst _ -> Lam_arity.non_function_arity_info
106649106654
| Llet(_,_,_, l ) -> get_arity meta l
106650-
| Lprim {primitive = Pfield (_, Fld_module {name = fld_name});
106655+
| Lprim {primitive = Pfield (_, Fld_module {name });
106651106656
args = [ Lglobal_module id ]; _} ->
106652-
begin match (Lam_compile_env.query_external_id_info id fld_name).arity with
106657+
begin match (Lam_compile_env.query_external_id_info id name).arity with
106653106658
| Single x -> x
106654106659
| Submodule _ -> Lam_arity.na
106655106660
end
106656106661
| Lprim {primitive = Pfield (m,_);
106657-
args = [ Lprim{primitive = Pfield(n,Fld_module {name = fld_name});
106662+
args = [ Lprim{primitive = Pfield(_,Fld_module {name });
106658106663
args = [ Lglobal_module id]} ]
106659106664
; _} ->
106660-
begin match (Lam_compile_env.query_external_id_info id fld_name ).arity with
106665+
begin match (Lam_compile_env.query_external_id_info id name).arity with
106661106666
| Submodule subs -> subs.(m) (* TODO: shall we store it as array?*)
106662106667
| Single _ -> Lam_arity.na
106663106668
end
@@ -115973,14 +115978,14 @@ let rec
115973115978
compile_external_field (* Like [List.empty]*)
115974115979
(lamba_cxt : Lam_compile_context.t)
115975115980
(id : Ident.t)
115976-
pos
115981+
name
115977115982
: Js_output.t =
115978-
match Lam_compile_env.query_external_id_info id pos with
115983+
match Lam_compile_env.query_external_id_info id name with
115979115984
| { persistent_closed_lambda = Some lam}
115980115985
when Lam_util.not_function lam
115981115986
->
115982115987
compile_lambda lamba_cxt lam
115983-
| { name} ->
115988+
| _ ->
115984115989
Js_output.output_of_expression lamba_cxt.continuation
115985115990
~no_effects:no_effects_const
115986115991
(E.ml_var_dot id name )
@@ -116050,7 +116055,9 @@ and compile_external_field_apply
116050116055
E.call ~info:(call_info_of_ap_status ap_status) fn args
116051116056
| App_na ->
116052116057
match ident_info.arity with
116053-
| Submodule _ -> E.call ~info:Js_call_info.dummy fn args
116058+
| Submodule _
116059+
| Single Arity_na
116060+
-> E.call ~info:Js_call_info.dummy fn args
116054116061
| Single x ->
116055116062
apply_with_arity
116056116063
fn ~arity:(Lam_arity.extract_arity x) args
@@ -403421,9 +403428,8 @@ let simplify_alias
403421403428
end
403422403429
| _ -> true
403423403430
) ->
403424-
simpl @@
403425-
Lam_beta_reduce.propogate_beta_reduce
403426-
meta params body args
403431+
simpl (Lam_beta_reduce.propogate_beta_reduce
403432+
meta params body args)
403427403433
| _ ->
403428403434
Lam.apply (simpl l1) (Ext_list.map args simpl) loc status
403429403435

@@ -403703,9 +403709,7 @@ let values_of_export
403703403709
match arity, persistent_closed_lambda with
403704403710
| Single Arity_na,
403705403711
(None | Some (Lconst (Const_pointer (_, Pt_module_alias)))) -> acc
403706-
(* TODO: empty module can be saved too
403707-
This is common since we have a module of externals quite common
403708-
*)
403712+
| Submodule [||], None -> acc
403709403713
| _ ->
403710403714
let cmj_value : Js_cmj_format.cmj_value =
403711403715
{arity ; persistent_closed_lambda } in

0 commit comments

Comments
 (0)