Skip to content

Commit 9896e7a

Browse files
committed
remove function kind which is never used
1 parent c0b3b53 commit 9896e7a

16 files changed

+94
-110
lines changed

Diff for: jscomp/core/lam.ml

+10-12
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ type mutable_flag = Asttypes.mutable_flag
2626

2727
type ident = Ident.t
2828

29-
type function_kind
30-
= Curried
29+
(* type function_kind
30+
= Curried *)
3131

3232

3333

@@ -222,7 +222,6 @@ module Types = struct
222222
}
223223
and function_info =
224224
{ arity : int ;
225-
function_kind : function_kind ;
226225
params : ident list ;
227226
body : t
228227
}
@@ -278,7 +277,6 @@ module X = struct
278277
= Types.function_info
279278
=
280279
{ arity : int ;
281-
function_kind : function_kind ;
282280
params : ident list ;
283281
body : t
284282
}
@@ -317,9 +315,9 @@ let inner_map (f : t -> X.t ) (l : t) : X.t =
317315
let fn = f fn in
318316
let args = Ext_list.map f args in
319317
Lapply { fn ; args; loc; status }
320-
| Lfunction({body; arity; function_kind; params } ) ->
318+
| Lfunction({body; arity; params } ) ->
321319
let body = f body in
322-
Lfunction {body; arity; function_kind ; params}
320+
Lfunction {body; arity; params}
323321
| Llet(str, id, arg, body) ->
324322
let arg = f arg in let body = f body in
325323
Llet(str,id,arg,body)
@@ -392,7 +390,7 @@ let inner_iter (f : t -> unit ) (l : t) : unit =
392390
| Lapply ({fn; args; loc; status} ) ->
393391
f fn;
394392
List.iter f args
395-
| Lfunction({body; arity; function_kind; params } ) ->
393+
| Lfunction({body; arity; params } ) ->
396394
f body
397395
| Llet(str, id, arg, body) ->
398396
f arg ;
@@ -1019,7 +1017,7 @@ let rec is_eta_conversion_exn
10191017
(** FIXME: more robust inlining check later, we should inline it before we add stub code*)
10201018
let apply fn args loc status : t =
10211019
match fn with
1022-
| Lfunction {function_kind;
1020+
| Lfunction {
10231021
params;
10241022
body = Lprim {primitive =
10251023
(Pundefined_to_opt |
@@ -1038,7 +1036,7 @@ let apply fn args loc status : t =
10381036
| exception Not_simple_form ->
10391037
Lapply { fn; args; loc; status }
10401038
end
1041-
| Lfunction {function_kind;
1039+
| Lfunction {
10421040
params;
10431041
body =Lprim ({primitive; args = inner_args}as primitive_call) }
10441042
->
@@ -1049,7 +1047,7 @@ let apply fn args loc status : t =
10491047
| exception _ ->
10501048
Lapply { fn; args; loc; status }
10511049
end
1052-
| Lfunction {function_kind ;
1050+
| Lfunction {
10531051
params;
10541052
body = Lsequence (Lprim ({primitive; args = inner_args}as primitive_call), (Lconst _ as const )) }
10551053
->
@@ -1114,8 +1112,8 @@ let rec seq (a : t) b : t =
11141112
let var id : t = Lvar id
11151113
let global_module id = Lglobal_module id
11161114
let const ct : t = Lconst ct
1117-
let function_ ~arity ~function_kind ~params ~body : t =
1118-
Lfunction { arity; function_kind; params ; body}
1115+
let function_ ~arity ~params ~body : t =
1116+
Lfunction { arity; params ; body}
11191117

11201118
let let_ kind id e body : t
11211119
= Llet (kind,id,e,body)

Diff for: jscomp/core/lam.mli

+2-5
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@ type mutable_flag = Asttypes.mutable_flag
2828

2929
type ident = Ident.t
3030

31-
type function_kind
32-
= Curried
33-
(* | Tupled *)
3431

3532

3633
type primitive =
@@ -191,7 +188,6 @@ and prim_info = private
191188
}
192189
and function_info = private
193190
{ arity : int ;
194-
function_kind : function_kind ;
195191
params : ident list ;
196192
body : t
197193
}
@@ -258,7 +254,8 @@ val const : Lam_constant.t -> t
258254
val apply : t -> t list -> Location.t -> apply_status -> t
259255
val function_ :
260256
arity:int ->
261-
function_kind:function_kind -> params:ident list -> body:t -> t
257+
params:ident list ->
258+
body:t -> t
262259

263260
val let_ : Lam_compat.let_kind -> ident -> t -> t -> t
264261
val letrec : (ident * t) list -> t -> t

Diff for: jscomp/core/lam_bounded_vars.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,10 @@ let rewrite (map : _ Ident_hashtbl.t)
9191
let bindings = Ext_list.map2 (fun var (_,l) -> var, aux l) vars bindings in
9292
let body = aux body in
9393
Lam.letrec bindings body
94-
| Lfunction{arity; function_kind; params; body} ->
94+
| Lfunction{arity; params; body} ->
9595
let params = Ext_list.map rebind params in
9696
let body = aux body in
97-
Lam.function_ ~arity ~function_kind ~params ~body
97+
Lam.function_ ~arity ~params ~body
9898
| Lstaticcatch(l1, (i,xs), l2) ->
9999
let l1 = aux l1 in
100100
let xs = Ext_list.map rebind xs in

Diff for: jscomp/core/lam_compile.ml

+3-3
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ and compile_recursive_let ~all_bindings
243243
(id : Ident.t)
244244
(arg : Lam.t) : Js_output.t * Ident.t list =
245245
match arg with
246-
| Lfunction { function_kind; params; body; _} ->
246+
| Lfunction { params; body; _} ->
247247

248248
let continue_label = Lam_util.generate_label ~name:id.name () in
249249
(* TODO: Think about recursive value
@@ -561,7 +561,7 @@ and
561561
(lam : Lam.t) : Js_output.t =
562562
begin
563563
match lam with
564-
| Lfunction{ function_kind; params; body} ->
564+
| Lfunction{ params; body} ->
565565
Js_output.output_of_expression st should_return lam
566566
(E.ocaml_fun
567567
params
@@ -949,7 +949,7 @@ and
949949
end
950950
| Lprim {primitive = Pjs_fn_method arity; args = args_lambda} ->
951951
begin match args_lambda with
952-
| [Lfunction{arity = len; function_kind; params; body} ]
952+
| [Lfunction{arity = len; params; body} ]
953953
when len = arity ->
954954
Js_output.output_of_block_and_expression
955955
st

Diff for: jscomp/core/lam_convert.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ let convert (exports : Ident_set.t) (lam : Lambda.lambda) : t * Lam_module_ident
474474
| Lfunction (Tupled,_,_) -> assert false
475475
| Lfunction (Curried, params,body)
476476
-> Lam.function_
477-
~arity:(List.length params) ~function_kind:Curried ~params
477+
~arity:(List.length params) ~params
478478
~body:(convert_aux body)
479479
| Llet (kind,id,e,body)
480480
->

Diff for: jscomp/core/lam_eta_conversion.ml

+12-13
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,15 @@ let transform_under_supply n loc status fn args =
6565
But it is dangerous to change the arity
6666
of an existing function which may cause inconsistency
6767
*)
68-
Lam.function_ ~arity:n ~function_kind:Curried ~params:extra_args
68+
Lam.function_ ~arity:n ~params:extra_args
6969
~body:(Lam.apply fn (Ext_list.append args extra_lambdas)
7070
loc
7171
status
7272
)
7373
| fn::args , bindings ->
7474

7575
let rest : Lam.t =
76-
Lam.function_ ~arity:n ~function_kind:Curried ~params:extra_args
76+
Lam.function_ ~arity:n ~params:extra_args
7777
~body:(Lam.apply fn (Ext_list.append args extra_lambdas)
7878
loc
7979
status
@@ -195,7 +195,7 @@ let unsafe_adjust_to_arity loc ~to_:(to_:int) ?from
195195
else if to_ = 0 then
196196
match fn with
197197
| Lfunction{params = [param]; body} ->
198-
Lam.function_ ~arity:0 ~function_kind:Curried
198+
Lam.function_ ~arity:0
199199
~params:[]
200200
~body:(
201201
Lam.let_ Alias param Lam.unit body
@@ -216,7 +216,7 @@ let unsafe_adjust_to_arity loc ~to_:(to_:int) ?from
216216

217217
let cont = Lam.function_
218218
~arity:0
219-
~function_kind:Curried
219+
220220
~params:[]
221221
~body:(
222222
Lam.apply new_fn [Lam.unit ; Lam.unit ] loc App_na
@@ -229,14 +229,13 @@ let unsafe_adjust_to_arity loc ~to_:(to_:int) ?from
229229

230230
else if to_ > from then
231231
match fn with
232-
| Lfunction{params;body; function_kind} ->
232+
| Lfunction{params;body} ->
233233
(* {[fun x -> f]} ->
234234
{[ fun x y -> f y ]}
235235
*)
236236
let extra_args = Ext_list.init (to_ - from) (fun _ -> Ident.create Literals.param) in
237237
Lam.function_
238238
~arity:to_
239-
~function_kind:Curried
240239
~params:(Ext_list.append params extra_args )
241240
~body:(Lam.apply body (Ext_list.map Lam.var extra_args) loc App_na)
242241
| _ ->
@@ -254,7 +253,7 @@ let unsafe_adjust_to_arity loc ~to_:(to_:int) ?from
254253
let cont =
255254
Lam.function_
256255
~arity
257-
~function_kind:Curried
256+
258257
~params:extra_args
259258
~body:(
260259
let first_args, rest_args = Ext_list.split_at from extra_args in
@@ -275,17 +274,17 @@ let unsafe_adjust_to_arity loc ~to_:(to_:int) ?from
275274
begin match fn with
276275

277276
| Lfunction
278-
{params; body; function_kind } (* TODO check arity = List.length params in debug mode *)
277+
{params; body; } (* TODO check arity = List.length params in debug mode *)
279278
->
280279
let arity = to_ in
281280
let extra_outer_args, extra_inner_args = Ext_list.split_at arity params in
282281
Lam.function_
283282
~arity
284-
~function_kind:Curried
283+
285284
~params:extra_outer_args
286285
~body:(
287286
Lam.function_ ~arity:(from - to_)
288-
~function_kind:Curried ~params:extra_inner_args ~body:body)
287+
~params:extra_inner_args ~body:body)
289288
| _
290289
->
291290
let extra_outer_args =
@@ -301,12 +300,12 @@ let unsafe_adjust_to_arity loc ~to_:(to_:int) ?from
301300
Some partial_arg, Lam.var partial_arg
302301
in
303302
let cont =
304-
Lam.function_ ~arity:to_ ~function_kind:Curried ~params:extra_outer_args
303+
Lam.function_ ~arity:to_ ~params:extra_outer_args
305304
~body:(
306305
let arity = from - to_ in
307306
let extra_inner_args =
308307
Ext_list.init arity (fun _ -> Ident.create Literals.param ) in
309-
Lam.function_ ~arity ~function_kind:Curried ~params:extra_inner_args
308+
Lam.function_ ~arity ~params:extra_inner_args
310309
~body:(Lam.apply new_fn
311310
(Ext_list.map_append
312311
Lam.var extra_outer_args
@@ -334,7 +333,7 @@ let unsafe_adjust_to_arity loc ~to_:(to_:int) ?from
334333

335334
let cont = Lam.function_
336335
~arity:0
337-
~function_kind:Curried
336+
338337
~params:[]
339338
~body:(
340339
Lam.apply new_fn [Lam.unit] loc App_na

Diff for: jscomp/core/lam_pass_alpha_conversion.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ let alpha_conversion (meta : Lam_stats.t) (lam : Lam.t) : Lam.t =
8787
end
8888
| Lprim {primitive; args ; loc} ->
8989
Lam.prim ~primitive ~args:(Ext_list.map simpl args) loc
90-
| Lfunction {arity; function_kind; params; body = l} ->
90+
| Lfunction {arity; params; body = l} ->
9191
(* Lam_mk.lfunction kind params (simpl l) *)
92-
Lam.function_ ~arity ~function_kind ~params ~body:(simpl l)
92+
Lam.function_ ~arity ~params ~body:(simpl l)
9393
| Lswitch (l, {sw_failaction;
9494
sw_consts;
9595
sw_blocks;

Diff for: jscomp/core/lam_pass_count.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ let collect_occurs lam : occ_tbl =
138138
List.iter (fun (v, l) -> count bv l) bindings;
139139
count bv body
140140
(** Note there is a difference here when do beta reduction for *)
141-
| Lapply{fn = Lfunction{function_kind= Curried; params; body}; args; _}
141+
| Lapply{fn = Lfunction{params; body}; args; _}
142142
when Ext_list.same_length params args ->
143143
count bv (Lam_beta_reduce.beta_reduce params body args)
144144
(* | Lapply{fn = Lfunction{function_kind = Tupled; params; body}; *)

Diff for: jscomp/core/lam_pass_deep_flatten.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,8 @@ let deep_flatten
262262
let args = Ext_list.map aux args in
263263
Lam.prim ~primitive ~args loc
264264

265-
| Lfunction{arity; function_kind; params; body = l} ->
266-
Lam.function_ ~arity ~function_kind ~params ~body:(aux l)
265+
| Lfunction{arity; params; body = l} ->
266+
Lam.function_ ~arity ~params ~body:(aux l)
267267
| Lswitch(l, {sw_failaction;
268268
sw_consts;
269269
sw_blocks;

Diff for: jscomp/core/lam_pass_eliminate_ref.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ let rec eliminate_ref id (lam : Lam.t) =
2222
if Ident.same v id then raise_notrace Real_reference else lam
2323
| Lprim {primitive = Pfield (0,_); args = [Lvar v]} when Ident.same v id ->
2424
Lam.var id
25-
| Lfunction{ function_kind; params; body} as lam ->
25+
| Lfunction{params; body} as lam ->
2626
if Ident_set.mem id (Lam.free_variables lam) (*TODO: optmization: no need construct*)
2727
then raise_notrace Real_reference
2828
else lam

Diff for: jscomp/core/lam_pass_exits.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,8 @@ let subst_helper (subst : subst_tbl) (query : int -> int) lam =
260260
| Lvar _|Lconst _ -> lam
261261
| Lapply {fn = l1; args = ll; loc; status } ->
262262
Lam.apply (simplif l1) (Ext_list.map simplif ll) loc status
263-
| Lfunction {arity; function_kind; params; body = l} ->
264-
Lam.function_ ~arity ~function_kind ~params ~body:(simplif l)
263+
| Lfunction {arity; params; body = l} ->
264+
Lam.function_ ~arity ~params ~body:(simplif l)
265265
| Llet (kind, v, l1, l2) ->
266266
Lam.let_ kind v (simplif l1) (simplif l2)
267267
| Lletrec (bindings, body) ->

Diff for: jscomp/core/lam_pass_lets_dce.ml

+3-3
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ let lets_helper (count_var : Ident.t -> Lam_pass_count.used_info) lam =
154154
else simplif l2
155155
| Lsequence(l1, l2) -> Lam.seq (simplif l1) (simplif l2)
156156

157-
| Lapply{fn = Lfunction{function_kind = Curried; params; body}; args; _}
157+
| Lapply{fn = Lfunction{params; body}; args; _}
158158
when Ext_list.same_length params args ->
159159
simplif (Lam_beta_reduce.beta_reduce params body args)
160160
(* | Lapply{ fn = Lfunction{function_kind = Tupled; params; body}; *)
@@ -167,8 +167,8 @@ let lets_helper (count_var : Ident.t -> Lam_pass_count.used_info) lam =
167167

168168
| Lapply{fn = l1;args = ll; loc; status} ->
169169
Lam.apply (simplif l1) (Ext_list.map simplif ll) loc status
170-
| Lfunction{arity; function_kind; params; body = l} ->
171-
Lam.function_ ~arity ~function_kind ~params ~body:(simplif l)
170+
| Lfunction{arity; params; body = l} ->
171+
Lam.function_ ~arity ~params ~body:(simplif l)
172172
| Lconst _ -> lam
173173
| Lletrec(bindings, body) ->
174174
Lam.letrec

Diff for: jscomp/core/lam_pass_remove_alias.ml

+3-3
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ let simplify_alias
259259

260260
end
261261

262-
| Lapply{ fn = Lfunction{ function_kind = Curried ; params; body}; args; _}
262+
| Lapply{ fn = Lfunction{ params; body}; args; _}
263263
when Ext_list.same_length params args ->
264264
simpl (Lam_beta_reduce.propogate_beta_reduce meta params body args)
265265
(* | Lapply{ fn = Lfunction{function_kind = Tupled; params; body}; *)
@@ -272,8 +272,8 @@ let simplify_alias
272272

273273
| Lapply {fn = l1; args = ll; loc ; status} ->
274274
Lam.apply (simpl l1) (Ext_list.map simpl ll) loc status
275-
| Lfunction {arity; function_kind; params; body = l}
276-
-> Lam.function_ ~arity ~function_kind ~params ~body:(simpl l)
275+
| Lfunction {arity; params; body = l}
276+
-> Lam.function_ ~arity ~params ~body:(simpl l)
277277
| Lswitch (l, {sw_failaction;
278278
sw_consts;
279279
sw_blocks;

Diff for: jscomp/core/lam_print.ml

+1-3
Original file line numberDiff line numberDiff line change
@@ -390,10 +390,8 @@ let lambda use_env env ppf v =
390390
let lams ppf args =
391391
List.iter (fun l -> fprintf ppf "@ %a" lam l) args in
392392
fprintf ppf "@[<2>(apply@ %a%a)@]" lam fn lams args
393-
| Lfunction{ function_kind; params; body; _} ->
393+
| Lfunction{params; body; _} ->
394394
let pr_params ppf params =
395-
match function_kind with
396-
| Curried ->
397395
List.iter (fun param -> fprintf ppf "@ %a" Ident.print param) params
398396
(* | Tupled -> *)
399397
(* fprintf ppf " ("; *)

Diff for: jscomp/core/lam_subst.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939
| Lconst sc as l -> l
4040
| Lapply{fn; args; loc; status} ->
4141
Lam.apply (subst_aux fn) (Ext_list.map subst_aux args) loc status
42-
| Lfunction {arity; function_kind; params; body} ->
43-
Lam.function_ ~arity ~function_kind ~params ~body:(subst_aux body)
42+
| Lfunction {arity; params; body} ->
43+
Lam.function_ ~arity ~params ~body:(subst_aux body)
4444
| Llet(str, id, arg, body) ->
4545
Lam.let_ str id (subst_aux arg) (subst_aux body)
4646
| Lletrec(decl, body) ->

0 commit comments

Comments
 (0)