Skip to content

Commit 60297a6

Browse files
committed
2 parents 3ed1757 + f93b32e commit 60297a6

16 files changed

+48
-133
lines changed

jscomp/core/j.ml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,6 @@ and expression_desc =
151151
(* A string is UTF-8 encoded, and may contain
152152
escape sequences.
153153
*)
154-
| Unicode of string
155-
(* It is escaped string, print delimited by '"'*)
156154
| Raw_js_code of Js_raw_info.t
157155
(* literally raw JS code
158156
*)

jscomp/core/js_analyzer.ml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ let free_variables_of_expression st =
8282

8383
let rec no_side_effect_expression_desc (x : J.expression_desc) =
8484
match x with
85-
| Undefined | Null | Bool _ | Var _ | Unicode _ -> true
85+
| Undefined | Null | Bool _ | Var _ -> true
8686
| Fun _ -> true
8787
| Number _ -> true (* Can be refined later *)
8888
| Static_index (obj, (_name : string), (_pos : int32 option)) ->
@@ -183,8 +183,6 @@ let rec eq_expression ({ expression_desc = x0 } : J.expression)
183183
| _ -> false)
184184
| Str {delim=a0; txt=b0} -> (
185185
match y0 with Str {delim=a1; txt=b1} -> a0 = a1 && b0 = b1 | _ -> false)
186-
| Unicode s0 -> (
187-
match y0 with Unicode s1 -> s0 = s1 | _ -> false)
188186
| Static_index (e0, p0, off0) -> (
189187
match y0 with
190188
| Static_index (e1, p1, off1) ->
@@ -270,6 +268,6 @@ let rev_toplevel_flatten block =
270268

271269
let rec is_okay_to_duplicate (e : J.expression) =
272270
match e.expression_desc with
273-
| Var _ | Bool _ | Str _ | Unicode _ | Number _ -> true
271+
| Var _ | Bool _ | Str _ | Number _ -> true
274272
| Static_index (e, _s, _off) -> is_okay_to_duplicate e
275273
| _ -> false

jscomp/core/js_dump.ml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ let exp_need_paren (e : J.expression) =
162162
| Raw_js_code { code_info = Stmt _ }
163163
| Length _ | Call _ | Caml_block_tag _ | Seq _ | Static_index _ | Cond _
164164
| Bin _ | Is_null_or_undefined _ | String_index _ | Array_index _
165-
| String_append _ | Var _ | Undefined | Null | Str _ | Unicode _ | Array _
165+
| String_append _ | Var _ | Undefined | Null | Str _ | Array _
166166
| Optional_block _ | Caml_block _ | FlatCall _ | Typeof _ | Number _
167167
| Js_not _ | Bool _ | New _ ->
168168
false
@@ -586,11 +586,6 @@ and expression_desc cxt ~(level : int) f x : cxt =
586586
P.string f L.codePointAt;
587587
(* FIXME: use code_point_at *)
588588
P.paren_group f 1 (fun _ -> expression ~level:0 cxt f b))
589-
| Unicode s ->
590-
P.string f "\"";
591-
P.string f s;
592-
P.string f "\"";
593-
cxt
594589
| Str {delim; txt} ->
595590
(*TODO --
596591
when utf8-> it will not escape '\\' which is definitely not we want

jscomp/core/js_exp_make.ml

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ type t = J.expression
3535
*)
3636
let rec remove_pure_sub_exp (x : t) : t option =
3737
match x.expression_desc with
38-
| Var _ | Str _ | Unicode _ | Number _ -> None (* Can be refined later *)
38+
| Var _ | Str _ | Number _ -> None (* Can be refined later *)
3939
| Array_index (a, b) ->
4040
if is_pure_sub_exp a && is_pure_sub_exp b then None else Some x
4141
| Array (xs, _mutable_flag) ->
@@ -128,8 +128,6 @@ let runtime_ref module_name fn_name = runtime_var_dot module_name fn_name
128128
let str ?(delim = None) ?comment txt : t =
129129
{ expression_desc = Str {txt; delim}; comment }
130130

131-
let unicode ?comment s : t = { expression_desc = Unicode s; comment }
132-
133131
let raw_js_code ?comment info s : t =
134132
{
135133
expression_desc = Raw_js_code { code = String.trim s; code_info = info };
@@ -173,7 +171,7 @@ module L = Literals
173171
let typeof ?comment (e : t) : t =
174172
match e.expression_desc with
175173
| Number _ | Length _ -> str ?comment L.js_type_number
176-
| Str _ | Unicode _ -> str ?comment L.js_type_string
174+
| Str _ -> str ?comment L.js_type_string
177175
| Array _ -> str ?comment L.js_type_object
178176
| Bool _ -> str ?comment L.js_type_boolean
179177
| _ -> { expression_desc = Typeof e; comment }
@@ -477,7 +475,7 @@ let array_length ?comment (e : t) : t =
477475

478476
let string_length ?comment (e : t) : t =
479477
match e.expression_desc with
480-
| Str {txt} -> int ?comment (Int32.of_int (String.length txt))
478+
| Str {txt; delim=None} -> int ?comment (Int32.of_int (String.length txt))
481479
(* No optimization for {j||j}*)
482480
| _ -> { expression_desc = Length (e, String); comment }
483481

@@ -551,8 +549,6 @@ let rec triple_equal ?comment (e0 : t) (e1 : t) : t =
551549
| Str {txt=x}, Str {txt=y} ->
552550
(* CF*)
553551
bool (Ext_string.equal x y)
554-
| Unicode x, Unicode y ->
555-
bool (Ext_string.equal x y)
556552
| Number (Int { i = i0; _ }), Number (Int { i = i1; _ }) -> bool (i0 = i1)
557553
| Optional_block (a, _), Optional_block (b, _) -> triple_equal ?comment a b
558554
| Undefined, Optional_block _
@@ -609,7 +605,7 @@ let and_ ?comment (e1 : t) (e2 : t) : t =
609605
Bin
610606
( EqEqEq,
611607
{ expression_desc = Var j },
612-
{ expression_desc = Str _ | Number _ | Unicode _ } ) )
608+
{ expression_desc = Str _ | Number _ } ) )
613609
when Js_op_util.same_vident i j ->
614610
e2
615611
| _, _ -> { expression_desc = Bin (And, e1, e2); comment }
@@ -729,7 +725,6 @@ let int_equal = float_equal
729725
let string_equal ?comment (e0 : t) (e1 : t) : t =
730726
match (e0.expression_desc, e1.expression_desc) with
731727
| Str {txt=a0}, Str {txt=b0} -> bool (Ext_string.equal a0 b0)
732-
| Unicode a0, Unicode b0 -> bool (Ext_string.equal a0 b0)
733728
| _, _ -> { expression_desc = Bin (EqEqEq, e0, e1); comment }
734729

735730
let is_type_number ?comment (e : t) : t =
@@ -812,8 +807,7 @@ let uint32 ?comment n : J.expression =
812807

813808
let string_comp (cmp : J.binop) ?comment (e0 : t) (e1 : t) =
814809
match (e0.expression_desc, e1.expression_desc) with
815-
| Str {txt=a0}, Str {txt=b0}
816-
| Unicode a0, Unicode b0 -> (
810+
| Str {txt=a0}, Str {txt=b0} -> (
817811
match cmp with
818812
| EqEqEq -> bool (a0 = b0)
819813
| NotEqEq -> bool (a0 <> b0)

jscomp/core/js_exp_make.mli

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,6 @@ val runtime_ref : string -> string -> t
8484

8585
val str : ?delim: string option -> ?comment: string -> string -> t
8686

87-
val unicode : ?comment:string -> string -> t
88-
8987
val ocaml_fun :
9088
?comment:string ->
9189
?immutable_mask:bool array ->

jscomp/core/js_fold.ml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ class fold =
151151
let _self = _self#block _x2 in
152152
_self
153153
| Str _ -> _self
154-
| Unicode _ -> _self
155154
| Raw_js_code _ -> _self
156155
| Array (_x0, _x1) ->
157156
let _self = list (fun _self -> _self#expression) _self _x0 in

jscomp/core/js_pass_flatten_and_mark_dead.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ let subst_map (substitution : J.expression Hash_ident.t) =
192192
let _, e, bindings =
193193
Ext_list.fold_left ls (0, [], []) (fun (i, e, acc) x ->
194194
match x.expression_desc with
195-
| Var _ | Number _ | Str _ | Unicode _ | J.Bool _ | Undefined ->
195+
| Var _ | Number _ | Str _ | J.Bool _ | Undefined ->
196196
(* TODO: check the optimization *)
197197
(i + 1, x :: e, acc)
198198
| _ ->

jscomp/core/js_pass_scope.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ let record_scope_pass =
220220
TODO:
221221
*)
222222
match x.expression_desc with
223-
| Fun _ | Number _ | Str _ | Unicode _ -> state
223+
| Fun _ | Number _ | Str _ -> state
224224
| _ ->
225225
(* if Set_ident.(is_empty @@ *)
226226
(* inter self#get_mutable_values *)

jscomp/core/js_record_fold.ml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ let expression_desc : 'a. ('a, expression_desc) fn =
157157
let st = _self.block _self st _x2 in
158158
st
159159
| Str _ -> st
160-
| Unicode _ -> st
161160
| Raw_js_code _ -> st
162161
| Array (_x0, _x1) ->
163162
let st = list _self.expression _self st _x0 in

jscomp/core/js_record_iter.ml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ let expression_desc : expression_desc fn =
122122
list _self.ident _self _x1;
123123
_self.block _self _x2
124124
| Str _ -> ()
125-
| Unicode _ -> ()
126125
| Raw_js_code _ -> ()
127126
| Array (_x0, _x1) -> list _self.expression _self _x0
128127
| Optional_block (_x0, _x1) -> _self.expression _self _x0

jscomp/core/js_record_map.ml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@ let expression_desc : expression_desc fn =
155155
let _x2 = _self.block _self _x2 in
156156
Fun (_x0, _x1, _x2, _x3, _x4)
157157
| Str _ as v -> v
158-
| Unicode _ as v -> v
159158
| Raw_js_code _ as v -> v
160159
| Array (_x0, _x1) ->
161160
let _x0 = list _self.expression _self _x0 in

jscomp/core/js_stmt_make.ml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,7 @@ let string_switch ?(comment : string option)
131131
?(declaration : (J.property * Ident.t) option) ?(default : J.block option)
132132
(e : J.expression) (clauses : (string * J.case_clause) list) : t =
133133
match e.expression_desc with
134-
| Str {txt}
135-
| Unicode txt -> (
134+
| Str {txt} -> (
136135
let continuation =
137136
match
138137
Ext_list.find_opt clauses (fun (switch_case, x) ->

jscomp/core/lam_compile_const.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ and translate (x : Lam_constant.t) : J.expression =
7171
(* https://github.com/google/closure-library/blob/master/closure%2Fgoog%2Fmath%2Flong.js *)
7272
| Const_float f -> E.float f (* TODO: preserve float *)
7373
| Const_string i (*TODO: here inline js*) -> E.str i
74-
| Const_unicode i -> E.unicode i
74+
| Const_unicode i -> E.str ~delim:(Some "j") i
7575
| Const_pointer name -> E.str name
7676
| Const_block (tag, tag_info, xs) ->
7777
Js_of_lam_block.make_block NA tag_info (E.small_int tag)

0 commit comments

Comments
 (0)