Skip to content

Commit 241565b

Browse files
committed
Refactor: remove Const_unicode.
1 parent 8c44a40 commit 241565b

13 files changed

+56
-94
lines changed

jscomp/core/lam.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ let rec eval_const_as_bool (v : Lam_constant.t) : bool =
638638
| Const_js_false | Const_js_null | Const_module_alias | Const_js_undefined ->
639639
false
640640
| Const_js_true | Const_string _ | Const_pointer _ | Const_float _
641-
| Const_unicode _ | Const_block _ | Const_float_array _ ->
641+
| Const_block _ | Const_float_array _ ->
642642
true
643643
| Const_some b -> eval_const_as_bool b
644644

jscomp/core/lam_analysis.ml

-1
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,6 @@ and size_constant x =
197197
| Const_js_null | Const_js_undefined | Const_module_alias | Const_js_true
198198
| Const_js_false ->
199199
1
200-
| Const_unicode _ (* TODO: this seems to be not good heurisitives*)
201200
| Const_string _ ->
202201
1
203202
| Const_some s -> size_constant s

jscomp/core/lam_compile_const.ml

-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ and translate (x : Lam_constant.t) : J.expression =
7272
| Const_float f -> E.float f (* TODO: preserve float *)
7373
| Const_string { s; unicode = false } -> E.str s
7474
| Const_string { s; unicode = true } -> E.str ~delim:(Some "j") s
75-
| Const_unicode i -> E.str ~delim:(Some "j") i
7675
| Const_pointer name -> E.str name
7776
| Const_block (tag, tag_info, xs) ->
7877
Js_of_lam_block.make_block NA tag_info (E.small_int tag)

jscomp/core/lam_constant.ml

-3
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ type t =
4444
| Const_int of { i : int32; comment : pointer_info }
4545
| Const_char of char
4646
| Const_string of { s : string; unicode : bool }
47-
| Const_unicode of string
4847
| Const_float of string
4948
| Const_int64 of int64
5049
| Const_pointer of string
@@ -69,8 +68,6 @@ let rec eq_approx (x : t) (y : t) =
6968
match y with
7069
| Const_string { s = sy; unicode = uy } -> sx = sy && ux = uy
7170
| _ -> false)
72-
| Const_unicode ix -> (
73-
match y with Const_unicode iy -> ix = iy | _ -> false)
7471
| Const_float ix -> ( match y with Const_float iy -> ix = iy | _ -> false)
7572
| Const_int64 ix -> ( match y with Const_int64 iy -> ix = iy | _ -> false)
7673
| Const_pointer ix -> (

jscomp/core/lam_constant.mli

-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ type t =
4040
| Const_int of { i : int32; comment : pointer_info }
4141
| Const_char of char
4242
| Const_string of { s : string; unicode : bool }
43-
| Const_unicode of string
4443
| Const_float of string
4544
| Const_int64 of int64
4645
| Const_pointer of string

jscomp/core/lam_eta_conversion.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ let transform_under_supply n ap_info fn args =
4242
match lam with
4343
| Lvar _
4444
| Lconst
45-
( Const_int _ | Const_char _ | Const_string _ | Const_unicode _ | Const_float _
45+
( Const_int _ | Const_char _ | Const_string _ | Const_float _
4646
| Const_int64 _ | Const_pointer _ | Const_js_true | Const_js_false
4747
| Const_js_undefined )
4848
| Lprim { primitive = Pfield (_, Fld_module _); _ }

jscomp/core/lam_print.ml

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ let rec struct_const ppf (cst : Lam_constant.t) =
2323
| Const_int { i } -> fprintf ppf "%ld" i
2424
| Const_char c -> fprintf ppf "%C" c
2525
| Const_string { s } -> fprintf ppf "%S" s
26-
| Const_unicode s -> fprintf ppf "%S" s
2726
| Const_float f -> fprintf ppf "%s" f
2827
| Const_int64 n -> fprintf ppf "%LiL" n
2928
| Const_pointer name -> fprintf ppf "`%s" name

jscomp/frontend/external_ffi_types.ml

+4-6
Original file line numberDiff line numberDiff line change
@@ -309,12 +309,10 @@ let () =
309309
)
310310
let inline_string_primitive (s : string) (op : string option) : string list =
311311
let lam : Lam_constant.t =
312-
match op with
313-
| Some op
314-
when Ast_utf8_string_interp.is_unicode_string op ->
315-
Const_unicode s
316-
| _ ->
317-
(Const_string { s; unicode = false }) in
312+
let unicode = match op with
313+
| Some op -> Ast_utf8_string_interp.is_unicode_string op
314+
| None -> false in
315+
(Const_string { s; unicode }) in
318316
[""; to_string (Ffi_inline_const lam )]
319317

320318
(* Let's only do it for string ATM

jscomp/frontend/external_ffi_types.pp.ml

+4-6
Original file line numberDiff line numberDiff line change
@@ -311,12 +311,10 @@ let () =
311311
)
312312
let inline_string_primitive (s : string) (op : string option) : string list =
313313
let lam : Lam_constant.t =
314-
match op with
315-
| Some op
316-
when Ast_utf8_string_interp.is_unicode_string op ->
317-
Const_unicode s
318-
| _ ->
319-
(Const_string { s; unicode = false }) in
314+
let unicode = match op with
315+
| Some op -> Ast_utf8_string_interp.is_unicode_string op
316+
| None -> false in
317+
(Const_string { s; unicode }) in
320318
[""; to_string (Ffi_inline_const lam )]
321319

322320
(* Let's only do it for string ATM

jscomp/main/builtin_cmj_datasets.ml

+7-7
Large diffs are not rendered by default.

lib/4.06.1/unstable/js_compiler.ml

+13-22
Large diffs are not rendered by default.

lib/4.06.1/unstable/js_playground_compiler.ml

+13-22
Large diffs are not rendered by default.

lib/4.06.1/whole_compiler.ml

+13-22
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)