@@ -156,8 +156,8 @@ let pure_runtime_call module_name fn_name args =
156156
157157let runtime_ref module_name fn_name = runtime_var_dot module_name fn_name
158158
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}
161161
162162let raw_js_code ?comment info s : t =
163163 {
@@ -209,7 +209,7 @@ let instanceof ?comment (e0 : t) (e1 : t) : t =
209209 {expression_desc = Bin (InstanceOf , e0, e1); comment}
210210
211211let is_array (e0 : t ) : t =
212- let f = str " Array.isArray" ~delim: DNoQuotes in
212+ let f = str " Array.isArray" ~kind: RawJs in
213213 {expression_desc = Call (f, [e0], Js_call_info. ml_full_call); comment = None }
214214
215215let new_ ?comment e0 args : t = {expression_desc = New (e0, Some args); comment}
@@ -548,7 +548,8 @@ let array_length ?comment (e : t) : t =
548548
549549let string_length ?comment (e : t ) : t =
550550 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))
552553 (* No optimization for {j||j}*)
553554 | _ -> {expression_desc = Length (e, String ); comment}
554555
@@ -566,31 +567,31 @@ let function_length ?comment (e : t) : t =
566567*)
567568
568569let 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
570571 match (e.expression_desc, el.expression_desc) with
571572 | Str {txt = "" } , _ -> el
572573 | _ , 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}
587588 | _ , _ -> {comment; expression_desc = String_append (e, el)}
588589
589590let obj ?comment ?dup properties : t =
590591 {expression_desc = Object (dup, properties); comment}
591592
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
594595 if Ext_string. equal txt0 txt1 then Some true
595596 else if
596597 Ast_utf8_string. simple_comparison txt0
@@ -1242,7 +1243,7 @@ let rec float_equal ?comment (e0 : t) (e1 : t) : t =
12421243let int_equal = float_equal
12431244
12441245let tag_type = function
1245- | Ast_untagged_variants. String s -> str s ~delim: DStarJ
1246+ | Ast_untagged_variants. String s -> str s ~kind: Verbatim
12461247 | Int i -> small_int i
12471248 | Float f -> float f
12481249 | BigInt i ->
@@ -1258,7 +1259,7 @@ let tag_type = function
12581259 | Untagged FunctionType -> str " function"
12591260 | Untagged StringType -> str " string"
12601261 | 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
12621263 | Untagged ObjectType -> str " object"
12631264 | Untagged UnknownType ->
12641265 (* TODO: this should not happen *)
@@ -1280,7 +1281,7 @@ let rec emit_check (check : t Ast_untagged_variants.DynamicChecks.t) =
12801281 | IsInstanceOf (Array, x ) -> is_array (emit_check x)
12811282 | IsInstanceOf (instance , x ) ->
12821283 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 )
12841285 | Not x -> not (emit_check x)
12851286 | Expr x -> x
12861287
@@ -1343,8 +1344,8 @@ let to_int32 ?comment (e : J.expression) : J.expression =
13431344
13441345let string_comp (cmp : Lam_compat.comparison ) ?comment (e0 : t ) (e1 : t ) =
13451346 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
13481349 | Ceq , Some b -> bool b
13491350 | Cneq , Some b -> bool (b = false )
13501351 | _ -> bin ?comment (Lam_compile_util. jsop_of_comp cmp) e0 e1)
0 commit comments