Skip to content

Commit 8332217

Browse files
authored
Merge pull request #4573 from BuckleScript/reduandant_bs_string_warning
finish the conversion scheme based on the new polyvar representation
2 parents ecd89cb + 500dc22 commit 8332217

29 files changed

+602
-5643
lines changed

jscomp/main/builtin_cmi_datasets.ml

Lines changed: 3 additions & 3 deletions
Large diffs are not rendered by default.

jscomp/main/builtin_cmj_datasets.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
(* 61330acfc17e89625785adbca5c010d9 *)
1+
(* eb200c1f2c43b3345ec9d60dfe47627b *)
22
let module_names : string array = Obj.magic (
33
"Gc" (* 220 *),
44
"Js" (* 23 *),
@@ -86,7 +86,7 @@ let module_names : string array = Obj.magic (
8686
"Belt_SetInt" (* 657 *),
8787
"BytesLabels" (* 772 *),
8888
"Dom_storage" (* 23 *),
89-
"Js_mapperRt" (* 214 *),
89+
"Js_mapperRt" (* 87 *),
9090
"Node_buffer" (* 23 *),
9191
"Node_module" (* 23 *),
9292
"Belt_HashMap" (* 617 *),
@@ -221,7 +221,7 @@ let module_data : string array = Obj.magic (
221221
(* Belt_SetInt *)"\132\149\166\190\000\000\002}\000\000\000\197\000\000\002\130\000\000\002Y\160\b\000\000\156\000\176\"eq\144\160\160B@@@\176#add\144\160\160B@@@\176#cmp\144\160\160B@@@\176#get\144\160\160B@@@\176#has\144\160\160B@@@\176$diff\144\160\160B@@@\176$keep\144\160\160B@@@\176$size\144\160\160A@@@\176$some\144\160\160B@@@\176%empty\144@\144\146A\176%every\144\160\160B@@@\176%keepU\144\160\160B@@@\176%someU\144\160\160B@@@\176%split\144\160\160B@@@\176%union\144\160\160B@@@\176&everyU\144\160\160B@@@\176&getExn\144\160\160B@@@\176&reduce\144\160\160C@@@\176&remove\144\160\160B@@@\176&subset\144\160\160B@@@\176&toList\144\160\160A@@@\176'forEach\144\160\160B@@@\176'isEmpty\144\160\160A@@@\176'maximum\144\160\160A@@@\176'minimum\144\160\160A@@@\176'reduceU\144\160\160C@@@\176'toArray\144\160\160A@@@\176(forEachU\144\160\160B@@@\176)fromArray\144\160\160A@@@\176)intersect\144\160\160B@@@\176)mergeMany\144\160\160B@@@\176)partition\144\160\160B@@@\176*partitionU\144\160\160B@@@\176*removeMany\144\160\160B@@@\176,getUndefined\144\160\160B@@@\176,maxUndefined\144\160\160A@@@\176,minUndefined\144\160\160A@@@\1765fromSortedArrayUnsafe\144\160\160A@@@\1766checkInvariantInternal\144\160\160A@@@A",
222222
(* BytesLabels *)"\132\149\166\190\000\000\002\240\000\000\000\212\000\000\002\199\000\000\002\149\160\b\000\000\168\000\176#cat\144\160\160B@@@\176#map\144\160\160B@@@\176#sub\144\160\160C@@@\176$blit\144\160\160E@@@\176$copy\144\160\160A@@@\176$fill\144\160\160D@@@\176$init\144\160\160B@@@\176$iter\144\160\160B@@@\176$make\144\160\160B@@@\176$mapi\144\160\160B@@@\176$trim\144\160\160A@@@\176%equal\144\160\160B@@@\176%index\144\160\160B@@@\176%iteri\144\160\160B@@@\176&concat\144\160\160B@@@\176&extend\144\160\160C@@@\176&rindex\144\160\160B@@@\176'compare\144\160\160B@@@\176'escaped\144\160\160A@@@\176(contains\144\160\160B@@@\176)index_opt\144\160\160B@@@\176)lowercase\144\160\160A@@@\176)of_string\144\160\160A@@@\176)to_string\144\160\160A@@@\176)uppercase\144\160\160A@@@\176*capitalize\144\160\160A@@@\176*index_from\144\160\160C@@@\176*rindex_opt\144\160\160B@@@\176*sub_string\144\160\160C@@@\176+blit_string\144\160\160E@@@\176+rindex_from\144\160\160C@@@\176,uncapitalize\144\160\160A@@@\176-contains_from\144\160\160C@@@\176.index_from_opt\144\160\160C@@@\176.rcontains_from\144\160\160C@@@\176/lowercase_ascii\144\160\160A@@@\176/rindex_from_opt\144\160\160C@@@\176/uppercase_ascii\144\160\160A@@@\1760capitalize_ascii\144\160\160A@@@\1760unsafe_of_string\144\160\160A@@@\1760unsafe_to_string\144\160\160A@@@\1762uncapitalize_ascii\144\160\160A@@@A",
223223
(* Dom_storage *)"\132\149\166\190\000\000\000\003\000\000\000\001\000\000\000\003\000\000\000\003\160\128A",
224-
(* Js_mapperRt *)"\132\149\166\190\000\000\000\194\000\000\0002\000\000\000\168\000\000\000\156\160\224\176%toInt\144\160\160B@@\144\180B\160\176\001\004V!i@\160\176\001\004W\"xs@@\151\176g\160\144\004\006\160\144\004\011@\176\1925others/js_mapperRt.ml\000J\001\n\006\001\n\b\192\004\002\000J\001\n\006\001\n!@\176'fromInt\144\160\160C@@@\176)revSearch\144\160\160C@@@\176,binarySearch\144\160\160C@@@\176-fromIntAssert\144\160\160C@@@\176/revSearchAssert\144\160\160C@@@A",
224+
(* Js_mapperRt *)"\132\149\166\190\000\000\000C\000\000\000\017\000\000\0009\000\000\0004\160\176\176'fromInt\144\160\160C@@@\176-fromIntAssert\144\160\160C@@@\1761raiseWhenNotFound\144\160\160A@@@A",
225225
(* Node_buffer *)"\132\149\166\190\000\000\000\003\000\000\000\001\000\000\000\003\000\000\000\003\160\128A",
226226
(* Node_module *)"\132\149\166\190\000\000\000\003\000\000\000\001\000\000\000\003\000\000\000\003\160\128A",
227227
(* Belt_HashMap *)"\132\149\166\190\000\000\002U\000\000\000\170\000\000\002/\000\000\002\r\160\b\000\000X\000\176#get\144\160\160B@@@\176#has\144\160\160B@@@\176#set\144\160\160C@@@\176$copy\144\160\160A@@@\176$make\144\160\160B@@\144\180B\160\176\001\005c(hintSize@\160\176\001\005d\"id@@\147\192\151\176\161A\146$make\160\145\176@8Belt_internalBucketsTypeA@\176\192&_none_A@\000\255\004\002A\160\151\176\161@\146$hash\160\144\004\024@\004\011\160\151\176\161A\146\"eq\160\004\b@\004\018\160\144\004$@\176\1926others/belt_HashMap.ml\001\000\201\001\025\018\001\025\020\192\004\002\001\000\201\001\025\018\001\025;@A\176$size\144\160\160A@@\144\180A\160\176\001\004I!h@@\151\176\161@\161$sizeA\160\144\004\t@\176\192\004\021]\001\004\255\001\005\012\192\004\022]\001\004\255\001\005\020@\176%clear\144\160\160A@@@\176&reduce\144\160\160C@@@\176&remove\144\160\160B@@@\176'forEach\144\160\160B@@@\176'isEmpty\144\160\160A@@@\176'reduceU\144\160\160C@@@\176'toArray\144\160\160A@@@\176(forEachU\144\160\160B@@@\176(logStats\144\160\160A@@@\176)fromArray\144\160\160B@@@\176)mergeMany\144\160\160B@@@\176+keysToArray\144\160\160A@@@\176-valuesToArray\144\160\160A@@@\176.keepMapInPlace\144\160\160B@@@\176/keepMapInPlaceU\144\160\160B@@@\1762getBucketHistogram\144\160\160A@@@A",

jscomp/others/js_mapperRt.ml

Lines changed: 9 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -23,56 +23,10 @@
2323
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
2424

2525

26-
(*
27-
[lower, upper)
28-
when [lower] = [upper], impossible
29-
[upper - lower] = 1
30-
[mid = lower], it should hit
31-
[uper -lower > 1], [mid <> lower]
32-
*)
33-
let rec binarySearchAux lower upper xs (k : string) =
34-
if not (lower < upper) then Js_exn.raiseError "binarySearchAux";
35-
let mid = (lower + upper) / 2 in
36-
let i,v = Js_array2.unsafe_get xs mid in
37-
if i = k then v
38-
else if i < k then
39-
binarySearchAux (mid + 1) upper xs k
40-
else
41-
binarySearchAux lower mid xs k (*Invariant: mid < upper *)
42-
43-
44-
45-
let binarySearch upper (id : string) array : string =
46-
binarySearchAux 0 upper array id
47-
48-
let rec revSearchAux
49-
i len (xs : ('a * string) array) (k : string) =
50-
if i = len then None
51-
else
52-
let (idx,s) = Js.Array2.unsafe_get xs i in
53-
if s = k then
54-
Some (idx : string)
55-
else
56-
revSearchAux (i + 1) len xs k
57-
58-
let revSearch len array (x : string) : _ option =
59-
revSearchAux 0 len array x
60-
61-
let rec revSearchAssertAux len
62-
i (xs : (_ * string) array) (k : string) =
63-
[%assert i < len];
64-
let (idx,s) = Js.Array2.unsafe_get xs i in
65-
if s = k then
66-
idx
67-
else
68-
revSearchAssertAux len (i + 1) xs k
69-
70-
let revSearchAssert len array (x : string) =
71-
revSearchAssertAux len 0 array x
72-
73-
let toInt (i : int) (xs : int array) =
74-
Js.Array2.unsafe_get xs i
75-
26+
let raiseWhenNotFound x =
27+
if Js.testAny x then raise Not_found
28+
else x
29+
7630
let rec fromIntAux (enum : int) i len xs =
7731
if i = len then None
7832
else
@@ -84,11 +38,11 @@ let fromInt len (xs : int array) (enum : int ) : 'variant option =
8438
fromIntAux enum 0 len xs
8539

8640
let rec fromIntAssertAux len (enum : int) i xs =
87-
[%assert i < len];
88-
(*TODO: replaced by [%assert i < len ]*)
89-
let k = Js.Array2.unsafe_get xs i in
90-
if k = enum then i
91-
else fromIntAssertAux len enum (i + 1) xs
41+
if i = len then raise Not_found
42+
else
43+
let k = Js.Array2.unsafe_get xs i in
44+
if k = enum then i
45+
else fromIntAssertAux len enum (i + 1) xs
9246

9347
(** [length] is not relevant any more *)
9448
let fromIntAssert len (xs : int array) (enum : int )=

jscomp/others/js_mapperRt.mli

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -23,39 +23,10 @@
2323
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
2424

2525

26-
(** [serach polyvar assocArray]
27-
Search hashvariant of [polyvar] to get the returned string,
28-
assume that [polvar] exists in the array
29-
*)
30-
val binarySearch:
31-
int ->
32-
string ->
33-
(string * string) array ->
34-
string
35-
36-
(**
37-
[revSearch len assocArray value]
38-
Based on the value to find the associated key, i.e, polyvar
39-
*)
40-
val revSearch:
41-
int ->
42-
(string * string) array ->
43-
string ->
44-
string option
4526

46-
val revSearchAssert:
47-
int -> (* len *)
48-
('a * string) array ->
49-
string ->
50-
'a
27+
val raiseWhenNotFound :
28+
'a -> 'a
5129

52-
(**
53-
[toInt enum array]
54-
Based on the value of [enum], return its mapped int
55-
*)
56-
val toInt :
57-
int -> int array -> int
58-
5930
(**
6031
[fromInt len array int]
6132
return the mapped [enum]

jscomp/others/release.ninja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ build others/js_json.cmj : cc_cmi others/js_json.ml | others/js_array2.cmj other
3030
build others/js_json.cmi : cc others/js_json.mli | others/js_dict.cmi others/js_null.cmi others/js_string.cmj others/js_types.cmi runtime
3131
build others/js_list.cmj : cc_cmi others/js_list.ml | others/js_array2.cmj others/js_list.cmi others/js_vector.cmj runtime
3232
build others/js_list.cmi : cc others/js_list.mli | others/js_vector.cmi runtime
33-
build others/js_mapperRt.cmj : cc_cmi others/js_mapperRt.ml | others/js_array2.cmj others/js_exn.cmj others/js_mapperRt.cmi runtime
33+
build others/js_mapperRt.cmj : cc_cmi others/js_mapperRt.ml | others/js_mapperRt.cmi runtime
3434
build others/js_mapperRt.cmi : cc others/js_mapperRt.mli | runtime
3535
build others/js_math.cmi others/js_math.cmj : cc others/js_math.ml | others/js_int.cmj runtime
3636
build others/js_null.cmj : cc_cmi others/js_null.ml | others/js_exn.cmj others/js_null.cmi runtime

jscomp/syntax/ast_attributes.ml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,10 @@ let is_bs (attr : attr) =
357357

358358

359359
let bs_get : attr
360-
= {txt = "bs.get"; loc = locg}, Ast_payload.empty
360+
= {txt = "bs.get"; loc = locg}, Ast_payload.empty
361+
362+
let bs_get_index : attr =
363+
{txt = "bs.get_index"; loc = locg}, Ast_payload.empty
361364

362365
let bs_get_arity : attr
363366
= {txt = "internal.arity"; loc = locg},

jscomp/syntax/ast_attributes.mli

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ val is_bs_as : attr -> bool *)
107107

108108

109109
val bs_get : attr
110+
val bs_get_index : attr
110111
val bs_get_arity : attr
111112
val bs_set : attr
112113
val bs_return_undefined : attr

jscomp/syntax/ast_compatible.ml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,6 @@ let object_field l attrs ty =
273273

274274

275275

276-
let hash_label (x : poly_var_label) : hash_label = x.txt
277-
let label_of_name (x : poly_var_label) : string = x.txt
278276

279277
type args =
280278
(Asttypes.arg_label * Parsetree.expression) list

jscomp/syntax/ast_compatible.mli

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,6 @@ type object_field =
197197
val object_field : Asttypes.label Asttypes.loc -> attributes -> core_type -> object_field
198198

199199

200-
val hash_label : poly_var_label -> hash_label
201-
202-
val label_of_name : poly_var_label -> string
203200

204201
type args =
205202
(Asttypes.arg_label * Parsetree.expression) list

0 commit comments

Comments
 (0)