Skip to content

Commit afa0d5f

Browse files
committed
meaningful names (App_uncurry/App_infer_ful), fix apply location
1 parent 015f2ef commit afa0d5f

File tree

8 files changed

+64
-72
lines changed

8 files changed

+64
-72
lines changed

jscomp/core/lam.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ type ident = Ident.t
2626

2727
type apply_status =
2828
| App_na
29-
| App_ml_full
30-
| App_js_full
29+
| App_infer_full
30+
| App_uncurry
3131

3232

3333
module Types = struct

jscomp/core/lam.mli

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ type lambda_switch =
3737
sw_names: Lambda.switch_names option }
3838
and apply_status =
3939
| App_na
40-
| App_ml_full
41-
| App_js_full
40+
| App_infer_full
41+
| App_uncurry
4242
and apply_info = private
4343
{ ap_func : t ;
4444
ap_args : t list ;

jscomp/core/lam_compile.ml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ module S = Js_stmt_make
2828

2929
let call_info_of_ap_status (ap_status : Lam.apply_status) : Js_call_info.t =
3030
match ap_status with
31-
| App_ml_full ->
31+
| App_infer_full ->
3232
{arity = Full ; call_info = Call_ml}
33-
| App_js_full ->
33+
| App_uncurry ->
3434
{arity = Full ; call_info = Call_na}
3535
| App_na ->
3636
{arity = NA; call_info = Call_ml }
@@ -250,7 +250,7 @@ and compile_external_field_apply
250250
let fn = E.ml_var_dot module_id ident_info.name in
251251
let expression =
252252
match appinfo.ap_status with
253-
| App_ml_full | App_js_full as ap_status ->
253+
| App_infer_full | App_uncurry as ap_status ->
254254
E.call ~info:(call_info_of_ap_status ap_status) fn args
255255
| App_na ->
256256
match ident_info.arity with
@@ -1454,10 +1454,10 @@ and compile_prim (prim_info : Lam.prim_info) (lambda_cxt : Lam_compile_context.t
14541454
Pjs_unsafe_downgrade {name = property; loc; setter = true};
14551455
} :: _
14561456
} -> assert false
1457-
| {primitive = Pjs_fn_run _ | Pmethod_run ; args}
1457+
| {primitive = Pjs_fn_run _ | Pmethod_run ; args; loc}
14581458
->
1459-
(* 1. prevent eta-conversion
1460-
by using [App_js_full]
1459+
(* 1. uncurried call should not do eta-conversion
1460+
since `fn.length` will broken
14611461
2. invariant: `external` declaration will guarantee
14621462
the function application is saturated
14631463
3. we need a location for Pccall in the call site
@@ -1466,9 +1466,7 @@ and compile_prim (prim_info : Lam.prim_info) (lambda_cxt : Lam_compile_context.t
14661466
(match args with
14671467
| fn :: rest ->
14681468
compile_lambda lambda_cxt
1469-
(Lam.apply fn rest
1470-
Location.none (*TODO*)
1471-
App_js_full)
1469+
(Lam.apply fn rest loc App_uncurry)
14721470
| [] -> assert false)
14731471

14741472
| {primitive = Pjs_fn_method arity; args = args_lambda} ->

jscomp/core/lam_eta_conversion.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ let unsafe_adjust_to_arity loc ~(to_:int) ?(from : int option) (fn : Lam.t) : La
191191
~params:extra_args
192192
~body:(
193193
let first_args, rest_args = Ext_list.split_at extra_args from in
194-
Lam.apply (Lam.apply new_fn (Ext_list.map first_args Lam.var) loc App_ml_full) (Ext_list.map rest_args Lam.var) loc App_na ) in
194+
Lam.apply (Lam.apply new_fn (Ext_list.map first_args Lam.var) loc App_infer_full) (Ext_list.map rest_args Lam.var) loc App_na ) in
195195
begin match wrapper with
196196
| None -> cont
197197
| Some partial_arg ->
@@ -245,7 +245,7 @@ let unsafe_adjust_to_arity loc ~(to_:int) ?(from : int option) (fn : Lam.t) : La
245245
(Ext_list.map extra_inner_args Lam.var)
246246
Lam.var
247247
)
248-
loc App_ml_full)
248+
loc App_infer_full)
249249
) in
250250
begin match wrapper with
251251
| None -> cont

jscomp/core/lam_pass_alpha_conversion.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,19 @@ let alpha_conversion (meta : Lam_stats.t) (lam : Lam.t) : Lam.t =
3838
| x :: xs ->
3939
if x = len
4040
then
41-
Lam.apply (simpl fn) (Ext_list.map args simpl) loc App_ml_full
41+
Lam.apply (simpl fn) (Ext_list.map args simpl) loc App_infer_full
4242
else if x > len
4343
then
4444
let fn = simpl fn in
4545
let args = Ext_list.map args simpl in
46-
Lam_eta_conversion.transform_under_supply (x - len) loc App_ml_full
46+
Lam_eta_conversion.transform_under_supply (x - len) loc App_infer_full
4747
fn args
4848
else
4949
let first,rest = Ext_list.split_at args x in
5050
Lam.apply (
5151
Lam.apply (simpl fn)
5252
(Ext_list.map first simpl )
53-
loc App_ml_full
53+
loc App_infer_full
5454
)
5555
(Ext_list.map rest simpl ) loc status (* TODO refien *)
5656

lib/4.06.1/unstable/js_compiler.ml

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -92405,8 +92405,8 @@ type lambda_switch =
9240592405
sw_names: Lambda.switch_names option }
9240692406
and apply_status =
9240792407
| App_na
92408-
| App_ml_full
92409-
| App_js_full
92408+
| App_infer_full
92409+
| App_uncurry
9241092410
and apply_info = private
9241192411
{ ap_func : t ;
9241292412
ap_args : t list ;
@@ -92558,8 +92558,8 @@ type ident = Ident.t
9255892558

9255992559
type apply_status =
9256092560
| App_na
92561-
| App_ml_full
92562-
| App_js_full
92561+
| App_infer_full
92562+
| App_uncurry
9256392563

9256492564

9256592565
module Types = struct
@@ -121658,7 +121658,7 @@ let unsafe_adjust_to_arity loc ~(to_:int) ?(from : int option) (fn : Lam.t) : La
121658121658
~params:extra_args
121659121659
~body:(
121660121660
let first_args, rest_args = Ext_list.split_at extra_args from in
121661-
Lam.apply (Lam.apply new_fn (Ext_list.map first_args Lam.var) loc App_ml_full) (Ext_list.map rest_args Lam.var) loc App_na ) in
121661+
Lam.apply (Lam.apply new_fn (Ext_list.map first_args Lam.var) loc App_infer_full) (Ext_list.map rest_args Lam.var) loc App_na ) in
121662121662
begin match wrapper with
121663121663
| None -> cont
121664121664
| Some partial_arg ->
@@ -121712,7 +121712,7 @@ let unsafe_adjust_to_arity loc ~(to_:int) ?(from : int option) (fn : Lam.t) : La
121712121712
(Ext_list.map extra_inner_args Lam.var)
121713121713
Lam.var
121714121714
)
121715-
loc App_ml_full)
121715+
loc App_infer_full)
121716121716
) in
121717121717
begin match wrapper with
121718121718
| None -> cont
@@ -123985,9 +123985,9 @@ module S = Js_stmt_make
123985123985

123986123986
let call_info_of_ap_status (ap_status : Lam.apply_status) : Js_call_info.t =
123987123987
match ap_status with
123988-
| App_ml_full ->
123988+
| App_infer_full ->
123989123989
{arity = Full ; call_info = Call_ml}
123990-
| App_js_full ->
123990+
| App_uncurry ->
123991123991
{arity = Full ; call_info = Call_na}
123992123992
| App_na ->
123993123993
{arity = NA; call_info = Call_ml }
@@ -124207,7 +124207,7 @@ and compile_external_field_apply
124207124207
let fn = E.ml_var_dot module_id ident_info.name in
124208124208
let expression =
124209124209
match appinfo.ap_status with
124210-
| App_ml_full | App_js_full as ap_status ->
124210+
| App_infer_full | App_uncurry as ap_status ->
124211124211
E.call ~info:(call_info_of_ap_status ap_status) fn args
124212124212
| App_na ->
124213124213
match ident_info.arity with
@@ -125411,10 +125411,10 @@ and compile_prim (prim_info : Lam.prim_info) (lambda_cxt : Lam_compile_context.t
125411125411
Pjs_unsafe_downgrade {name = property; loc; setter = true};
125412125412
} :: _
125413125413
} -> assert false
125414-
| {primitive = Pjs_fn_run _ | Pmethod_run ; args}
125414+
| {primitive = Pjs_fn_run _ | Pmethod_run ; args; loc}
125415125415
->
125416-
(* 1. prevent eta-conversion
125417-
by using [App_js_full]
125416+
(* 1. uncurried call should not do eta-conversion
125417+
since `fn.length` will broken
125418125418
2. invariant: `external` declaration will guarantee
125419125419
the function application is saturated
125420125420
3. we need a location for Pccall in the call site
@@ -125423,9 +125423,7 @@ and compile_prim (prim_info : Lam.prim_info) (lambda_cxt : Lam_compile_context.t
125423125423
(match args with
125424125424
| fn :: rest ->
125425125425
compile_lambda lambda_cxt
125426-
(Lam.apply fn rest
125427-
Location.none (*TODO*)
125428-
App_js_full)
125426+
(Lam.apply fn rest loc App_uncurry)
125429125427
| [] -> assert false)
125430125428

125431125429
| {primitive = Pjs_fn_method arity; args = args_lambda} ->
@@ -126853,19 +126851,19 @@ let alpha_conversion (meta : Lam_stats.t) (lam : Lam.t) : Lam.t =
126853126851
| x :: xs ->
126854126852
if x = len
126855126853
then
126856-
Lam.apply (simpl fn) (Ext_list.map args simpl) loc App_ml_full
126854+
Lam.apply (simpl fn) (Ext_list.map args simpl) loc App_infer_full
126857126855
else if x > len
126858126856
then
126859126857
let fn = simpl fn in
126860126858
let args = Ext_list.map args simpl in
126861-
Lam_eta_conversion.transform_under_supply (x - len) loc App_ml_full
126859+
Lam_eta_conversion.transform_under_supply (x - len) loc App_infer_full
126862126860
fn args
126863126861
else
126864126862
let first,rest = Ext_list.split_at args x in
126865126863
Lam.apply (
126866126864
Lam.apply (simpl fn)
126867126865
(Ext_list.map first simpl )
126868-
loc App_ml_full
126866+
loc App_infer_full
126869126867
)
126870126868
(Ext_list.map rest simpl ) loc status (* TODO refien *)
126871126869

lib/4.06.1/unstable/js_refmt_compiler.ml

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -92405,8 +92405,8 @@ type lambda_switch =
9240592405
sw_names: Lambda.switch_names option }
9240692406
and apply_status =
9240792407
| App_na
92408-
| App_ml_full
92409-
| App_js_full
92408+
| App_infer_full
92409+
| App_uncurry
9241092410
and apply_info = private
9241192411
{ ap_func : t ;
9241292412
ap_args : t list ;
@@ -92558,8 +92558,8 @@ type ident = Ident.t
9255892558

9255992559
type apply_status =
9256092560
| App_na
92561-
| App_ml_full
92562-
| App_js_full
92561+
| App_infer_full
92562+
| App_uncurry
9256392563

9256492564

9256592565
module Types = struct
@@ -121658,7 +121658,7 @@ let unsafe_adjust_to_arity loc ~(to_:int) ?(from : int option) (fn : Lam.t) : La
121658121658
~params:extra_args
121659121659
~body:(
121660121660
let first_args, rest_args = Ext_list.split_at extra_args from in
121661-
Lam.apply (Lam.apply new_fn (Ext_list.map first_args Lam.var) loc App_ml_full) (Ext_list.map rest_args Lam.var) loc App_na ) in
121661+
Lam.apply (Lam.apply new_fn (Ext_list.map first_args Lam.var) loc App_infer_full) (Ext_list.map rest_args Lam.var) loc App_na ) in
121662121662
begin match wrapper with
121663121663
| None -> cont
121664121664
| Some partial_arg ->
@@ -121712,7 +121712,7 @@ let unsafe_adjust_to_arity loc ~(to_:int) ?(from : int option) (fn : Lam.t) : La
121712121712
(Ext_list.map extra_inner_args Lam.var)
121713121713
Lam.var
121714121714
)
121715-
loc App_ml_full)
121715+
loc App_infer_full)
121716121716
) in
121717121717
begin match wrapper with
121718121718
| None -> cont
@@ -123985,9 +123985,9 @@ module S = Js_stmt_make
123985123985

123986123986
let call_info_of_ap_status (ap_status : Lam.apply_status) : Js_call_info.t =
123987123987
match ap_status with
123988-
| App_ml_full ->
123988+
| App_infer_full ->
123989123989
{arity = Full ; call_info = Call_ml}
123990-
| App_js_full ->
123990+
| App_uncurry ->
123991123991
{arity = Full ; call_info = Call_na}
123992123992
| App_na ->
123993123993
{arity = NA; call_info = Call_ml }
@@ -124207,7 +124207,7 @@ and compile_external_field_apply
124207124207
let fn = E.ml_var_dot module_id ident_info.name in
124208124208
let expression =
124209124209
match appinfo.ap_status with
124210-
| App_ml_full | App_js_full as ap_status ->
124210+
| App_infer_full | App_uncurry as ap_status ->
124211124211
E.call ~info:(call_info_of_ap_status ap_status) fn args
124212124212
| App_na ->
124213124213
match ident_info.arity with
@@ -125411,10 +125411,10 @@ and compile_prim (prim_info : Lam.prim_info) (lambda_cxt : Lam_compile_context.t
125411125411
Pjs_unsafe_downgrade {name = property; loc; setter = true};
125412125412
} :: _
125413125413
} -> assert false
125414-
| {primitive = Pjs_fn_run _ | Pmethod_run ; args}
125414+
| {primitive = Pjs_fn_run _ | Pmethod_run ; args; loc}
125415125415
->
125416-
(* 1. prevent eta-conversion
125417-
by using [App_js_full]
125416+
(* 1. uncurried call should not do eta-conversion
125417+
since `fn.length` will broken
125418125418
2. invariant: `external` declaration will guarantee
125419125419
the function application is saturated
125420125420
3. we need a location for Pccall in the call site
@@ -125423,9 +125423,7 @@ and compile_prim (prim_info : Lam.prim_info) (lambda_cxt : Lam_compile_context.t
125423125423
(match args with
125424125424
| fn :: rest ->
125425125425
compile_lambda lambda_cxt
125426-
(Lam.apply fn rest
125427-
Location.none (*TODO*)
125428-
App_js_full)
125426+
(Lam.apply fn rest loc App_uncurry)
125429125427
| [] -> assert false)
125430125428

125431125429
| {primitive = Pjs_fn_method arity; args = args_lambda} ->
@@ -126853,19 +126851,19 @@ let alpha_conversion (meta : Lam_stats.t) (lam : Lam.t) : Lam.t =
126853126851
| x :: xs ->
126854126852
if x = len
126855126853
then
126856-
Lam.apply (simpl fn) (Ext_list.map args simpl) loc App_ml_full
126854+
Lam.apply (simpl fn) (Ext_list.map args simpl) loc App_infer_full
126857126855
else if x > len
126858126856
then
126859126857
let fn = simpl fn in
126860126858
let args = Ext_list.map args simpl in
126861-
Lam_eta_conversion.transform_under_supply (x - len) loc App_ml_full
126859+
Lam_eta_conversion.transform_under_supply (x - len) loc App_infer_full
126862126860
fn args
126863126861
else
126864126862
let first,rest = Ext_list.split_at args x in
126865126863
Lam.apply (
126866126864
Lam.apply (simpl fn)
126867126865
(Ext_list.map first simpl )
126868-
loc App_ml_full
126866+
loc App_infer_full
126869126867
)
126870126868
(Ext_list.map rest simpl ) loc status (* TODO refien *)
126871126869

0 commit comments

Comments
 (0)