Skip to content

Commit f636e66

Browse files
committed
remove unused code
1 parent e4b9322 commit f636e66

26 files changed

+525
-539
lines changed

jscomp/bsb/bsb_ninja_file_groups.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ let emit_module_build
9696
filename_sans_extension ^ if is_re then Literals.suffix_reiast else Literals.suffix_mliast in
9797
let output_d = filename_sans_extension ^ Literals.suffix_d in
9898
let output_filename_sans_extension =
99-
Ext_namespace.make ?ns:namespace filename_sans_extension
99+
Ext_namespace_encode.make ?ns:namespace filename_sans_extension
100100
in
101101
let output_cmi = output_filename_sans_extension ^ Literals.suffix_cmi in
102102
let output_cmj = output_filename_sans_extension ^ Literals.suffix_cmj in

jscomp/bsb/bsb_world.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ let install_targets cwd ({files_to_install; namespace; package_name = _} : Bsb_c
3535
let lib_artifacts_dir = Lazy.force Bsb_global_backend.lib_artifacts_dir in
3636
let install_filename_sans_extension destdir namespace x =
3737
let x =
38-
Ext_namespace.make ?ns:namespace x in
38+
Ext_namespace_encode.make ?ns:namespace x in
3939
install ~destdir (cwd // x ^ Literals.suffix_ml) ;
4040
install ~destdir (cwd // x ^ Literals.suffix_re) ;
4141
install ~destdir (cwd // x ^ Literals.suffix_mli) ;

jscomp/bsb_helper/bsb_helper_depfile_gen.ml

+5-5
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ type kind = Js | Bytecode | Native
9191

9292
let output_file (buf : Ext_buffer.t) source namespace =
9393
Ext_buffer.add_string buf
94-
(Ext_namespace.make ?ns:namespace source)
94+
(Ext_namespace_encode.make ?ns:namespace source)
9595

9696
(** for bucklescript artifacts
9797
[lhs_suffix] is [.cmj]
@@ -144,11 +144,11 @@ let oc_impl
144144
output_file buf (Ext_filename.chop_extension_maybe mlast) namespace ;
145145
Ext_buffer.add_string buf lhs_suffix;
146146
Ext_buffer.add_string buf dep_lit ) in
147-
Ext_option.iter namespace (fun ns ->
147+
(match namespace with None -> () | Some ns ->
148148
Lazy.force at_most_once;
149149
Ext_buffer.add_string buf ns;
150150
Ext_buffer.add_string buf Literals.suffix_cmi;
151-
) ; (* TODO: moved into static files*)
151+
) ; (* TODO: moved into static files*)
152152
let is_not_lib_dir = not (Bsb_dir_index.is_lib_dir index) in
153153
let s = extract_dep_raw_string mlast in
154154
let offset = ref 1 in
@@ -206,11 +206,11 @@ let oc_intf
206206
output_file buf (Ext_filename.chop_all_extensions_maybe mliast) namespace ;
207207
Ext_buffer.add_string buf Literals.suffix_cmi ;
208208
Ext_buffer.add_string buf dep_lit) in
209-
Ext_option.iter namespace (fun ns ->
209+
(match namespace with None -> () | Some ns ->
210210
Lazy.force at_most_once;
211211
Ext_buffer.add_string buf ns;
212212
Ext_buffer.add_string buf Literals.suffix_cmi;
213-
) ;
213+
) ;
214214
let cur_module_name = Ext_filename.module_name mliast in
215215
let is_not_lib_dir = not (Bsb_dir_index.is_lib_dir index) in
216216
let s = extract_dep_raw_string mliast in

jscomp/core/js_implementation.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ let make_structure_item ~ns cunit : Parsetree.structure_item =
227227
(Mb.mk {txt = cunit; loc }
228228
(Mod.ident
229229
{txt = Lident
230-
( Ext_namespace.make ~ns cunit)
230+
( Ext_namespace_encode.make ~ns cunit)
231231
; loc}))
232232

233233

jscomp/ext/ext_buffer.ml

+9-12
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ let contents b = Bytes.sub_string b.buffer 0 b.position
4848

4949
let length b = b.position
5050
let is_empty b = b.position = 0
51-
let clear b = b.position <- 0
51+
(* let clear b = b.position <- 0 *)
5252

5353
(* let reset b =
5454
b.position <- 0; b.buffer <- b.initial_buffer;
@@ -80,17 +80,17 @@ let add_char b c =
8080
Bytes.unsafe_set b.buffer pos c;
8181
b.position <- pos + 1
8282

83-
let add_substring b s offset len =
83+
(* let add_substring b s offset len =
8484
if offset < 0 || len < 0 || offset > String.length s - len
8585
then invalid_arg "Ext_buffer.add_substring/add_subbytes";
8686
let new_position = b.position + len in
8787
if new_position > b.length then resize b len;
8888
Ext_bytes.unsafe_blit_string s offset b.buffer b.position len;
89-
b.position <- new_position
89+
b.position <- new_position *)
9090

9191

92-
let add_subbytes b s offset len =
93-
add_substring b (Bytes.unsafe_to_string s) offset len
92+
(* let add_subbytes b s offset len =
93+
add_substring b (Bytes.unsafe_to_string s) offset len *)
9494

9595
let add_string b s =
9696
let len = String.length s in
@@ -122,22 +122,19 @@ let add_char_string b c s =
122122
b.position <- new_position
123123

124124

125-
let add_bytes b s = add_string b (Bytes.unsafe_to_string s)
125+
(* let add_bytes b s = add_string b (Bytes.unsafe_to_string s)
126126
127127
let add_buffer b bs =
128-
add_subbytes b bs.buffer 0 bs.position
128+
add_subbytes b bs.buffer 0 bs.position *)
129129

130-
let add_channel b ic len =
130+
(* let add_channel b ic len =
131131
if len < 0
132-
#if BS then
133-
#else
134132
|| len > Sys.max_string_length
135-
#end
136133
then (* PR#5004 *)
137134
invalid_arg "Ext_buffer.add_channel";
138135
if b.position + len > b.length then resize b len;
139136
really_input ic b.buffer b.position len;
140-
b.position <- b.position + len
137+
b.position <- b.position + len *)
141138

142139
let output_buffer oc b =
143140
output oc b.buffer 0 b.position

jscomp/ext/ext_buffer.mli

+6-6
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ val length : t -> int
4747

4848
val is_empty : t -> bool
4949

50-
val clear : t -> unit
50+
(* val clear : t -> unit *)
5151
(** Empty the buffer. *)
5252

5353

@@ -57,24 +57,24 @@ val add_char : t -> char -> unit
5757
val add_string : t -> string -> unit
5858
(** [add_string b s] appends the string [s] at the end of the buffer [b]. *)
5959

60-
val add_bytes : t -> bytes -> unit
60+
(* val add_bytes : t -> bytes -> unit *)
6161
(** [add_string b s] appends the string [s] at the end of the buffer [b].
6262
@since 4.02 *)
6363

64-
val add_substring : t -> string -> int -> int -> unit
64+
(* val add_substring : t -> string -> int -> int -> unit *)
6565
(** [add_substring b s ofs len] takes [len] characters from offset
6666
[ofs] in string [s] and appends them at the end of the buffer [b]. *)
6767

68-
val add_subbytes : t -> bytes -> int -> int -> unit
68+
(* val add_subbytes : t -> bytes -> int -> int -> unit *)
6969
(** [add_substring b s ofs len] takes [len] characters from offset
7070
[ofs] in byte sequence [s] and appends them at the end of the buffer [b].
7171
@since 4.02 *)
7272

73-
val add_buffer : t -> t -> unit
73+
(* val add_buffer : t -> t -> unit *)
7474
(** [add_buffer b1 b2] appends the current contents of buffer [b2]
7575
at the end of buffer [b1]. [b2] is not modified. *)
7676

77-
val add_channel : t -> in_channel -> int -> unit
77+
(* val add_channel : t -> in_channel -> int -> unit *)
7878
(** [add_channel b ic n] reads exactly [n] character from the
7979
input channel [ic] and stores them at the end of buffer [b].
8080
Raise [End_of_file] if the channel contains fewer than [n]

jscomp/ext/ext_namespace.ml

+1-10
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,14 @@
2424
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
2525

2626

27-
(* Note the build system should check the validity of filenames
28-
espeically, it should not contain '-'
29-
*)
30-
let ns_sep_char = '-'
31-
let ns_sep = "-"
3227

33-
let make ?ns cunit =
34-
match ns with
35-
| None -> cunit
36-
| Some ns -> cunit ^ ns_sep ^ ns
3728

3829

3930
let rec rindex_rec s i =
4031
if i < 0 then i else
4132
let char = String.unsafe_get s i in
4233
if Ext_filename.is_dir_sep char then -1
43-
else if char = ns_sep_char then i
34+
else if char = Literals.ns_sep_char then i
4435
else
4536
rindex_rec s (i - 1)
4637

jscomp/ext/ext_namespace.mli

+1-6
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,7 @@
2222
* along with this program; if not, write to the Free Software
2323
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
2424

25-
(** [make ~ns:"Ns" "a" ]
26-
A typical example would return "a-Ns"
27-
Note the namespace comes from the output of [namespace_of_package_name]
28-
*)
29-
val make :
30-
?ns:string -> string -> string
25+
3126

3227
val try_split_module_name :
3328
string -> (string * string ) option

jscomp/ext/ext_namespace_encode.ml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
(* Copyright (C) 2020- Authors of BuckleScript
2+
*
3+
* This program is free software: you can redistribute it and/or modify
4+
* it under the terms of the GNU Lesser General Public License as published by
5+
* the Free Software Foundation, either version 3 of the License, or
6+
* (at your option) any later version.
7+
*
8+
* In addition to the permissions granted to you by the LGPL, you may combine
9+
* or link a "work that uses the Library" with a publicly distributed version
10+
* of this file to produce a combined library or application, then distribute
11+
* that combined work under the terms of your choosing, with no requirement
12+
* to comply with the obligations normally placed on you by section 4 of the
13+
* LGPL version 3 (or the corresponding section of a later version of the LGPL
14+
* should you choose to use a later version).
15+
*
16+
* This program is distributed in the hope that it will be useful,
17+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19+
* GNU Lesser General Public License for more details.
20+
*
21+
* You should have received a copy of the GNU Lesser General Public License
22+
* along with this program; if not, write to the Free Software
23+
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
24+
25+
let make ?ns cunit =
26+
match ns with
27+
| None -> cunit
28+
| Some ns -> cunit ^ Literals.ns_sep ^ ns

jscomp/ext/ext_namespace_encode.mli

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
(* Copyright (C) 2020- Authors of BuckleScript
2+
*
3+
* This program is free software: you can redistribute it and/or modify
4+
* it under the terms of the GNU Lesser General Public License as published by
5+
* the Free Software Foundation, either version 3 of the License, or
6+
* (at your option) any later version.
7+
*
8+
* In addition to the permissions granted to you by the LGPL, you may combine
9+
* or link a "work that uses the Library" with a publicly distributed version
10+
* of this file to produce a combined library or application, then distribute
11+
* that combined work under the terms of your choosing, with no requirement
12+
* to comply with the obligations normally placed on you by section 4 of the
13+
* LGPL version 3 (or the corresponding section of a later version of the LGPL
14+
* should you choose to use a later version).
15+
*
16+
* This program is distributed in the hope that it will be useful,
17+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19+
* GNU Lesser General Public License for more details.
20+
*
21+
* You should have received a copy of the GNU Lesser General Public License
22+
* along with this program; if not, write to the Free Software
23+
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
24+
25+
(** [make ~ns:"Ns" "a" ]
26+
A typical example would return "a-Ns"
27+
Note the namespace comes from the output of [namespace_of_package_name]
28+
*)
29+
val make :
30+
?ns:string -> string -> string
31+

jscomp/ext/literals.ml

+7-1
Original file line numberDiff line numberDiff line change
@@ -132,4 +132,10 @@ let gentype_import = "genType.import"
132132

133133
let bsbuild_cache = ".bsbuild"
134134

135-
let sourcedirs_meta = ".sourcedirs.json"
135+
let sourcedirs_meta = ".sourcedirs.json"
136+
137+
(* Note the build system should check the validity of filenames
138+
espeically, it should not contain '-'
139+
*)
140+
let ns_sep_char = '-'
141+
let ns_sep = "-"

jscomp/ext/literals.mli

+4-1
Original file line numberDiff line numberDiff line change
@@ -132,4 +132,7 @@ val gentype_import : string
132132

133133
val bsbuild_cache : string
134134

135-
val sourcedirs_meta : string
135+
val sourcedirs_meta : string
136+
137+
val ns_sep_char : char
138+
val ns_sep : string

0 commit comments

Comments
 (0)