Skip to content

Commit 133141b

Browse files
committed
remove unused code
1 parent 602ed5d commit 133141b

14 files changed

+38
-141
lines changed

jscomp/core/bs_conditional_initial.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
let setup_env () =
2727
#if BS_DEBUG then
28-
Js_config.set_debug_file "pipe_syntax.ml";
28+
Js_config.set_debug_file "gpr_2700_test.ml";
2929
#end
3030
Lexer.replace_directive_bool "BS" true;
3131
Lexer.replace_directive_string "BS_VERSION" Bs_version.version

jscomp/core/j.ml

-8
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,7 @@ and expression_desc =
111111
*)
112112
| Array_copy of expression (* shallow copy, like [x.slice] *)
113113
| Array_append of expression * expression (* For [caml_array_append]*)
114-
(* | Tag_ml_obj of expression *)
115114
| String_append of expression * expression
116-
117-
| Anything_to_number of expression
118115
| Bool of bool (* js true/false*)
119116
(* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence
120117
[typeof] is an operator
@@ -178,11 +175,6 @@ and expression_desc =
178175
if it's know at compile time, we can turn it into
179176
f(args[0], args[1], ... )
180177
*)
181-
| Bind of expression * expression
182-
(* {[ Bind (a,b) ]}
183-
is literally
184-
{[ a.bind(b) ]}
185-
*)
186178
| Call of expression * expression list * Js_call_info.t
187179
(* Analysze over J expression is hard since,
188180
some primitive call is translated

jscomp/core/js_analyzer.ml

-6
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ let rec no_side_effect_expression_desc (x : J.expression_desc) =
100100
the block is mutable does not mean this operation is non-pure
101101
*)
102102
List.for_all no_side_effect xs
103-
| Bind(fn, obj) -> no_side_effect fn && no_side_effect obj
104103
| Object kvs ->
105104
List.for_all (fun (_property_name, y) -> no_side_effect y ) kvs
106105
| Array_append (a,b)
@@ -117,8 +116,6 @@ let rec no_side_effect_expression_desc (x : J.expression_desc) =
117116
| Math _
118117
| Array_of_size _
119118
| Array_copy _
120-
(* | Tag_ml_obj _ *)
121-
| J.Anything_to_number _
122119
| Js_not _
123120
| String_of_small_int_array _
124121
| Json_stringify _
@@ -269,8 +266,6 @@ let rec eq_expression
269266
| Array_copy _
270267
| Array_append _
271268
| String_append _
272-
| Anything_to_number _
273-
274269
| Typeof _
275270
| Js_not _
276271
| String_of_small_int_array _
@@ -280,7 +275,6 @@ let rec eq_expression
280275

281276
| Cond _
282277
| FlatCall _
283-
| Bind _
284278
| String_access _
285279

286280
| New _

jscomp/core/js_dump.ml

+1-25
Original file line numberDiff line numberDiff line change
@@ -476,16 +476,7 @@ and
476476
in
477477
if l > 15 then P.paren_group f 1 action
478478
else action ()
479-
| Bind (a,b) ->
480-
(* a.bind(b)
481-
{[ fun b -> a.bind(b) ==? a.bind ]}
482-
*)
483-
begin
484-
expression_desc cxt l f
485-
(Call ({expression_desc = Dot(a,L.bind, true); comment = None }, [b],
486-
{arity = Full; call_info = Call_na}))
487-
end
488-
479+
489480
| FlatCall(e,el) ->
490481
P.group f 1 (fun _ ->
491482
let cxt = expression 15 cxt f e in
@@ -640,19 +631,6 @@ and
640631
else action ()
641632
);
642633
cxt
643-
| J.Anything_to_number e
644-
->
645-
let action () =
646-
P.group f 0 @@ fun _ ->
647-
P.string f "+" ;
648-
expression 13 cxt f e
649-
in
650-
(* need to tweak precedence carefully
651-
here [++x --> +(+x)]
652-
*)
653-
if l > 12
654-
then P.paren_group f 1 action
655-
else action ()
656634
| Is_null_undefined_to_boolean e ->
657635
let action = (fun _ ->
658636
let cxt = expression 1 cxt f e in
@@ -1146,12 +1124,10 @@ and statement_desc top cxt f (s : J.statement_desc) : Ext_pp_scope.t =
11461124
| Caml_block _
11471125
| FlatCall _
11481126
| Typeof _
1149-
| Bind _
11501127
| Number _
11511128
| Js_not _
11521129
| Bool _
11531130
| New _
1154-
| J.Anything_to_number _
11551131
-> false
11561132
(* e = function(x){...}(x); is good
11571133
*)

jscomp/core/js_fold.ml

+1-9
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,7 @@ class virtual fold =
130130
since GC does not rely on it
131131
*)
132132
(* shallow copy, like [x.slice] *)
133-
(* For [caml_array_append]*)
134-
(* | Tag_ml_obj of expression *) (* js true/false*)
133+
(* For [caml_array_append]*) (* js true/false*)
135134
(* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence
136135
[typeof] is an operator
137136
*)
@@ -182,10 +181,6 @@ class virtual fold =
182181
if it's know at compile time, we can turn it into
183182
f(args[0], args[1], ... )
184183
*)
185-
(* {[ Bind (a,b) ]}
186-
is literally
187-
{[ a.bind(b) ]}
188-
*)
189184
(* Analysze over J expression is hard since,
190185
some primitive call is translated
191186
into a plain call, it's better to keep them
@@ -373,7 +368,6 @@ class virtual fold =
373368
let o = o#expression _x in let o = o#expression _x_i1 in o
374369
| String_append (_x, _x_i1) ->
375370
let o = o#expression _x in let o = o#expression _x_i1 in o
376-
| Anything_to_number _x -> let o = o#expression _x in o
377371
| Bool _x -> let o = o#bool _x in o
378372
| Typeof _x -> let o = o#expression _x in o
379373
| Js_not _x -> let o = o#expression _x in o
@@ -393,8 +387,6 @@ class virtual fold =
393387
let o = o#expression _x_i1 in let o = o#expression _x_i2 in o
394388
| FlatCall (_x, _x_i1) ->
395389
let o = o#expression _x in let o = o#expression _x_i1 in o
396-
| Bind (_x, _x_i1) ->
397-
let o = o#expression _x in let o = o#expression _x_i1 in o
398390
| Call (_x, _x_i1, _x_i2) ->
399391
let o = o#expression _x in
400392
let o = o#list (fun o -> o#expression) _x_i1 in

jscomp/core/js_map.ml

+1-11
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,7 @@ class virtual map =
143143
since GC does not rely on it
144144
*)
145145
(* shallow copy, like [x.slice] *)
146-
(* For [caml_array_append]*)
147-
(* | Tag_ml_obj of expression *) (* js true/false*)
146+
(* For [caml_array_append]*) (* js true/false*)
148147
(* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence
149148
[typeof] is an operator
150149
*)
@@ -195,10 +194,6 @@ class virtual map =
195194
if it's know at compile time, we can turn it into
196195
f(args[0], args[1], ... )
197196
*)
198-
(* {[ Bind (a,b) ]}
199-
is literally
200-
{[ a.bind(b) ]}
201-
*)
202197
(* Analysze over J expression is hard since,
203198
some primitive call is translated
204199
into a plain call, it's better to keep them
@@ -401,8 +396,6 @@ class virtual map =
401396
| String_append (_x, _x_i1) ->
402397
let _x = o#expression _x in
403398
let _x_i1 = o#expression _x_i1 in String_append (_x, _x_i1)
404-
| Anything_to_number _x ->
405-
let _x = o#expression _x in Anything_to_number _x
406399
| Bool _x -> let _x = o#bool _x in Bool _x
407400
| Typeof _x -> let _x = o#expression _x in Typeof _x
408401
| Js_not _x -> let _x = o#expression _x in Js_not _x
@@ -429,9 +422,6 @@ class virtual map =
429422
| FlatCall (_x, _x_i1) ->
430423
let _x = o#expression _x in
431424
let _x_i1 = o#expression _x_i1 in FlatCall (_x, _x_i1)
432-
| Bind (_x, _x_i1) ->
433-
let _x = o#expression _x in
434-
let _x_i1 = o#expression _x_i1 in Bind (_x, _x_i1)
435425
| Call (_x, _x_i1, _x_i2) ->
436426
let _x = o#expression _x in
437427
let _x_i1 = o#list (fun o -> o#expression) _x_i1 in

jscomp/core/js_pass_tailcall_inline.ml

+5-6
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ let subst name export_set stats =
220220
(* Mark a function as dead means it will never be scanned,
221221
here we inline the function
222222
*)
223-
Ext_list.append block @@ self#block rest
223+
Ext_list.append block (self#block rest)
224224
| (None | Some _) ->
225225
self#statement st :: self#block rest
226226
end
@@ -235,9 +235,8 @@ let subst name export_set stats =
235235

236236

237237
let tailcall_inline (program : J.program) =
238-
let _stats = get_stats program in
239-
let _export_set = program.export_set in
240-
program
241-
|> (subst program.name _export_set _stats )# program
242-
(* |> pass_beta #program *)
238+
let stats = get_stats program in
239+
let export_set = program.export_set in
240+
(subst program.name export_set stats )#program program
241+
243242

jscomp/core/lam_compile_primitive.ml

+1-3
Original file line numberDiff line numberDiff line change
@@ -703,9 +703,7 @@ let translate loc
703703
(* assert false (\* already handled *\) *)
704704
(* assert false *)
705705
| Pduprecord ((Record_regular
706-
| Record_float ),0)
707-
| Pduprecord ((Record_regular
708-
| Record_float ),_) ->
706+
| Record_float ),_size) -> (* _size is the length of all_lables*)
709707
begin match args with
710708
| [e] -> Js_of_lam_record.copy e
711709
| _ -> assert false

jscomp/core/lam_dispatch_primitive.ml

-2
Original file line numberDiff line numberDiff line change
@@ -659,8 +659,6 @@ let translate loc (prim_name : string)
659659
*)
660660
| _ -> E.array_copy a
661661
end
662-
(* if Js_analyzer.is_constant a then a
663-
else E.array_copy a *)
664662
| _ -> assert false
665663
end
666664
| "caml_obj_block" ->

jscomp/test/.depend

+1
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ gpr_2614_test.cmj :
311311
gpr_2633_test.cmj :
312312
gpr_2642_test.cmj :
313313
gpr_2652_test.cmj : ../others/node.cmj ../stdlib/buffer.cmj
314+
gpr_2700_test.cmj :
314315
gpr_405_test.cmj : ../stdlib/hashtbl.cmj gpr_405_test.cmi
315316
gpr_441.cmj :
316317
gpr_459_test.cmj : mt.cmj

jscomp/test/Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ OTHERS := test_literals a test_ari test_export2 test_internalOO test_obj_simple_
249249
gpr_2642_test\
250250
gpr_2652_test\
251251
gpr_2614_test\
252+
gpr_2700_test\
252253
# bs_uncurry_test
253254
# needs Lam to get rid of Uncurry arity first
254255
# simple_derive_test

jscomp/test/gpr_2700_test.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
'use strict';
2+
3+
4+
function f(x) {
5+
if (x === 3) {
6+
return true;
7+
} else {
8+
return x === 4;
9+
}
10+
}
11+
12+
exports.f = f;
13+
/* No side effect */

jscomp/test/gpr_2700_test.ml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
3+
4+
let f x = x = 3 || x = 4

0 commit comments

Comments
 (0)