Skip to content

Commit f10725b

Browse files
committed
snapshot
1 parent a2f66e6 commit f10725b

File tree

4 files changed

+348
-491
lines changed

4 files changed

+348
-491
lines changed

lib/4.06.1/unstable/js_compiler.ml

+10-163
Original file line numberDiff line numberDiff line change
@@ -27495,7 +27495,7 @@ let build_other_constant proj make first next p env =
2749527495

2749627496
let some_other_tag = "<some other tag>"
2749727497

27498-
let build_other ext env = match env with
27498+
let build_other ext env : Typedtree.pattern = match env with
2749927499
| ({pat_desc = Tpat_construct (lid, {cstr_tag=Cstr_extension _},_)},_) :: _ ->
2750027500
(* let c = {c with cstr_name = "*extension*"} in *) (* PR#7330 *)
2750127501
make_pat (Tpat_var (Ident.create "*extension*",
@@ -27537,13 +27537,19 @@ let build_other ext env = match env with
2753727537
make_pat (Tpat_or (pat, p_res, None)) p.pat_type p.pat_env)
2753827538
pat other_pats
2753927539
end
27540-
| ({pat_desc=(Tpat_constant (Const_int _ | Const_char _))} as p,_) :: _ ->
27540+
| ({pat_desc=(Tpat_constant (Const_int _ ))} as p,_) :: _ ->
2754127541
build_other_constant
2754227542
(function Tpat_constant(Const_int i) -> i
27543-
| Tpat_constant (Const_char i) -> Char.code i
2754427543
| _ -> assert false)
2754527544
(function i -> Tpat_constant(Const_int i))
2754627545
0 succ p env
27546+
| ({pat_desc=(Tpat_constant (Const_char _ ))} as p,_) :: _ ->
27547+
build_other_constant
27548+
(function
27549+
| Tpat_constant (Const_char i) -> Char.code i
27550+
| _ -> assert false)
27551+
(function i -> Tpat_constant(Const_char (Obj.magic (i:int) : char)))
27552+
0 succ p env
2754727553
| ({pat_desc=(Tpat_constant (Const_int32 _))} as p,_) :: _ ->
2754827554
build_other_constant
2754927555
(function Tpat_constant(Const_int32 i) -> i | _ -> assert false)
@@ -51098,165 +51104,6 @@ let isKeywordTxt str =
5109851104

5109951105
let catch = Lident "catch"
5110051106

51101-
end
51102-
module Res_utf8 : sig
51103-
#1 "res_utf8.mli"
51104-
val repl : int
51105-
51106-
val max : int
51107-
51108-
val decodeCodePoint : int -> string -> int -> int * int
51109-
51110-
val encodeCodePoint : int -> string
51111-
51112-
val isValidCodePoint : int -> bool
51113-
51114-
end = struct
51115-
#1 "res_utf8.ml"
51116-
(* https://tools.ietf.org/html/rfc3629#section-10 *)
51117-
(* let bom = 0xFEFF *)
51118-
51119-
let repl = 0xFFFD
51120-
51121-
(* let min = 0x0000 *)
51122-
let max = 0x10FFFF
51123-
51124-
let surrogateMin = 0xD800
51125-
let surrogateMax = 0xDFFF
51126-
51127-
(*
51128-
* Char. number range | UTF-8 octet sequence
51129-
* (hexadecimal) | (binary)
51130-
* --------------------+---------------------------------------------
51131-
* 0000 0000-0000 007F | 0xxxxxxx
51132-
* 0000 0080-0000 07FF | 110xxxxx 10xxxxxx
51133-
* 0000 0800-0000 FFFF | 1110xxxx 10xxxxxx 10xxxxxx
51134-
* 0001 0000-0010 FFFF | 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
51135-
*)
51136-
let h2 = 0b1100_0000
51137-
let h3 = 0b1110_0000
51138-
let h4 = 0b1111_0000
51139-
51140-
let cont_mask = 0b0011_1111
51141-
51142-
type category = {low: int; high: int; size: int}
51143-
51144-
let locb = 0b1000_0000
51145-
let hicb = 0b1011_1111
51146-
51147-
let categoryTable = [|
51148-
(* 0 *) {low = -1; high= -1; size= 1}; (* invalid *)
51149-
(* 1 *) {low = 1; high= -1; size= 1}; (* ascii *)
51150-
(* 2 *) {low = locb; high= hicb; size= 2};
51151-
(* 3 *) {low = 0xA0; high= hicb; size= 3};
51152-
(* 4 *) {low = locb; high= hicb; size= 3};
51153-
(* 5 *) {low = locb; high= 0x9F; size= 3};
51154-
(* 6 *) {low = 0x90; high= hicb; size= 4};
51155-
(* 7 *) {low = locb; high= hicb; size= 4};
51156-
(* 8 *) {low = locb; high= 0x8F; size= 4};
51157-
|] [@@ocamlformat "disable"]
51158-
51159-
let categories = [|
51160-
1; 1; 1; 1; 1; 1 ;1 ;1 ;1 ;1 ;1 ;1 ;1 ;1 ;1 ;1;
51161-
1; 1; 1; 1; 1; 1 ;1 ;1 ;1 ;1 ;1 ;1 ;1 ;1 ;1 ;1;
51162-
1; 1; 1; 1; 1; 1 ;1 ;1 ;1 ;1 ;1 ;1 ;1 ;1 ;1 ;1;
51163-
1; 1; 1; 1; 1; 1 ;1 ;1 ;1 ;1 ;1 ;1 ;1 ;1 ;1 ;1;
51164-
1; 1; 1; 1; 1; 1 ;1 ;1 ;1 ;1 ;1 ;1 ;1 ;1 ;1 ;1;
51165-
1; 1; 1; 1; 1; 1 ;1 ;1 ;1 ;1 ;1 ;1 ;1 ;1 ;1 ;1;
51166-
1; 1; 1; 1; 1; 1 ;1 ;1 ;1 ;1 ;1 ;1 ;1 ;1 ;1 ;1;
51167-
1; 1; 1; 1; 1; 1 ;1 ;1 ;1 ;1 ;1 ;1 ;1 ;1 ;1 ;1;
51168-
51169-
0; 0; 0; 0;0; 0; 0; 0;0; 0; 0; 0;0; 0; 0; 0;
51170-
0; 0; 0; 0;0; 0; 0; 0;0; 0; 0; 0;0; 0; 0; 0;
51171-
0; 0; 0; 0;0; 0; 0; 0;0; 0; 0; 0;0; 0; 0; 0;
51172-
0; 0; 0; 0;0; 0; 0; 0;0; 0; 0; 0;0; 0; 0; 0;
51173-
(* surrogate range U+D800 - U+DFFFF = 55296 - 917503 *)
51174-
0; 0; 2; 2;2; 2; 2; 2;2; 2; 2; 2;2; 2; 2; 2;
51175-
2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2; 2;
51176-
3; 4; 4; 4; 4; 4; 4; 4; 4; 4; 4; 4; 4; 5; 4; 4;
51177-
6; 7; 7 ;7; 8; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0;
51178-
|] [@@ocamlformat "disable"]
51179-
51180-
let decodeCodePoint i s len =
51181-
if len < 1 then (repl, 1)
51182-
else
51183-
let first = int_of_char (String.unsafe_get s i) in
51184-
if first < 128 then (first, 1)
51185-
else
51186-
let index = Array.unsafe_get categories first in
51187-
if index = 0 then (repl, 1)
51188-
else
51189-
let cat = Array.unsafe_get categoryTable index in
51190-
if len < i + cat.size then (repl, 1)
51191-
else if cat.size == 2 then
51192-
let c1 = int_of_char (String.unsafe_get s (i + 1)) in
51193-
if c1 < cat.low || cat.high < c1 then (repl, 1)
51194-
else
51195-
let i1 = c1 land 0b00111111 in
51196-
let i0 = (first land 0b00011111) lsl 6 in
51197-
let uc = i0 lor i1 in
51198-
(uc, 2)
51199-
else if cat.size == 3 then
51200-
let c1 = int_of_char (String.unsafe_get s (i + 1)) in
51201-
let c2 = int_of_char (String.unsafe_get s (i + 2)) in
51202-
if c1 < cat.low || cat.high < c1 || c2 < locb || hicb < c2 then
51203-
(repl, 1)
51204-
else
51205-
let i0 = (first land 0b00001111) lsl 12 in
51206-
let i1 = (c1 land 0b00111111) lsl 6 in
51207-
let i2 = c2 land 0b00111111 in
51208-
let uc = i0 lor i1 lor i2 in
51209-
(uc, 3)
51210-
else
51211-
let c1 = int_of_char (String.unsafe_get s (i + 1)) in
51212-
let c2 = int_of_char (String.unsafe_get s (i + 2)) in
51213-
let c3 = int_of_char (String.unsafe_get s (i + 3)) in
51214-
if
51215-
c1 < cat.low || cat.high < c1 || c2 < locb || hicb < c2 || c3 < locb
51216-
|| hicb < c3
51217-
then (repl, 1)
51218-
else
51219-
let i1 = (c1 land 0x3f) lsl 12 in
51220-
let i2 = (c2 land 0x3f) lsl 6 in
51221-
let i3 = c3 land 0x3f in
51222-
let i0 = (first land 0x07) lsl 18 in
51223-
let uc = i0 lor i3 lor i2 lor i1 in
51224-
(uc, 4)
51225-
51226-
let encodeCodePoint c =
51227-
if c <= 127 then (
51228-
let bytes = (Bytes.create [@doesNotRaise]) 1 in
51229-
Bytes.unsafe_set bytes 0 (Char.unsafe_chr c);
51230-
Bytes.unsafe_to_string bytes)
51231-
else if c <= 2047 then (
51232-
let bytes = (Bytes.create [@doesNotRaise]) 2 in
51233-
Bytes.unsafe_set bytes 0 (Char.unsafe_chr (h2 lor (c lsr 6)));
51234-
Bytes.unsafe_set bytes 1
51235-
(Char.unsafe_chr (0b1000_0000 lor (c land cont_mask)));
51236-
Bytes.unsafe_to_string bytes)
51237-
else if c <= 65535 then (
51238-
let bytes = (Bytes.create [@doesNotRaise]) 3 in
51239-
Bytes.unsafe_set bytes 0 (Char.unsafe_chr (h3 lor (c lsr 12)));
51240-
Bytes.unsafe_set bytes 1
51241-
(Char.unsafe_chr (0b1000_0000 lor ((c lsr 6) land cont_mask)));
51242-
Bytes.unsafe_set bytes 2
51243-
(Char.unsafe_chr (0b1000_0000 lor (c land cont_mask)));
51244-
Bytes.unsafe_to_string bytes)
51245-
else
51246-
(* if c <= max then *)
51247-
let bytes = (Bytes.create [@doesNotRaise]) 4 in
51248-
Bytes.unsafe_set bytes 0 (Char.unsafe_chr (h4 lor (c lsr 18)));
51249-
Bytes.unsafe_set bytes 1
51250-
(Char.unsafe_chr (0b1000_0000 lor ((c lsr 12) land cont_mask)));
51251-
Bytes.unsafe_set bytes 2
51252-
(Char.unsafe_chr (0b1000_0000 lor ((c lsr 6) land cont_mask)));
51253-
Bytes.unsafe_set bytes 3
51254-
(Char.unsafe_chr (0b1000_0000 lor (c land cont_mask)));
51255-
Bytes.unsafe_to_string bytes
51256-
51257-
let isValidCodePoint c =
51258-
(0 <= c && c < surrogateMin) || (surrogateMax < c && c <= max)
51259-
5126051107
end
5126151108
module Res_printer : sig
5126251109
#1 "res_printer.mli"
@@ -51855,7 +51702,7 @@ let printConstant ?(templateLiteral = false) c =
5185551702
let s = (Bytes.create [@doesNotRaise]) 1 in
5185651703
Bytes.unsafe_set s 0 c;
5185751704
Bytes.unsafe_to_string s
51858-
| c -> Res_utf8.encodeCodePoint (Obj.magic c)
51705+
| c -> string_of_int (Obj.magic c)
5185951706
in
5186051707
Doc.text ("'" ^ str ^ "'")
5186151708

lib/4.06.1/unstable/js_compiler.ml.d

-2
Original file line numberDiff line numberDiff line change
@@ -584,8 +584,6 @@
584584
../lib/4.06.1/unstable/js_compiler.ml: ./napkin/res_printer.ml
585585
../lib/4.06.1/unstable/js_compiler.ml: ./napkin/res_printer.mli
586586
../lib/4.06.1/unstable/js_compiler.ml: ./napkin/res_token.ml
587-
../lib/4.06.1/unstable/js_compiler.ml: ./napkin/res_utf8.ml
588-
../lib/4.06.1/unstable/js_compiler.ml: ./napkin/res_utf8.mli
589587
../lib/4.06.1/unstable/js_compiler.ml: ./outcome_printer/outcome_printer_ns.ml
590588
../lib/4.06.1/unstable/js_compiler.ml: ./outcome_printer/outcome_printer_ns.mli
591589
../lib/4.06.1/unstable/js_compiler.ml: ./stubs/bs_hash_stubs.pp.ml

0 commit comments

Comments
 (0)