@@ -27497,7 +27497,7 @@ let build_other_constant proj make first next p env =
27497
27497
27498
27498
let some_other_tag = "<some other tag>"
27499
27499
27500
- let build_other ext env = match env with
27500
+ let build_other ext env : Typedtree.pattern = match env with
27501
27501
| ({pat_desc = Tpat_construct (lid, {cstr_tag=Cstr_extension _},_)},_) :: _ ->
27502
27502
(* let c = {c with cstr_name = "*extension*"} in *) (* PR#7330 *)
27503
27503
make_pat (Tpat_var (Ident.create "*extension*",
@@ -27539,13 +27539,19 @@ let build_other ext env = match env with
27539
27539
make_pat (Tpat_or (pat, p_res, None)) p.pat_type p.pat_env)
27540
27540
pat other_pats
27541
27541
end
27542
- | ({pat_desc=(Tpat_constant (Const_int _ | Const_char _ ))} as p,_) :: _ ->
27542
+ | ({pat_desc=(Tpat_constant (Const_int _ ))} as p,_) :: _ ->
27543
27543
build_other_constant
27544
27544
(function Tpat_constant(Const_int i) -> i
27545
- | Tpat_constant (Const_char i) -> Char.code i
27546
27545
| _ -> assert false)
27547
27546
(function i -> Tpat_constant(Const_int i))
27548
27547
0 succ p env
27548
+ | ({pat_desc=(Tpat_constant (Const_char _ ))} as p,_) :: _ ->
27549
+ build_other_constant
27550
+ (function
27551
+ | Tpat_constant (Const_char i) -> Char.code i
27552
+ | _ -> assert false)
27553
+ (function i -> Tpat_constant(Const_char (Obj.magic (i:int) : char)))
27554
+ 0 succ p env
27549
27555
| ({pat_desc=(Tpat_constant (Const_int32 _))} as p,_) :: _ ->
27550
27556
build_other_constant
27551
27557
(function Tpat_constant(Const_int32 i) -> i | _ -> assert false)
@@ -51121,165 +51127,6 @@ let isKeywordTxt str =
51121
51127
51122
51128
let catch = Lident "catch"
51123
51129
51124
- end
51125
- module Res_utf8 : sig
51126
- #1 "res_utf8.mli"
51127
- val repl : int
51128
-
51129
- val max : int
51130
-
51131
- val decodeCodePoint : int -> string -> int -> int * int
51132
-
51133
- val encodeCodePoint : int -> string
51134
-
51135
- val isValidCodePoint : int -> bool
51136
-
51137
- end = struct
51138
- #1 "res_utf8.ml"
51139
- (* https://tools.ietf.org/html/rfc3629#section-10 *)
51140
- (* let bom = 0xFEFF *)
51141
-
51142
- let repl = 0xFFFD
51143
-
51144
- (* let min = 0x0000 *)
51145
- let max = 0x10FFFF
51146
-
51147
- let surrogateMin = 0xD800
51148
- let surrogateMax = 0xDFFF
51149
-
51150
- (*
51151
- * Char. number range | UTF-8 octet sequence
51152
- * (hexadecimal) | (binary)
51153
- * --------------------+---------------------------------------------
51154
- * 0000 0000-0000 007F | 0xxxxxxx
51155
- * 0000 0080-0000 07FF | 110xxxxx 10xxxxxx
51156
- * 0000 0800-0000 FFFF | 1110xxxx 10xxxxxx 10xxxxxx
51157
- * 0001 0000-0010 FFFF | 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
51158
- *)
51159
- let h2 = 0b1100_0000
51160
- let h3 = 0b1110_0000
51161
- let h4 = 0b1111_0000
51162
-
51163
- let cont_mask = 0b0011_1111
51164
-
51165
- type category = {low: int; high: int; size: int}
51166
-
51167
- let locb = 0b1000_0000
51168
- let hicb = 0b1011_1111
51169
-
51170
- let categoryTable = [|
51171
- (* 0 *) {low = -1; high= -1; size= 1}; (* invalid *)
51172
- (* 1 *) {low = 1; high= -1; size= 1}; (* ascii *)
51173
- (* 2 *) {low = locb; high= hicb; size= 2};
51174
- (* 3 *) {low = 0xA0; high= hicb; size= 3};
51175
- (* 4 *) {low = locb; high= hicb; size= 3};
51176
- (* 5 *) {low = locb; high= 0x9F; size= 3};
51177
- (* 6 *) {low = 0x90; high= hicb; size= 4};
51178
- (* 7 *) {low = locb; high= hicb; size= 4};
51179
- (* 8 *) {low = locb; high= 0x8F; size= 4};
51180
- |] [@@ocamlformat "disable"]
51181
-
51182
- let categories = [|
51183
- 1; 1; 1; 1; 1; 1 ;1 ;1 ;1 ;1 ;1 ;1 ;1 ;1 ;1 ;1;
51184
- 1; 1; 1; 1; 1; 1 ;1 ;1 ;1 ;1 ;1 ;1 ;1 ;1 ;1 ;1;
51185
- 1; 1; 1; 1; 1; 1 ;1 ;1 ;1 ;1 ;1 ;1 ;1 ;1 ;1 ;1;
51186
- 1; 1; 1; 1; 1; 1 ;1 ;1 ;1 ;1 ;1 ;1 ;1 ;1 ;1 ;1;
51187
- 1; 1; 1; 1; 1; 1 ;1 ;1 ;1 ;1 ;1 ;1 ;1 ;1 ;1 ;1;
51188
- 1; 1; 1; 1; 1; 1 ;1 ;1 ;1 ;1 ;1 ;1 ;1 ;1 ;1 ;1;
51189
- 1; 1; 1; 1; 1; 1 ;1 ;1 ;1 ;1 ;1 ;1 ;1 ;1 ;1 ;1;
51190
- 1; 1; 1; 1; 1; 1 ;1 ;1 ;1 ;1 ;1 ;1 ;1 ;1 ;1 ;1;
51191
-
51192
- 0; 0; 0; 0;0; 0; 0; 0;0; 0; 0; 0;0; 0; 0; 0;
51193
- 0; 0; 0; 0;0; 0; 0; 0;0; 0; 0; 0;0; 0; 0; 0;
51194
- 0; 0; 0; 0;0; 0; 0; 0;0; 0; 0; 0;0; 0; 0; 0;
51195
- 0; 0; 0; 0;0; 0; 0; 0;0; 0; 0; 0;0; 0; 0; 0;
51196
- (* surrogate range U+D800 - U+DFFFF = 55296 - 917503 *)
51197
- 0; 0; 2; 2;2; 2; 2; 2;2; 2; 2; 2;2; 2; 2; 2;
51198
- 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2;
51199
- 3; 4; 4; 4; 4; 4; 4; 4; 4; 4; 4; 4; 4; 5; 4; 4;
51200
- 6; 7; 7 ;7; 8; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0;
51201
- |] [@@ocamlformat "disable"]
51202
-
51203
- let decodeCodePoint i s len =
51204
- if len < 1 then (repl, 1)
51205
- else
51206
- let first = int_of_char (String.unsafe_get s i) in
51207
- if first < 128 then (first, 1)
51208
- else
51209
- let index = Array.unsafe_get categories first in
51210
- if index = 0 then (repl, 1)
51211
- else
51212
- let cat = Array.unsafe_get categoryTable index in
51213
- if len < i + cat.size then (repl, 1)
51214
- else if cat.size == 2 then
51215
- let c1 = int_of_char (String.unsafe_get s (i + 1)) in
51216
- if c1 < cat.low || cat.high < c1 then (repl, 1)
51217
- else
51218
- let i1 = c1 land 0b00111111 in
51219
- let i0 = (first land 0b00011111) lsl 6 in
51220
- let uc = i0 lor i1 in
51221
- (uc, 2)
51222
- else if cat.size == 3 then
51223
- let c1 = int_of_char (String.unsafe_get s (i + 1)) in
51224
- let c2 = int_of_char (String.unsafe_get s (i + 2)) in
51225
- if c1 < cat.low || cat.high < c1 || c2 < locb || hicb < c2 then
51226
- (repl, 1)
51227
- else
51228
- let i0 = (first land 0b00001111) lsl 12 in
51229
- let i1 = (c1 land 0b00111111) lsl 6 in
51230
- let i2 = c2 land 0b00111111 in
51231
- let uc = i0 lor i1 lor i2 in
51232
- (uc, 3)
51233
- else
51234
- let c1 = int_of_char (String.unsafe_get s (i + 1)) in
51235
- let c2 = int_of_char (String.unsafe_get s (i + 2)) in
51236
- let c3 = int_of_char (String.unsafe_get s (i + 3)) in
51237
- if
51238
- c1 < cat.low || cat.high < c1 || c2 < locb || hicb < c2 || c3 < locb
51239
- || hicb < c3
51240
- then (repl, 1)
51241
- else
51242
- let i1 = (c1 land 0x3f) lsl 12 in
51243
- let i2 = (c2 land 0x3f) lsl 6 in
51244
- let i3 = c3 land 0x3f in
51245
- let i0 = (first land 0x07) lsl 18 in
51246
- let uc = i0 lor i3 lor i2 lor i1 in
51247
- (uc, 4)
51248
-
51249
- let encodeCodePoint c =
51250
- if c <= 127 then (
51251
- let bytes = (Bytes.create [@doesNotRaise]) 1 in
51252
- Bytes.unsafe_set bytes 0 (Char.unsafe_chr c);
51253
- Bytes.unsafe_to_string bytes)
51254
- else if c <= 2047 then (
51255
- let bytes = (Bytes.create [@doesNotRaise]) 2 in
51256
- Bytes.unsafe_set bytes 0 (Char.unsafe_chr (h2 lor (c lsr 6)));
51257
- Bytes.unsafe_set bytes 1
51258
- (Char.unsafe_chr (0b1000_0000 lor (c land cont_mask)));
51259
- Bytes.unsafe_to_string bytes)
51260
- else if c <= 65535 then (
51261
- let bytes = (Bytes.create [@doesNotRaise]) 3 in
51262
- Bytes.unsafe_set bytes 0 (Char.unsafe_chr (h3 lor (c lsr 12)));
51263
- Bytes.unsafe_set bytes 1
51264
- (Char.unsafe_chr (0b1000_0000 lor ((c lsr 6) land cont_mask)));
51265
- Bytes.unsafe_set bytes 2
51266
- (Char.unsafe_chr (0b1000_0000 lor (c land cont_mask)));
51267
- Bytes.unsafe_to_string bytes)
51268
- else
51269
- (* if c <= max then *)
51270
- let bytes = (Bytes.create [@doesNotRaise]) 4 in
51271
- Bytes.unsafe_set bytes 0 (Char.unsafe_chr (h4 lor (c lsr 18)));
51272
- Bytes.unsafe_set bytes 1
51273
- (Char.unsafe_chr (0b1000_0000 lor ((c lsr 12) land cont_mask)));
51274
- Bytes.unsafe_set bytes 2
51275
- (Char.unsafe_chr (0b1000_0000 lor ((c lsr 6) land cont_mask)));
51276
- Bytes.unsafe_set bytes 3
51277
- (Char.unsafe_chr (0b1000_0000 lor (c land cont_mask)));
51278
- Bytes.unsafe_to_string bytes
51279
-
51280
- let isValidCodePoint c =
51281
- (0 <= c && c < surrogateMin) || (surrogateMax < c && c <= max)
51282
-
51283
51130
end
51284
51131
module Res_printer : sig
51285
51132
#1 "res_printer.mli"
@@ -51878,7 +51725,7 @@ let printConstant ?(templateLiteral = false) c =
51878
51725
let s = (Bytes.create [@doesNotRaise]) 1 in
51879
51726
Bytes.unsafe_set s 0 c;
51880
51727
Bytes.unsafe_to_string s
51881
- | c -> Res_utf8.encodeCodePoint (Obj.magic c)
51728
+ | c -> string_of_int (Obj.magic c)
51882
51729
in
51883
51730
Doc.text ("'" ^ str ^ "'")
51884
51731
0 commit comments