Skip to content

Commit 9e7ea22

Browse files
committed
clean up arity, remove gen_tds which was never prod ready
1 parent baf25d6 commit 9e7ea22

15 files changed

+41
-131
lines changed

jscomp/all.depend

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -572,11 +572,10 @@ core/lam_stats_export.cmx : ext/string_map.cmx core/lam_stats_util.cmx \
572572
core/lam_stats.cmx core/lam_module_ident.cmx core/lam_inline_util.cmx \
573573
core/lam_id_kind.cmx core/lam_compile_env.cmx core/lam_closure.cmx \
574574
core/lam_arity.cmx core/lam_analysis.cmx core/lam.cmx \
575-
core/js_packages_state.cmx common/js_config.cmx core/js_cmj_format.cmx \
576-
ext/ident_set.cmx ext/ident_map.cmx ext/ident_hashtbl.cmx \
577-
ext/ext_string.cmx ext/ext_pervasives.cmx ext/ext_path.cmx \
578-
ext/ext_option.cmx common/ext_log.cmx ext/ext_list.cmx ext/ext_ident.cmx \
579-
ext/ext_array.cmx core/lam_stats_export.cmi
575+
core/js_packages_state.cmx core/js_cmj_format.cmx ext/ident_set.cmx \
576+
ext/ident_map.cmx ext/ident_hashtbl.cmx ext/ext_option.cmx \
577+
common/ext_log.cmx ext/ext_list.cmx ext/ext_array.cmx \
578+
core/lam_stats_export.cmi
580579
core/lam_pass_alpha_conversion.cmx : core/lam_stats_util.cmx \
581580
core/lam_stats.cmx core/lam_eta_conversion.cmx core/lam.cmx \
582581
ext/ext_list.cmx core/lam_pass_alpha_conversion.cmi

jscomp/common/js_config.ml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ let (//) = Filename.concat
6565

6666
(* let get_packages_info () = !packages_info *)
6767

68-
let default_gen_tds = ref false
6968
let no_builtin_ppx_ml = ref false
7069
let no_builtin_ppx_mli = ref false
7170

jscomp/common/js_config.mli

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,6 @@ val get_diagnose : unit -> bool
5757
val set_diagnose : bool -> unit
5858

5959

60-
(** generate tds option *)
61-
val default_gen_tds : bool ref
62-
6360
(** options for builtin ppx *)
6461
val no_builtin_ppx_ml : bool ref
6562
val no_builtin_ppx_mli : bool ref

jscomp/core/js_main.ml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,6 @@ let buckle_script_flags : (string * Arg.spec * string) list =
192192
Arg.Set Js_config.cross_module_inline,
193193
"enable cross module inlining(experimental), default(false)")
194194
::
195-
("-bs-gen-tds",
196-
Arg.Set Js_config.default_gen_tds,
197-
" set will generate `.d.ts` file for typescript (experimental)")
198-
::
199195
("-bs-diagnose",
200196
Arg.Set Js_config.diagnose,
201197
" More verbose output")

jscomp/core/lam_arity.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525

2626
type t =
27-
| Determin of bool * (int * Ident.t list option) list * bool
27+
| Determin of bool * int list * bool
2828
(**
2929
when the first argument is true, it is for sure
3030
the last one means it can take any params later,
@@ -47,7 +47,7 @@ let print (fmt : Format.formatter) (x : t) =
4747
pp fmt "~");
4848
pp fmt "[";
4949
Format.pp_print_list ~pp_sep:(fun fmt () -> pp fmt ",")
50-
(fun fmt (x,_) -> Format.pp_print_int fmt x)
50+
(fun fmt x -> Format.pp_print_int fmt x)
5151
fmt ls ;
5252
if tail
5353
then pp fmt "@ *";

jscomp/core/lam_arity.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525

2626
type t =
27-
| Determin of bool * (int * Ident.t list option) list * bool
27+
| Determin of bool * int list * bool
2828
(**
2929
when the first argument is true, it is for sure
3030
the last one means it can take any params later,

jscomp/core/lam_compile.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ and compile_external_field_apply
181181
match arity, len with
182182
| _, 0 ->
183183
acc (** All arguments consumed so far *)
184-
| Determin (a, (x,_) :: rest, b), len ->
184+
| Determin (a, x :: rest, b), len ->
185185
let x =
186186
if x = 0
187187
then 1

jscomp/core/lam_pass_alpha_conversion.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ let alpha_conversion (meta : Lam_stats.t) (lam : Lam.t) : Lam.t =
4444
let len = List.length ll in
4545
let rec take args =
4646
match args with
47-
| (x,_) :: xs ->
47+
| x :: xs ->
4848
if x = len
4949
then
5050
Lam.apply (simpl l1)
@@ -77,7 +77,7 @@ let alpha_conversion (meta : Lam_stats.t) (lam : Lam.t) : Lam.t =
7777
; loc } ->
7878

7979
begin match Lam_stats_util.get_arity meta arg with
80-
| Determin (b, (x,_)::_, tail)
80+
| Determin (b, x::_, tail)
8181
->
8282
let arg = simpl arg in
8383
Lam_eta_conversion.unsafe_adjust_to_arity loc

jscomp/core/lam_stats_export.ml

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -32,26 +32,7 @@ let pp = Format.fprintf
3232

3333
(* let meaningless_names = ["*opt*"; "param";] *)
3434

35-
let rec dump_ident fmt (id : Ident.t) (arity : Lam_arity.t) =
36-
pp fmt "@[<2>export var %s:@ %a@ ;@]" (Ext_ident.convert id.name ) dump_arity arity
37-
38-
and dump_arity fmt (arity : Lam_arity.t) =
39-
match arity with
40-
| NA -> pp fmt "any"
41-
| Determin (_, [], _) -> pp fmt "any"
42-
| Determin (_, (n,args)::xs, _) ->
43-
let args = match args with
44-
| Some args -> args
45-
| None -> Ext_list.init n (fun _ -> Ident.create "param") in
46-
pp fmt "@[(%a)@ =>@ any@]"
47-
(Format.pp_print_list
48-
~pp_sep:(fun fmt _ ->
49-
Format.pp_print_string fmt ",";
50-
Format.pp_print_space fmt ();
51-
)
52-
(fun fmt ident -> pp fmt "@[%s@ :@ any@]"
53-
(Ext_ident.convert @@ Ident.name ident))
54-
) args
35+
5536

5637
let single_na = Js_cmj_format.single_na
5738

@@ -134,14 +115,7 @@ let get_effect (meta : Lam_stats.t) maybe_pure external_ids =
134115
) external_ids) (fun x -> Lam_module_ident.name x)
135116
| Some _ -> maybe_pure
136117

137-
let rec dump meta fmt ids =
138-
(* TODO: also use {[Ext_pp]} module instead *)
139-
match ids with
140-
| [] -> ()
141-
| x::xs ->
142-
dump_ident fmt x (Lam_stats_util.get_arity meta (Lam.var x)) ;
143-
Format.pp_print_space fmt ();
144-
dump meta fmt xs
118+
145119

146120
(* Note that
147121
[lambda_exports] is
@@ -162,12 +136,6 @@ let export_to_cmj
162136
cmj_case
163137
: Js_cmj_format.t =
164138
let values = values_of_export meta export_map in
165-
let () =
166-
if !Js_config.default_gen_tds && not ( Ext_string.is_empty meta.filename) then
167-
Ext_pervasives.with_file_as_pp
168-
(Ext_path.chop_extension ~loc:__LOC__ meta.filename ^ ".d.ts")
169-
@@ fun fmt ->
170-
pp fmt "@[<v>%a@]@." (dump meta) meta.exports in
171139
let effect = get_effect meta maybe_pure external_ids in
172140
{values;
173141
effect ;

jscomp/core/lam_stats_util.ml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@
2424

2525

2626
let merge
27-
((n : int ), params as y)
27+
(n : int )
2828
(x : Lam_arity.t) : Lam_arity.t =
2929
match x with
30-
| NA -> Determin(false, [y], false)
31-
| Determin (b,xs,tail) -> Determin (b, y :: xs, tail)
30+
| NA -> Determin(false, [n], false)
31+
| Determin (b,xs,tail) -> Determin (b, n :: xs, tail)
3232

3333

3434
let arity_of_var (meta : Lam_stats.t) (v : Ident.t) =
@@ -110,15 +110,12 @@ let rec get_arity
110110
| Determin (b, xs, tail ) ->
111111
let rec take (xs : _ list) arg_length =
112112
match xs with
113-
| (x,y) :: xs ->
113+
| (x) :: xs ->
114114
if arg_length = x then Lam_arity.Determin (b, xs, tail)
115115
else if arg_length > x then
116116
take xs (arg_length - x)
117117
else Determin (b,
118-
((x - arg_length ),
119-
(match y with
120-
| Some y -> Some (Ext_list.drop arg_length y)
121-
| None -> None)) :: xs ,
118+
(x - arg_length ) :: xs ,
122119
tail)
123120
| [] ->
124121
if tail then Determin(b, [], tail)
@@ -135,7 +132,7 @@ let rec get_arity
135132
take xs (List.length args)
136133
end
137134
| Lfunction {arity; function_kind; params; body = l} ->
138-
merge (arity, Some params) (get_arity meta l)
135+
merge arity (get_arity meta l)
139136
| Lswitch(l, {sw_failaction;
140137
sw_consts;
141138
sw_blocks;

0 commit comments

Comments
 (0)