Skip to content

Commit a838df8

Browse files
committed
tweak
1 parent 5543e4f commit a838df8

File tree

4 files changed

+50
-26
lines changed

4 files changed

+50
-26
lines changed

jscomp/core/lam_arity.ml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,11 @@ let first_arity_na ( x : t ) =
8888
match x with
8989
| Arity_na
9090
| Arity_info (_, [], _) -> true
91-
| _ -> false
91+
| _ -> false
92+
93+
let extract_arity ( x : t) =
94+
match x with
95+
| Arity_na -> None
96+
| Arity_info(_,xs,_) -> Some xs
97+
98+
(* let update_arity (x : t) xs = *)

jscomp/core/lam_arity.mli

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,6 @@ val raise_arity_info : t
5050
val na : t
5151
val info : bool -> int list -> bool -> t
5252

53-
val first_arity_na : t -> bool
53+
val first_arity_na : t -> bool
54+
55+
val extract_arity : t -> int list option

jscomp/core/lam_compile.ml

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -177,11 +177,11 @@ and compile_external_field_apply
177177
params body args_lambda)
178178
| _ ->
179179
let rec aux (acc : J.expression)
180-
(arity : Lam_arity.t) args (len : int) =
181-
match arity, len with
182-
| _, 0 ->
180+
(arity : Lam_arity.t) args (len : int) : E.t =
181+
if len = 0 then
183182
acc (** All arguments consumed so far *)
184-
| Arity_info (aaaaa, x :: rest, bbbbb), len ->
183+
else match arity with
184+
| Arity_info (aaaaa, x :: rest, bbbbb) ->
185185
let x =
186186
if x = 0
187187
then 1
@@ -204,22 +204,25 @@ and compile_external_field_apply
204204
(* alpha conversion now? --
205205
Since we did an alpha conversion before so it is not here
206206
*)
207-
| Arity_info (a, [], b ), _ ->
207+
| Arity_info (_, [], _ ) ->
208208
(* can not happen, unless it's an exception ? *)
209209
E.call ~info:Js_call_info.dummy acc args
210-
| Arity_na, _ ->
210+
| Arity_na ->
211211
E.call ~info:Js_call_info.dummy acc args
212212
in
213+
let fn = E.ml_var_dot id name in
214+
let initial_args_len = List.length args in
215+
let expression =
216+
match arity with
217+
| Submodule _ -> E.call ~info:Js_call_info.dummy fn args
218+
| Single x ->
219+
aux fn x args initial_args_len
220+
in
213221
Js_output.output_of_block_and_expression
214222
cxt.st
215223
cxt.should_return
216224
lam
217-
args_code
218-
(
219-
aux
220-
(E.ml_var_dot id name)
221-
(match arity with Single x -> x | Submodule _ -> Lam_arity.na)
222-
args (List.length args ))
225+
args_code expression
223226

224227

225228
and compile_let

lib/whole_compiler.ml

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69079,6 +69079,8 @@ val na : t
6907969079
val info : bool -> int list -> bool -> t
6908069080

6908169081
val first_arity_na : t -> bool
69082+
69083+
val extract_arity : t -> int list option
6908269084
end = struct
6908369085
#1 "lam_arity.ml"
6908469086
(* Copyright (C) Authors of BuckleScript
@@ -69172,6 +69174,13 @@ let first_arity_na ( x : t ) =
6917269174
| Arity_na
6917369175
| Arity_info (_, [], _) -> true
6917469176
| _ -> false
69177+
69178+
let extract_arity ( x : t) =
69179+
match x with
69180+
| Arity_na -> None
69181+
| Arity_info(_,xs,_) -> Some xs
69182+
69183+
(* let update_arity (x : t) xs = *)
6917569184
end
6917669185
module Js_cmj_format : sig
6917769186
#1 "js_cmj_format.mli"
@@ -97282,11 +97291,11 @@ and compile_external_field_apply
9728297291
params body args_lambda)
9728397292
| _ ->
9728497293
let rec aux (acc : J.expression)
97285-
(arity : Lam_arity.t) args (len : int) =
97286-
match arity, len with
97287-
| _, 0 ->
97294+
(arity : Lam_arity.t) args (len : int) : E.t =
97295+
if len = 0 then
9728897296
acc (** All arguments consumed so far *)
97289-
| Arity_info (aaaaa, x :: rest, bbbbb), len ->
97297+
else match arity with
97298+
| Arity_info (aaaaa, x :: rest, bbbbb) ->
9729097299
let x =
9729197300
if x = 0
9729297301
then 1
@@ -97309,22 +97318,25 @@ and compile_external_field_apply
9730997318
(* alpha conversion now? --
9731097319
Since we did an alpha conversion before so it is not here
9731197320
*)
97312-
| Arity_info (a, [], b ), _ ->
97321+
| Arity_info (_, [], _ ) ->
9731397322
(* can not happen, unless it's an exception ? *)
9731497323
E.call ~info:Js_call_info.dummy acc args
97315-
| Arity_na, _ ->
97324+
| Arity_na ->
9731697325
E.call ~info:Js_call_info.dummy acc args
9731797326
in
97327+
let fn = E.ml_var_dot id name in
97328+
let initial_args_len = List.length args in
97329+
let expression =
97330+
match arity with
97331+
| Submodule _ -> E.call ~info:Js_call_info.dummy fn args
97332+
| Single x ->
97333+
aux fn x args initial_args_len
97334+
in
9731897335
Js_output.output_of_block_and_expression
9731997336
cxt.st
9732097337
cxt.should_return
9732197338
lam
97322-
args_code
97323-
(
97324-
aux
97325-
(E.ml_var_dot id name)
97326-
(match arity with Single x -> x | Submodule _ -> Lam_arity.na)
97327-
args (List.length args ))
97339+
args_code expression
9732897340

9732997341

9733097342
and compile_let

0 commit comments

Comments
 (0)