Skip to content

Commit d70e031

Browse files
authored
Merge pull request #4196 from BuckleScript/support_indexed_operators
support printing indexed operators && remove unused String load/set
2 parents b5691e1 + 6176f1e commit d70e031

27 files changed

+248
-296
lines changed

.vscode/tasks.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,23 @@
8484
"autoDetect",
8585
"owner": "globalUnused"
8686
}
87+
},
88+
{
89+
"label": "check unused refmt",
90+
"command" : "node",
91+
"options": {
92+
"cwd": "${workspaceRoot}/lib"
93+
},
94+
"args": [
95+
"../scripts/checkUnused.js" ,
96+
"refmt_main3"
97+
],
98+
"problemMatcher" :{
99+
"base": "$ocamlc",
100+
"fileLocation" :
101+
"autoDetect",
102+
"owner": "globalUnused"
103+
}
87104
}
88105
]
89106
}

jscomp/core/js_long.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ let compare (args : J.expression list) =
167167

168168
(* let of_string (args : J.expression list) =
169169
int64_call "of_string" args *)
170-
let get64 = int64_call "get64"
170+
(* let get64 = int64_call "get64" *)
171171
let float_of_bits = int64_call "float_of_bits"
172172
let bits_of_float = int64_call "bits_of_float"
173173
let min args =

jscomp/core/js_long.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,4 @@ val compare : int64_call
6363
(* val of_string : int64_call *)
6464
val float_of_bits : int64_call
6565
val bits_of_float : int64_call
66-
val get64 : int64_call
66+
(* val get64 : int64_call *)

jscomp/core/lam_analysis.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,12 +191,12 @@ let rec no_side_effects (lam : Lam.t) : bool =
191191
(* size of the nth dimension of a big array *)
192192
| Pbigarraydim _
193193
(* load/set 16,32,64 bits from a string: (unsafe)*)
194-
| Pstring_load_16 _
194+
(* | Pstring_load_16 _
195195
| Pstring_load_32 _
196-
| Pstring_load_64 _
197-
| Pstring_set_16 _
196+
| Pstring_load_64 _ *)
197+
(* | Pstring_set_16 _
198198
| Pstring_set_32 _
199-
| Pstring_set_64 _
199+
| Pstring_set_64 _ *)
200200
(* load/set 16,32,64 bits from a
201201
(char, int8_unsigned_elt, c_layout) Bigarray.Array1.t : (unsafe) *)
202202
| Pbigstring_load_16 _

jscomp/core/lam_compile_primitive.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -686,12 +686,12 @@ let translate loc
686686
E.runtime_call Js_runtime_modules.int32 "caml_int32_bswap" args
687687
| Pbbswap Lambda.Pint64
688688
-> Js_long.swap args
689-
| Pstring_load_16 unsafe
689+
(* | Pstring_load_16 unsafe
690690
-> E.runtime_call Js_runtime_modules.string "caml_string_get16" args
691691
| Pstring_load_32 unsafe
692692
-> E.runtime_call Js_runtime_modules.string "caml_string_get32" args
693693
| Pstring_load_64 unsafe
694-
-> Js_long.get64 args
694+
-> Js_long.get64 args *)
695695

696696
| Plazyforce
697697
(* let parm = Ident.create "prim" in
@@ -700,9 +700,9 @@ let translate loc
700700
It is inlined, this should not appear here *)
701701
| Pbittest
702702

703-
| Pstring_set_16 _
703+
(* | Pstring_set_16 _
704704
| Pstring_set_32 _
705-
| Pstring_set_64 _
705+
| Pstring_set_64 _ *)
706706
| Pbigstring_load_16 _
707707
| Pbigstring_load_32 _
708708
| Pbigstring_load_64 _

jscomp/core/lam_convert.ml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -364,12 +364,13 @@ let lam_prim ~primitive:( p : Lambda.primitive) ~args loc : Lam.t =
364364
| Plsrbint x -> prim ~primitive:(Plsrbint x) ~args loc
365365
| Pasrbint x -> prim ~primitive:(Pasrbint x) ~args loc
366366
| Pbigarraydim x -> prim ~primitive:(Pbigarraydim x) ~args loc
367-
| Pstring_load_16 x -> prim ~primitive:(Pstring_load_16 x) ~args loc
368-
| Pstring_load_32 x -> prim ~primitive:(Pstring_load_32 x) ~args loc
369-
| Pstring_load_64 x -> prim ~primitive:(Pstring_load_64 x) ~args loc
370-
| Pstring_set_16 x -> prim ~primitive:(Pstring_set_16 x) ~args loc
371-
| Pstring_set_32 x -> prim ~primitive:(Pstring_set_32 x) ~args loc
372-
| Pstring_set_64 x -> prim ~primitive:(Pstring_set_64 x) ~args loc
367+
| Pstring_load_16 _
368+
| Pstring_load_32 _
369+
| Pstring_load_64 _
370+
| Pstring_set_16 _
371+
| Pstring_set_32 _
372+
| Pstring_set_64 _ ->
373+
Location.raise_errorf ~loc "unsupported primitive"
373374
| Pbigstring_load_16 x -> prim ~primitive:(Pbigstring_load_16 x) ~args loc
374375
| Pbigstring_load_32 x -> prim ~primitive:(Pbigstring_load_32 x) ~args loc
375376
| Pbigstring_load_64 x -> prim ~primitive:(Pbigstring_load_64 x) ~args loc

jscomp/core/lam_dispatch_primitive.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ let translate loc (prim_name : string)
552552
call Js_runtime_modules.char
553553
| "caml_string_get"
554554
->
555-
call Js_runtime_modules.string
555+
E.runtime_call Js_runtime_modules.string "get" args
556556
| "bytes_to_string"
557557
| "bytes_of_string"
558558
| "caml_blit_string"

jscomp/core/lam_primitive.ml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,12 @@ type t =
116116
(* size of the nth dimension of a big array *)
117117
| Pbigarraydim of int
118118
(* load/set 16,32,64 bits from a string: (unsafe)*)
119-
| Pstring_load_16 of bool
119+
(* | Pstring_load_16 of bool
120120
| Pstring_load_32 of bool
121-
| Pstring_load_64 of bool
122-
| Pstring_set_16 of bool
121+
| Pstring_load_64 of bool *)
122+
(* | Pstring_set_16 of bool
123123
| Pstring_set_32 of bool
124-
| Pstring_set_64 of bool
124+
| Pstring_set_64 of bool *)
125125
(* load/set 16,32,64 bits from a
126126
(char, int8_unsigned_elt, c_layout) Bigarray.Array1.t : (unsafe) *)
127127
| Pbigstring_load_16 of bool
@@ -315,12 +315,12 @@ let eq_primitive_approx ( lhs : t) (rhs : t) =
315315
| Pcvtbint (boxed_integer, boxed_integer1) -> (match rhs with Pcvtbint (boxed_integer10, boxed_integer11) -> Lam_compat.eq_boxed_integer boxed_integer boxed_integer10 && Lam_compat.eq_boxed_integer boxed_integer1 boxed_integer11 | _ -> false )
316316
| Pbintcomp (boxed_integer , comparison) -> (match rhs with Pbintcomp(boxed_integer1, comparison1) -> Lam_compat.eq_boxed_integer boxed_integer boxed_integer1 && Lam_compat.eq_comparison comparison comparison1 | _ -> false)
317317
| Pbigarraydim dim -> (match rhs with Pbigarraydim dim1 -> dim = dim1 | _ -> false )
318-
| Pstring_load_16 str -> (match rhs with Pstring_load_16 str1 -> str = str1 | _ -> false )
318+
(* | Pstring_load_16 str -> (match rhs with Pstring_load_16 str1 -> str = str1 | _ -> false )
319319
| Pstring_load_32 b -> (match rhs with Pstring_load_32 b1 -> b = b1 | _ -> false )
320-
| Pstring_load_64 b -> (match rhs with Pstring_load_64 b1 -> b = b1 | _ -> false )
321-
| Pstring_set_16 b -> (match rhs with Pstring_set_16 b1 -> b = b1 | _ -> false )
320+
| Pstring_load_64 b -> (match rhs with Pstring_load_64 b1 -> b = b1 | _ -> false ) *)
321+
(* | Pstring_set_16 b -> (match rhs with Pstring_set_16 b1 -> b = b1 | _ -> false )
322322
| Pstring_set_32 b -> (match rhs with Pstring_set_32 b1 -> b = b1 | _ -> false )
323-
| Pstring_set_64 b -> (match rhs with Pstring_set_64 b1 -> b = b1 | _ -> false )
323+
| Pstring_set_64 b -> (match rhs with Pstring_set_64 b1 -> b = b1 | _ -> false ) *)
324324
| Pbigstring_load_16 b -> (match rhs with Pbigstring_load_16 b1 -> b = b1 | _ -> false )
325325
| Pbigstring_load_32 b -> (match rhs with Pbigstring_load_32 b1 -> b = b1 | _ -> false )
326326
| Pbigstring_load_64 b -> (match rhs with Pbigstring_load_64 b1 -> b = b1 | _ -> false )

jscomp/core/lam_primitive.mli

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,12 @@ type t =
111111
(* size of the nth dimension of a big array *)
112112
| Pbigarraydim of int
113113
(* load/set 16,32,64 bits from a string: (unsafe)*)
114-
| Pstring_load_16 of bool
114+
(* | Pstring_load_16 of bool
115115
| Pstring_load_32 of bool
116-
| Pstring_load_64 of bool
117-
| Pstring_set_16 of bool
116+
| Pstring_load_64 of bool *)
117+
(* | Pstring_set_16 of bool
118118
| Pstring_set_32 of bool
119-
| Pstring_set_64 of bool
119+
| Pstring_set_64 of bool *)
120120
(* load/set 16,32,64 bits from a
121121
(char, int8_unsigned_elt, c_layout) Bigarray.Array1.t : (unsafe) *)
122122
| Pbigstring_load_16 of bool

jscomp/core/lam_print.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ let primitive ppf (prim : Lam_primitive.t) = match prim with
268268
| Pbigarrayset(unsafe, n, kind, layout) ->
269269
print_bigarray "set" unsafe kind ppf layout
270270
| Pbigarraydim(n) -> fprintf ppf "Bigarray.dim_%i" n
271-
| Pstring_load_16(unsafe) ->
271+
(* | Pstring_load_16(unsafe) ->
272272
if unsafe then fprintf ppf "string.unsafe_get16"
273273
else fprintf ppf "string.get16"
274274
| Pstring_load_32(unsafe) ->
@@ -277,15 +277,15 @@ let primitive ppf (prim : Lam_primitive.t) = match prim with
277277
| Pstring_load_64(unsafe) ->
278278
if unsafe then fprintf ppf "string.unsafe_get64"
279279
else fprintf ppf "string.get64"
280-
| Pstring_set_16(unsafe) ->
280+
(* | Pstring_set_16(unsafe) -> *)
281281
if unsafe then fprintf ppf "string.unsafe_set16"
282282
else fprintf ppf "string.set16"
283283
| Pstring_set_32(unsafe) ->
284284
if unsafe then fprintf ppf "string.unsafe_set32"
285285
else fprintf ppf "string.set32"
286286
| Pstring_set_64(unsafe) ->
287287
if unsafe then fprintf ppf "string.unsafe_set64"
288-
else fprintf ppf "string.set64"
288+
else fprintf ppf "string.set64" *)
289289
| Pbigstring_load_16(unsafe) ->
290290
if unsafe then fprintf ppf "bigarray.array1.unsafe_get16"
291291
else fprintf ppf "bigarray.array1.get16"

0 commit comments

Comments
 (0)