@@ -156,8 +156,8 @@ let pure_runtime_call module_name fn_name args =
156
156
157
157
let runtime_ref module_name fn_name = runtime_var_dot module_name fn_name
158
158
159
- let str ?(delim = J. DNone ) ?comment txt : t =
160
- {expression_desc = Str {txt; delim }; comment}
159
+ let str ?(kind = J. Standard ) ?comment txt : t =
160
+ {expression_desc = Str {txt; kind }; comment}
161
161
162
162
let raw_js_code ?comment info s : t =
163
163
{
@@ -209,7 +209,7 @@ let instanceof ?comment (e0 : t) (e1 : t) : t =
209
209
{expression_desc = Bin (InstanceOf , e0, e1); comment}
210
210
211
211
let is_array (e0 : t ) : t =
212
- let f = str " Array.isArray" ~delim: DNoQuotes in
212
+ let f = str " Array.isArray" ~kind: RawJs in
213
213
{expression_desc = Call (f, [e0], Js_call_info. ml_full_call); comment = None }
214
214
215
215
let new_ ?comment e0 args : t = {expression_desc = New (e0, Some args); comment}
@@ -548,7 +548,8 @@ let array_length ?comment (e : t) : t =
548
548
549
549
let string_length ?comment (e : t ) : t =
550
550
match e.expression_desc with
551
- | Str {txt; delim = DNone } -> int ?comment (Int32. of_int (String. length txt))
551
+ | Str {txt; kind = Standard } ->
552
+ int ?comment (Int32. of_int (String. length txt))
552
553
(* No optimization for {j||j}*)
553
554
| _ -> {expression_desc = Length (e, String ); comment}
554
555
@@ -566,31 +567,31 @@ let function_length ?comment (e : t) : t =
566
567
*)
567
568
568
569
let rec string_append ?comment (e : t ) (el : t ) : t =
569
- let concat a b ~delim = {e with expression_desc = Str {txt = a ^ b; delim }} in
570
+ let concat a b ~kind = {e with expression_desc = Str {txt = a ^ b; kind }} in
570
571
match (e.expression_desc, el.expression_desc) with
571
572
| Str {txt = "" } , _ -> el
572
573
| _ , Str {txt = "" } -> e
573
- | ( Str {txt = a; delim },
574
- String_append ({expression_desc = Str {txt = b; delim = delim_ }}, c) )
575
- when delim = delim_ ->
576
- string_append ?comment (concat a b ~delim ) c
577
- | ( String_append (c, {expression_desc = Str {txt = b; delim }}),
578
- Str {txt = a; delim = delim_ } )
579
- when delim = delim_ ->
580
- string_append ?comment c (concat b a ~delim )
581
- | ( String_append (a, {expression_desc = Str {txt = b; delim }}),
582
- String_append ({expression_desc = Str {txt = c; delim = delim_ }}, d) )
583
- when delim = delim_ ->
584
- string_append ?comment (string_append a (concat b c ~delim )) d
585
- | Str {txt = a ; delim } , Str {txt = b ; delim = delim_ } when delim = delim_ ->
586
- {(concat a b ~delim ) with comment}
574
+ | ( Str {txt = a; kind },
575
+ String_append ({expression_desc = Str {txt = b; kind = kind_ }}, c) )
576
+ when kind = kind_ ->
577
+ string_append ?comment (concat a b ~kind ) c
578
+ | ( String_append (c, {expression_desc = Str {txt = b; kind }}),
579
+ Str {txt = a; kind = kind_ } )
580
+ when kind = kind_ ->
581
+ string_append ?comment c (concat b a ~kind )
582
+ | ( String_append (a, {expression_desc = Str {txt = b; kind }}),
583
+ String_append ({expression_desc = Str {txt = c; kind = kind_ }}, d) )
584
+ when kind = kind_ ->
585
+ string_append ?comment (string_append a (concat b c ~kind )) d
586
+ | Str {txt = a ; kind } , Str {txt = b ; kind = kind_ } when kind = kind_ ->
587
+ {(concat a b ~kind ) with comment}
587
588
| _ , _ -> {comment; expression_desc = String_append (e, el)}
588
589
589
590
let obj ?comment ?dup properties : t =
590
591
{expression_desc = Object (dup, properties); comment}
591
592
592
- let str_equal (txt0 : string ) (delim0 : External_arg_spec.delim ) txt1 delim1 =
593
- if delim0 = delim1 then
593
+ let str_equal (txt0 : string ) (kind0 : String_kind.t ) txt1 kind1 =
594
+ if kind0 = kind1 then
594
595
if Ext_string. equal txt0 txt1 then Some true
595
596
else if
596
597
Ast_utf8_string. simple_comparison txt0
@@ -1242,7 +1243,7 @@ let rec float_equal ?comment (e0 : t) (e1 : t) : t =
1242
1243
let int_equal = float_equal
1243
1244
1244
1245
let tag_type = function
1245
- | Ast_untagged_variants. String s -> str s ~delim: DStarJ
1246
+ | Ast_untagged_variants. String s -> str s ~kind: Verbatim
1246
1247
| Int i -> small_int i
1247
1248
| Float f -> float f
1248
1249
| BigInt i ->
@@ -1258,7 +1259,7 @@ let tag_type = function
1258
1259
| Untagged FunctionType -> str " function"
1259
1260
| Untagged StringType -> str " string"
1260
1261
| Untagged (InstanceType i ) ->
1261
- str (Ast_untagged_variants.Instance. to_string i) ~delim: DNoQuotes
1262
+ str (Ast_untagged_variants.Instance. to_string i) ~kind: RawJs
1262
1263
| Untagged ObjectType -> str " object"
1263
1264
| Untagged UnknownType ->
1264
1265
(* TODO: this should not happen *)
@@ -1280,7 +1281,7 @@ let rec emit_check (check : t Ast_untagged_variants.DynamicChecks.t) =
1280
1281
| IsInstanceOf (Array, x ) -> is_array (emit_check x)
1281
1282
| IsInstanceOf (instance , x ) ->
1282
1283
let instance_name = Ast_untagged_variants.Instance. to_string instance in
1283
- instanceof (emit_check x) (str instance_name ~delim: DNoQuotes )
1284
+ instanceof (emit_check x) (str instance_name ~kind: RawJs )
1284
1285
| Not x -> not (emit_check x)
1285
1286
| Expr x -> x
1286
1287
@@ -1343,8 +1344,8 @@ let to_int32 ?comment (e : J.expression) : J.expression =
1343
1344
1344
1345
let string_comp (cmp : Lam_compat.comparison ) ?comment (e0 : t ) (e1 : t ) =
1345
1346
match (e0.expression_desc, e1.expression_desc) with
1346
- | Str {txt = a0 ; delim = d0 } , Str {txt = a1 ; delim = d1 } -> (
1347
- match (cmp, str_equal a0 d0 a1 d1 ) with
1347
+ | Str {txt = a0 ; kind = k0 } , Str {txt = a1 ; kind = k1 } -> (
1348
+ match (cmp, str_equal a0 k0 a1 k1 ) with
1348
1349
| Ceq , Some b -> bool b
1349
1350
| Cneq , Some b -> bool (b = false )
1350
1351
| _ -> bin ?comment (Lam_compile_util. jsop_of_comp cmp) e0 e1)
0 commit comments