@@ -44790,31 +44790,35 @@ let generic_apply kind loc
44790
44790
-> []
44791
44791
| _ -> args in
44792
44792
let arity = List.length args in
44793
- if arity < 10 then
44794
- let txt =
44795
- match kind with
44796
- | `Fn | `PropertyFn ->
44797
- Longident.Ldot (Ast_literal.Lid.js_internal,
44798
- Literals.fn_run ^ string_of_int arity)
44799
- | `Method ->
44800
- Longident.Ldot(Lident "Js_internalOO",
44801
- Literals.method_run ^ string_of_int arity
44802
- ) in
44803
- Parsetree.Pexp_apply (Exp.ident {txt ; loc}, (Nolabel,fn) :: Ext_list.map args (fun x -> Asttypes.Nolabel,x))
44804
- else
44805
- let fn_type, args_type, result_type = Ast_comb.tuple_type_pair ~loc `Run arity in
44806
- let string_arity = string_of_int arity in
44807
- let pval_prim, pval_type =
44808
- match kind with
44809
- | `Fn | `PropertyFn ->
44793
+ match kind with
44794
+ | `Fn | `PropertyFn ->
44795
+ if arity < 10 then
44796
+ let txt : Longident.t =
44797
+ Ldot (Ast_literal.Lid.js_internal, Literals.fn_run ^ string_of_int arity) in
44798
+ Parsetree.Pexp_apply (Exp.ident {txt ; loc}, (Nolabel,fn) :: Ext_list.map args (fun x -> Asttypes.Nolabel,x))
44799
+ else
44800
+ let fn_type, args_type, result_type = Ast_comb.tuple_type_pair ~loc `Run arity in
44801
+ let string_arity = string_of_int arity in
44802
+ let pval_prim, pval_type =
44810
44803
["#fn_run"; string_arity],
44811
44804
arrow ~loc (Ast_typ_uncurry.lift_curry_type loc args_type result_type ) fn_type
44812
- | `Method ->
44805
+ in
44806
+ Ast_external_mk.local_external_apply loc ~pval_prim ~pval_type
44807
+ ( fn :: args )
44808
+ | `Method ->
44809
+ if arity < 10 then
44810
+ let txt : Longident.t =
44811
+ Ldot(Lident "Js_internalOO", Literals.method_run ^ string_of_int arity) in
44812
+ Parsetree.Pexp_apply (Exp.ident {txt ; loc}, (Nolabel,fn) :: Ext_list.map args (fun x -> Asttypes.Nolabel,x))
44813
+ else
44814
+ let fn_type, args_type, result_type = Ast_comb.tuple_type_pair ~loc `Run arity in
44815
+ let string_arity = string_of_int arity in
44816
+ let pval_prim, pval_type =
44813
44817
["#method_run" ; string_arity],
44814
44818
arrow ~loc (Ast_typ_uncurry.lift_method_type loc args_type result_type) fn_type
44815
- in
44816
- Ast_external_mk.local_external_apply loc ~pval_prim ~pval_type
44817
- ( fn :: args )
44819
+ in
44820
+ Ast_external_mk.local_external_apply loc ~pval_prim ~pval_type
44821
+ ( fn :: args )
44818
44822
44819
44823
44820
44824
let uncurry_fn_apply loc self fn args =
@@ -44853,48 +44857,44 @@ let generic_to_uncurry_exp kind loc (self : Bs_ast_mapper.mapper) pat body
44853
44857
Bs_syntaxerr.err first_arg.ppat_loc Bs_this_simple_pattern
44854
44858
| _ -> ()
44855
44859
in
44856
-
44857
44860
let result, rev_extra_args = aux [first_arg] body in
44858
44861
let body =
44859
44862
Ext_list.fold_left rev_extra_args result (fun e p -> Ast_compatible.fun_ ~loc p e )
44860
- in
44861
- let len = List.length rev_extra_args in
44862
- let arity =
44863
- match kind with
44864
- | `Fn ->
44865
- begin match rev_extra_args with
44866
- | [ p]
44867
- ->
44868
- Ast_pat.is_unit_cont ~yes:0 ~no:len p
44869
-
44870
- | _ -> len
44871
- end
44872
- | `Method_callback -> len in
44873
- if arity < 10 then
44874
- let txt =
44875
- match kind with
44876
- | `Fn ->
44877
- Longident.Ldot ( Ast_literal.Lid.js_internal, Literals.fn_mk ^ string_of_int arity)
44878
- | `Method_callback ->
44879
- Longident.Ldot (Lident "Js_internalOO", Literals.fn_method ^ string_of_int arity) in
44880
- Parsetree.Pexp_apply (Exp.ident {txt;loc} , [ Nolabel, body])
44881
-
44882
- else
44883
- let pval_prim =
44884
- [ (match kind with
44885
- | `Fn -> "#fn_mk"
44886
- | `Method_callback -> "#fn_method");
44887
- string_of_int arity] in
44888
- let fn_type , args_type, result_type = Ast_comb.tuple_type_pair ~loc `Make arity in
44889
- let pval_type = arrow ~loc fn_type (
44890
- match kind with
44891
- | `Fn ->
44892
- Ast_typ_uncurry.lift_curry_type loc args_type result_type
44893
- | `Method_callback ->
44894
- Ast_typ_uncurry.lift_js_method_callback loc args_type result_type
44895
- ) in
44896
- Ast_external_mk.local_extern_cont loc ~pval_prim ~pval_type
44897
- (fun prim -> Ast_compatible.app1 ~loc prim body)
44863
+ in
44864
+ let len = List.length rev_extra_args in
44865
+ match kind with
44866
+ | `Fn ->
44867
+ let arity =
44868
+ match rev_extra_args with
44869
+ | [ p]
44870
+ ->
44871
+ Ast_pat.is_unit_cont ~yes:0 ~no:len p
44872
+ | _ -> len
44873
+ in
44874
+ if arity < 10 then
44875
+ let txt =
44876
+ Longident.Ldot ( Ast_literal.Lid.js_internal, Literals.fn_mk ^ string_of_int arity) in
44877
+ Parsetree.Pexp_apply (Exp.ident {txt;loc} , [ Nolabel, body])
44878
+ else
44879
+ let pval_prim =
44880
+ [ "#fn_mk"; string_of_int arity] in
44881
+ let fn_type , args_type, result_type = Ast_comb.tuple_type_pair ~loc `Make arity in
44882
+ let pval_type = arrow ~loc fn_type (Ast_typ_uncurry.lift_curry_type loc args_type result_type) in
44883
+ Ast_external_mk.local_extern_cont loc ~pval_prim ~pval_type
44884
+ (fun prim -> Ast_compatible.app1 ~loc prim body)
44885
+ | `Method_callback ->
44886
+ let arity = len in
44887
+ if arity < 10 then
44888
+ let txt = Longident.Ldot (Lident "Js_internalOO", Literals.fn_method ^ string_of_int arity) in
44889
+ Parsetree.Pexp_apply (Exp.ident {txt;loc} , [ Nolabel, body])
44890
+ else
44891
+ let pval_prim =
44892
+ [ "#fn_method"; string_of_int arity] in
44893
+ let fn_type , args_type, result_type = Ast_comb.tuple_type_pair ~loc `Make arity in
44894
+ let pval_type = arrow ~loc fn_type
44895
+ (Ast_typ_uncurry.lift_js_method_callback loc args_type result_type) in
44896
+ Ast_external_mk.local_extern_cont loc ~pval_prim ~pval_type
44897
+ (fun prim -> Ast_compatible.app1 ~loc prim body)
44898
44898
44899
44899
let to_uncurry_fn =
44900
44900
generic_to_uncurry_exp `Fn
0 commit comments