Skip to content

Commit 9d682ff

Browse files
authored
Merge pull request #4138 from BuckleScript/dce
remove unused code
2 parents 65b47eb + 74e9317 commit 9d682ff

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+878
-962
lines changed

jscomp/core/lam.mli

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ val switch : t -> lambda_switch -> t
117117
(** constant folding*)
118118
val stringswitch : t -> (string * t) list -> t option -> t
119119

120-
val true_ : t
121-
val false_ : t
120+
(* val true_ : t *)
121+
(* val false_ : t *)
122122
val unit : t
123123

124124
(** convert [l || r] to [if l then true else r]*)

jscomp/js_parser/file_key.ml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ let to_string = function
2323
x
2424
| Builtins -> "(global)"
2525

26-
let to_path = function
26+
(* let to_path = function
2727
| LibFile x
2828
| SourceFile x
2929
| JsonFile x
3030
| ResourceFile x ->
3131
Ok x
32-
| Builtins -> Error "File key refers to a builtin"
32+
| Builtins -> Error "File key refers to a builtin" *)
3333

3434
let compare =
3535
(* builtins, then libs, then source and json files at the same priority since
@@ -56,30 +56,30 @@ let compare_opt a b =
5656
| (None, None) -> 0
5757
| (Some a, Some b) -> compare a b
5858

59-
let is_lib_file = function
59+
(* let is_lib_file = function
6060
| LibFile _ -> true
6161
| Builtins -> true
6262
| SourceFile _ -> false
6363
| JsonFile _ -> false
64-
| ResourceFile _ -> false
64+
| ResourceFile _ -> false *)
6565

66-
let map f = function
66+
(* let map f = function
6767
| LibFile filename -> LibFile (f filename)
6868
| SourceFile filename -> SourceFile (f filename)
6969
| JsonFile filename -> JsonFile (f filename)
7070
| ResourceFile filename -> ResourceFile (f filename)
71-
| Builtins -> Builtins
71+
| Builtins -> Builtins *)
7272

73-
let exists f = function
73+
(* let exists f = function
7474
| LibFile filename
7575
| SourceFile filename
7676
| JsonFile filename
7777
| ResourceFile filename ->
7878
f filename
79-
| Builtins -> false
79+
| Builtins -> false *)
8080

81-
let check_suffix filename suffix = exists (fun fn -> Filename.check_suffix fn suffix) filename
81+
(* let check_suffix filename suffix = exists (fun fn -> Filename.check_suffix fn suffix) filename
8282
8383
let chop_suffix filename suffix = map (fun fn -> Filename.chop_suffix fn suffix) filename
8484
85-
let with_suffix filename suffix = map (fun fn -> fn ^ suffix) filename
85+
let with_suffix filename suffix = map (fun fn -> fn ^ suffix) filename *)

jscomp/js_parser/flow_ast_utils.ml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ type 'loc ident = 'loc * string
1414

1515
type 'loc source = 'loc * string
1616

17-
let rec fold_bindings_of_pattern =
17+
(* let rec fold_bindings_of_pattern =
1818
Pattern.(
1919
let property f acc =
2020
Object.(
@@ -35,9 +35,9 @@ let rec fold_bindings_of_pattern =
3535
| Identifier { Identifier.name; _ } -> f acc name
3636
| Object { Object.properties; _ } -> List.fold_left (property f) acc properties
3737
| Array { Array.elements; _ } -> List.fold_left (element f) acc elements
38-
| Expression _ -> failwith "expression pattern")
38+
| Expression _ -> failwith "expression pattern") *)
3939

40-
let fold_bindings_of_variable_declarations f acc declarations =
40+
(* let fold_bindings_of_variable_declarations f acc declarations =
4141
Flow_ast.Statement.VariableDeclaration.(
4242
List.fold_left
4343
(fun acc -> function
@@ -70,11 +70,11 @@ let loc_of_expression = fst
7070
7171
let loc_of_pattern = fst
7272
73-
let loc_of_ident = fst
73+
let loc_of_ident = fst *)
7474

7575
let name_of_ident (_, { Identifier.name; comments = _ }) = name
7676

77-
let source_of_ident (loc, { Identifier.name; comments = _ }) = (loc, name)
77+
(* let source_of_ident (loc, { Identifier.name; comments = _ }) = (loc, name) *)
7878

7979
let ident_of_source (loc, name) = (loc, { Identifier.name; comments = None })
8080

@@ -85,7 +85,7 @@ let mk_comments_opt ?(leading = []) ?(trailing = []) () =
8585
| ([], []) -> None
8686
| (_, _) -> Some (mk_comments ~leading ~trailing ())
8787

88-
let string_of_assignment_operator op =
88+
(* let string_of_assignment_operator op =
8989
Flow_ast.Expression.Assignment.(
9090
match op with
9191
| PlusAssign -> "+="
@@ -125,7 +125,7 @@ let string_of_binary_operator op =
125125
| Xor -> "^"
126126
| BitAnd -> "&"
127127
| In -> "in"
128-
| Instanceof -> "instanceof")
128+
| Instanceof -> "instanceof") *)
129129

130130
module ExpressionSort = struct
131131
type t =
@@ -161,7 +161,7 @@ module ExpressionSort = struct
161161
| Update
162162
| Yield
163163

164-
let to_string = function
164+
(* let to_string = function
165165
| Array -> "array"
166166
| ArrowFunction -> "arrow function"
167167
| Assignment -> "assignment expression"
@@ -192,5 +192,5 @@ module ExpressionSort = struct
192192
| TypeCast -> "type cast"
193193
| Unary -> "unary expression"
194194
| Update -> "update expression"
195-
| Yield -> "yield expression"
195+
| Yield -> "yield expression" *)
196196
end

jscomp/js_parser/flow_ast_utils.mli

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ type 'loc ident = 'loc * string
1111

1212
type 'loc source = 'loc * string
1313

14-
val fold_bindings_of_pattern :
14+
(* val fold_bindings_of_pattern :
1515
('a -> ('loc, 'loc) Flow_ast.Identifier.t -> 'a) -> 'a -> ('loc, 'loc) Flow_ast.Pattern.t' -> 'a
1616
1717
val fold_bindings_of_variable_declarations :
@@ -32,19 +32,19 @@ val loc_of_statement : ('a, 'a) Flow_ast.Statement.t -> 'a
3232
3333
val loc_of_pattern : ('a, 'a) Flow_ast.Pattern.t -> 'a
3434
35-
val loc_of_ident : ('a, 'a) Flow_ast.Identifier.t -> 'a
35+
val loc_of_ident : ('a, 'a) Flow_ast.Identifier.t -> 'a *)
3636

3737
val name_of_ident : ('loc, 'a) Flow_ast.Identifier.t -> string
3838

39-
val source_of_ident : ('a, 'a) Flow_ast.Identifier.t -> 'a source
39+
(* val source_of_ident : ('a, 'a) Flow_ast.Identifier.t -> 'a source *)
4040

4141
val ident_of_source : 'a source -> ('a, 'a) Flow_ast.Identifier.t
4242

43-
val mk_comments :
43+
(* val mk_comments :
4444
?leading:'loc Flow_ast.Comment.t list ->
4545
?trailing:'loc Flow_ast.Comment.t list ->
4646
'a ->
47-
('loc, 'a) Flow_ast.Syntax.t
47+
('loc, 'a) Flow_ast.Syntax.t *)
4848

4949
val mk_comments_opt :
5050
?leading:'loc Flow_ast.Comment.t list ->
@@ -86,9 +86,9 @@ module ExpressionSort : sig
8686
| Update
8787
| Yield
8888

89-
val to_string : t -> string
89+
(* val to_string : t -> string *)
9090
end
9191

92-
val string_of_assignment_operator : Flow_ast.Expression.Assignment.operator -> string
92+
(* val string_of_assignment_operator : Flow_ast.Expression.Assignment.operator -> string *)
9393

94-
val string_of_binary_operator : Flow_ast.Expression.Binary.operator -> string
94+
(* val string_of_binary_operator : Flow_ast.Expression.Binary.operator -> string *)

jscomp/js_parser/lex_env.ml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ let get_and_clear_state env =
5050
in
5151
(env, state)
5252

53-
let lexbuf env = env.lex_lb
53+
(* let lexbuf env = env.lex_lb *)
5454

5555
let source env = env.lex_source
5656

57-
let state env = env.lex_state
57+
(* let state env = env.lex_state *)
5858

5959
let line env = env.lex_bol.line
6060

@@ -71,9 +71,9 @@ let in_comment_syntax is_in env =
7171
env
7272

7373
(* TODO *)
74-
let debug_string_of_lexbuf _lb = ""
74+
(* let debug_string_of_lexbuf _lb = "" *)
7575

76-
let debug_string_of_lex_env (env : t) =
76+
(* let debug_string_of_lex_env (env : t) =
7777
let source =
7878
match source env with
7979
| None -> "None"
@@ -85,4 +85,4 @@ let debug_string_of_lex_env (env : t) =
8585
(debug_string_of_lexbuf env.lex_lb)
8686
(is_in_comment_syntax env)
8787
(is_comment_syntax_enabled env)
88-
(List.length (state env).lex_errors_acc)
88+
(List.length (state env).lex_errors_acc) *)

jscomp/js_parser/lex_result.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ let comments result = result.lex_comments
2020

2121
let errors result = result.lex_errors
2222

23-
let debug_string_of_lex_result lex_result =
23+
(* let debug_string_of_lex_result lex_result =
2424
Printf.sprintf
2525
"{\n lex_token = %s\n lex_value = %S\n lex_errors = (length = %d)\n lex_comments = (length = %d)\n}"
2626
(Token.token_to_string lex_result.lex_token)
2727
(Token.value_of_token lex_result.lex_token)
2828
(List.length lex_result.lex_errors)
29-
(List.length lex_result.lex_comments)
29+
(List.length lex_result.lex_comments) *)

jscomp/js_parser/loc.ml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ let btwn loc1 loc2 = { source = loc1.source; start = loc1.start; _end = loc2._en
2727
(* Returns the position immediately before the start of the given loc. If the
2828
given loc is at the beginning of a line, return the position of the first
2929
char on the same line. *)
30-
let char_before loc =
30+
(* let char_before loc =
3131
let start =
3232
let { line; column } = loc.start in
3333
let column =
@@ -39,14 +39,14 @@ let char_before loc =
3939
{ line; column }
4040
in
4141
let _end = loc.start in
42-
{ loc with start; _end }
42+
{ loc with start; _end } *)
4343

4444
(* Returns the location of the first character in the given loc. Not accurate if the
4545
* first line is a newline character, but is still consistent with loc orderings. *)
46-
let first_char loc =
46+
(* let first_char loc =
4747
let start = loc.start in
4848
let _end = { start with column = start.column + 1 } in
49-
{ loc with _end }
49+
{ loc with _end } *)
5050

5151
let pos_cmp a b =
5252
let k = a.line - b.line in
@@ -60,7 +60,7 @@ let pos_cmp a b =
6060
* If `b` starts before `a` (even if it ends inside), returns < 0.
6161
* If `b` ends after `a` (even if it starts inside), returns > 0.
6262
*)
63-
let span_compare a b =
63+
(* let span_compare a b =
6464
let k = File_key.compare_opt a.source b.source in
6565
if k = 0 then
6666
let k = pos_cmp a.start b.start in
@@ -73,15 +73,15 @@ let span_compare a b =
7373
else
7474
1
7575
else
76-
k
76+
k *)
7777

7878
(* Returns true if loc1 entirely overlaps loc2 *)
79-
let contains loc1 loc2 = span_compare loc1 loc2 = 0
79+
(* let contains loc1 loc2 = span_compare loc1 loc2 = 0 *)
8080

8181
(* Returns true if loc1 intersects loc2 at all *)
82-
let lines_intersect loc1 loc2 =
82+
(* let lines_intersect loc1 loc2 =
8383
File_key.compare_opt loc1.source loc2.source = 0
84-
&& not (loc1._end.line < loc2.start.line || loc1.start.line > loc2._end.line)
84+
&& not (loc1._end.line < loc2.start.line || loc1.start.line > loc2._end.line) *)
8585

8686
let compare loc1 loc2 =
8787
let k = File_key.compare_opt loc1.source loc2.source in
@@ -94,13 +94,13 @@ let compare loc1 loc2 =
9494
else
9595
k
9696

97-
let equal loc1 loc2 = compare loc1 loc2 = 0
97+
(* let equal loc1 loc2 = compare loc1 loc2 = 0 *)
9898

9999
(**
100100
* This is mostly useful for debugging purposes.
101101
* Please don't dead-code delete this!
102102
*)
103-
let debug_to_string ?(include_source = false) loc =
103+
(* let debug_to_string ?(include_source = false) loc =
104104
let source =
105105
if include_source then
106106
Printf.sprintf
@@ -119,9 +119,9 @@ let debug_to_string ?(include_source = false) loc =
119119
loc._end.line
120120
loc._end.column
121121
in
122-
source ^ pos
122+
source ^ pos *)
123123

124-
let to_string_no_source loc =
124+
(* let to_string_no_source loc =
125125
let line = loc.start.line in
126126
let start = loc.start.column + 1 in
127127
let end_ = loc._end.column in
@@ -141,4 +141,4 @@ let make file line col =
141141
142142
let start_loc loc = { loc with _end = loc.start }
143143
144-
let end_loc loc = { loc with start = loc._end }
144+
let end_loc loc = { loc with start = loc._end } *)

jscomp/js_parser/loc.mli

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ val none : t
2222

2323
val btwn : t -> t -> t
2424

25-
val char_before : t -> t
25+
(* val char_before : t -> t
2626
2727
val first_char : t -> t
2828
@@ -32,16 +32,16 @@ val lines_intersect : t -> t -> bool
3232
3333
val pos_cmp : position -> position -> int
3434
35-
val span_compare : t -> t -> int
35+
val span_compare : t -> t -> int *)
3636

3737
val compare : t -> t -> int
3838

39-
val equal : t -> t -> bool
39+
(* val equal : t -> t -> bool
4040
41-
val debug_to_string : ?include_source:bool -> t -> string
41+
val debug_to_string : ?include_source:bool -> t -> string *)
4242

4343
(* Relatively compact; suitable for use as a unique string identifier *)
44-
val to_string_no_source : t -> string
44+
(* val to_string_no_source : t -> string
4545
4646
val source : t -> File_key.t option
4747
@@ -52,4 +52,4 @@ val make : File_key.t -> int -> int -> t
5252
val start_loc : t -> t
5353
5454
(* Produces a location at the end of the input location *)
55-
val end_loc : t -> t
55+
val end_loc : t -> t *)

jscomp/js_parser/parse_error.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ type t =
153153

154154
exception Error of (Loc.t * t) list
155155

156-
let error loc e = raise (Error [(loc, e)])
156+
(* let error loc e = raise (Error [(loc, e)]) *)
157157

158158
module PP = struct
159159
let error = function

0 commit comments

Comments
 (0)