toilscript 0.0.1 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -201
- package/NOTICE +94 -94
- package/README.md +101 -114
- package/bin/asc.js +0 -0
- package/bin/asinit.js +6 -6
- package/dist/asc.generated.d.ts +10027 -0
- package/dist/asc.js +24474 -0
- package/dist/asc.js.map +7 -0
- package/dist/importmap.json +9 -0
- package/dist/toilscript.generated.d.ts +11242 -0
- package/dist/toilscript.js +337 -0
- package/dist/toilscript.js.map +7 -0
- package/dist/web.js +22 -0
- package/lib/binaryen.d.ts +2 -2
- package/lib/binaryen.js +2 -2
- package/package.json +115 -114
- package/std/README.md +6 -6
- package/std/assembly/array.ts +550 -550
- package/std/assembly/arraybuffer.ts +77 -77
- package/std/assembly/atomics.ts +127 -127
- package/std/assembly/bindings/asyncify.ts +16 -16
- package/std/assembly/bindings/dom.ts +291 -291
- package/std/assembly/bindings/node.ts +6 -6
- package/std/assembly/bitflags.ts +53 -53
- package/std/assembly/builtins.ts +2650 -2650
- package/std/assembly/byteslice.ts +177 -177
- package/std/assembly/compat.ts +2 -2
- package/std/assembly/console.ts +42 -42
- package/std/assembly/crypto.ts +9 -9
- package/std/assembly/dataview.ts +181 -181
- package/std/assembly/date.ts +375 -375
- package/std/assembly/diagnostics.ts +11 -11
- package/std/assembly/encoding.ts +151 -151
- package/std/assembly/endian.ts +45 -45
- package/std/assembly/error.ts +44 -44
- package/std/assembly/fixedarray.ts +173 -173
- package/std/assembly/fixedmap.ts +326 -326
- package/std/assembly/fixedset.ts +275 -275
- package/std/assembly/function.ts +42 -42
- package/std/assembly/index.d.ts +2892 -2891
- package/std/assembly/iterator.ts +35 -35
- package/std/assembly/map.ts +269 -269
- package/std/assembly/math.ts +3289 -3289
- package/std/assembly/memory.ts +123 -123
- package/std/assembly/number.ts +388 -388
- package/std/assembly/object.ts +36 -36
- package/std/assembly/performance.ts +9 -9
- package/std/assembly/pointer.ts +80 -80
- package/std/assembly/polyfills.ts +27 -27
- package/std/assembly/process.ts +50 -50
- package/std/assembly/reference.ts +48 -48
- package/std/assembly/regexp.ts +12 -12
- package/std/assembly/rt/README.md +83 -83
- package/std/assembly/rt/common.ts +81 -81
- package/std/assembly/rt/index-incremental.ts +2 -2
- package/std/assembly/rt/index-memory.ts +1 -1
- package/std/assembly/rt/index-minimal.ts +2 -2
- package/std/assembly/rt/index-stub.ts +1 -1
- package/std/assembly/rt/index.d.ts +37 -37
- package/std/assembly/rt/itcms.ts +419 -419
- package/std/assembly/rt/memory-runtime.ts +94 -94
- package/std/assembly/rt/rtrace.ts +15 -15
- package/std/assembly/rt/stub.ts +133 -133
- package/std/assembly/rt/tcms.ts +254 -254
- package/std/assembly/rt/tlsf.ts +592 -592
- package/std/assembly/rt.ts +90 -90
- package/std/assembly/set.ts +225 -225
- package/std/assembly/shared/feature.ts +68 -68
- package/std/assembly/shared/runtime.ts +13 -13
- package/std/assembly/shared/target.ts +11 -11
- package/std/assembly/shared/tsconfig.json +11 -11
- package/std/assembly/shared/typeinfo.ts +72 -72
- package/std/assembly/staticarray.ts +423 -423
- package/std/assembly/string.ts +850 -850
- package/std/assembly/symbol.ts +114 -114
- package/std/assembly/table.ts +16 -16
- package/std/assembly/toilscript.ts +16 -0
- package/std/assembly/tsconfig.json +6 -6
- package/std/assembly/typedarray.ts +1954 -1954
- package/std/assembly/uri.ts +17 -17
- package/std/assembly/util/bytes.ts +107 -107
- package/std/assembly/util/casemap.ts +497 -497
- package/std/assembly/util/error.ts +58 -58
- package/std/assembly/util/hash.ts +117 -117
- package/std/assembly/util/math.ts +1922 -1922
- package/std/assembly/util/memory.ts +290 -290
- package/std/assembly/util/number.ts +873 -873
- package/std/assembly/util/sort.ts +313 -313
- package/std/assembly/util/string.ts +1202 -1202
- package/std/assembly/util/uri.ts +275 -275
- package/std/assembly/vector.ts +4 -4
- package/std/assembly.json +16 -16
- package/std/portable/index.d.ts +461 -461
- package/std/portable/index.js +416 -416
- package/std/portable.json +11 -11
- package/std/types/assembly/index.d.ts +1 -1
- package/std/types/assembly/package.json +2 -2
- package/std/types/portable/index.d.ts +1 -1
- package/std/types/portable/package.json +2 -2
- package/tsconfig-base.json +13 -13
- package/util/README.md +23 -23
- package/util/browser/fs.js +1 -1
- package/util/browser/module.js +5 -5
- package/util/browser/path.js +520 -520
- package/util/browser/process.js +59 -59
- package/util/browser/url.js +23 -23
- package/util/cpu.d.ts +9 -9
- package/util/cpu.js +42 -42
- package/util/find.d.ts +6 -6
- package/util/find.js +20 -20
- package/util/node.d.ts +21 -21
- package/util/node.js +34 -34
- package/util/options.d.ts +70 -70
- package/util/options.js +262 -262
- package/util/terminal.d.ts +52 -52
- package/util/terminal.js +35 -35
- package/util/text.d.ts +26 -26
- package/util/text.js +114 -114
- package/util/tsconfig.json +9 -9
- package/util/web.d.ts +11 -11
- package/util/web.js +33 -33
|
@@ -1,1202 +1,1202 @@
|
|
|
1
|
-
import {
|
|
2
|
-
itoa32,
|
|
3
|
-
utoa32,
|
|
4
|
-
itoa64,
|
|
5
|
-
utoa64,
|
|
6
|
-
dtoa,
|
|
7
|
-
itoa_buffered,
|
|
8
|
-
dtoa_buffered,
|
|
9
|
-
MAX_DOUBLE_LENGTH
|
|
10
|
-
} from "./number";
|
|
11
|
-
|
|
12
|
-
import {
|
|
13
|
-
ipow32
|
|
14
|
-
} from "../math";
|
|
15
|
-
|
|
16
|
-
// All tables are stored as two staged lookup tables (static tries)
|
|
17
|
-
// because the full range of Unicode symbols can't be efficiently
|
|
18
|
-
// represented as-is in memory (see Unicode spec ch 5, p.196):
|
|
19
|
-
// https://www.unicode.org/versions/Unicode12.0.0/ch05.pdf
|
|
20
|
-
// Tables have been generated using these forked musl tools:
|
|
21
|
-
// https://github.com/MaxGraey/musl-chartable-tools/tree/case-ignorable
|
|
22
|
-
|
|
23
|
-
// Lookup table to check if a character is alphanumeric or not
|
|
24
|
-
// See: https://git.musl-libc.org/cgit/musl/tree/src/ctype/alpha.h
|
|
25
|
-
// size: 3904 bytes
|
|
26
|
-
// @ts-ignore
|
|
27
|
-
@inline @lazy const ALPHA_TABLE = memory.data<u8>([
|
|
28
|
-
18,17,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,17,34,35,36,17,37,38,39,40,
|
|
29
|
-
41,42,43,44,17,45,46,47,16,16,48,16,16,16,16,16,16,16,49,50,51,16,52,53,16,16,
|
|
30
|
-
17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,54,
|
|
31
|
-
17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,
|
|
32
|
-
17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,
|
|
33
|
-
17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,
|
|
34
|
-
17,17,17,55,17,17,17,17,56,17,57,58,59,60,61,62,17,17,17,17,17,17,17,17,17,17,
|
|
35
|
-
17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,
|
|
36
|
-
17,17,17,17,17,17,17,63,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
37
|
-
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,17,64,65,17,66,67,
|
|
38
|
-
68,69,70,71,72,73,74,17,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,
|
|
39
|
-
93,94,16,95,96,97,98,17,17,17,99,100,101,16,16,16,16,16,16,16,16,16,16,17,17,
|
|
40
|
-
17,17,102,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,17,17,103,16,16,16,16,
|
|
41
|
-
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
42
|
-
16,16,16,17,17,104,105,16,16,106,107,17,17,17,17,17,17,17,17,17,17,17,17,17,
|
|
43
|
-
17,17,17,17,17,17,17,17,17,17,108,17,17,17,17,109,110,16,16,16,16,16,16,16,16,
|
|
44
|
-
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
45
|
-
17,111,112,16,16,16,16,16,16,16,16,16,113,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
46
|
-
16,16,16,16,16,16,16,16,16,16,16,114,115,116,117,16,16,16,16,16,16,16,16,118,
|
|
47
|
-
119,120,16,16,16,16,16,121,122,16,16,16,16,123,16,16,124,16,16,16,16,16,16,16,
|
|
48
|
-
16,16,125,16,16,16,
|
|
49
|
-
16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,
|
|
50
|
-
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
|
|
51
|
-
255,255,255,255,255,255,255,255,255,255,255,0,0,0,0,0,0,0,0,254,255,255,7,254,
|
|
52
|
-
255,255,7,0,0,0,0,0,4,32,4,255,255,127,255,255,255,127,255,255,255,255,255,
|
|
53
|
-
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
|
|
54
|
-
255,195,255,3,0,31,80,0,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,223,188,64,215,255,255,
|
|
55
|
-
251,255,255,255,255,255,255,255,255,255,191,255,255,255,255,255,255,255,255,
|
|
56
|
-
255,255,255,255,255,255,255,255,255,3,252,255,255,255,255,255,255,255,255,255,
|
|
57
|
-
255,255,255,255,255,255,255,255,255,255,255,254,255,255,255,127,2,255,255,255,
|
|
58
|
-
255,255,1,0,0,0,0,255,191,182,0,255,255,255,135,7,0,0,0,255,7,255,255,255,255,
|
|
59
|
-
255,255,255,254,255,195,255,255,255,255,255,255,255,255,255,255,255,255,239,
|
|
60
|
-
31,254,225,255,
|
|
61
|
-
159,0,0,255,255,255,255,255,255,0,224,255,255,255,255,255,255,255,255,255,255,
|
|
62
|
-
255,255,3,0,255,255,255,255,255,7,48,4,255,255,255,252,255,31,0,0,255,255,255,
|
|
63
|
-
1,255,7,0,0,0,0,0,0,255,255,223,255,255,0,240,255,248,3,255,255,255,255,255,
|
|
64
|
-
255,255,255,255,239,255,223,225,255,207,255,254,255,239,159,249,255,255,253,
|
|
65
|
-
197,227,159,89,128,176,207,255,3,16,238,135,249,255,255,253,109,195,135,25,2,
|
|
66
|
-
94,192,255,63,0,238,191,251,255,255,253,237,227,191,27,1,0,207,255,0,30,238,
|
|
67
|
-
159,249,255,255,253,237,227,159,25,192,176,207,255,2,0,236,199,61,214,24,199,
|
|
68
|
-
255,195,199,29,129,0,192,255,0,0,239,223,253,255,255,253,255,227,223,29,96,7,
|
|
69
|
-
207,255,0,0,239,223,253,255,255,253,239,227,223,29,96,64,207,255,6,0,255,223,
|
|
70
|
-
253,255,255,255,255,231,223,93,240,128,207,255,0,252,238,255,127,252,255,255,
|
|
71
|
-
251,47,127,128,95,255,192,255,12,0,254,255,255,255,255,127,255,7,63,32,255,3,
|
|
72
|
-
0,0,0,0,214,247,255,255,175,255,255,59,95,32,255,243,0,0,0,
|
|
73
|
-
0,1,0,0,0,255,3,0,0,255,254,255,255,255,31,254,255,3,255,255,254,255,255,255,
|
|
74
|
-
31,0,0,0,0,0,0,0,0,255,255,255,255,255,255,127,249,255,3,255,255,255,255,255,
|
|
75
|
-
255,255,255,255,63,255,255,255,255,191,32,255,255,255,255,255,247,255,255,255,
|
|
76
|
-
255,255,255,255,255,255,61,127,61,255,255,255,255,255,61,255,255,255,255,61,
|
|
77
|
-
127,61,255,127,255,255,255,255,255,255,255,61,255,255,255,255,255,255,255,255,
|
|
78
|
-
7,0,0,0,0,255,255,0,0,255,255,255,255,255,255,255,255,255,255,63,63,254,255,
|
|
79
|
-
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
|
|
80
|
-
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
|
|
81
|
-
255,255,255,255,255,159,255,255,254,255,255,7,255,255,255,255,255,255,255,255,
|
|
82
|
-
255,199,255,1,255,223,15,0,255,255,15,0,255,255,15,0,255,223,13,0,255,255,255,
|
|
83
|
-
255,255,255,207,255,255,1,128,16,255,3,0,0,0,0,255,3,255,255,255,255,255,255,
|
|
84
|
-
255,255,255,255,255,1,255,255,255,255,255,7,255,255,255,255,255,255,255,255,
|
|
85
|
-
63,
|
|
86
|
-
0,255,255,255,127,255,15,255,1,192,255,255,255,255,63,31,0,255,255,255,255,
|
|
87
|
-
255,15,255,255,255,3,255,3,0,0,0,0,255,255,255,15,255,255,255,255,255,255,255,
|
|
88
|
-
127,254,255,31,0,255,3,255,3,128,0,0,128,1,0,0,0,0,0,0,0,255,255,255,255,255,
|
|
89
|
-
255,239,255,239,15,255,3,0,0,0,0,255,255,255,255,255,243,255,255,255,255,255,
|
|
90
|
-
255,191,255,3,0,255,255,255,255,255,255,127,0,255,227,255,255,255,255,255,63,
|
|
91
|
-
255,1,255,255,255,255,255,231,0,0,0,0,0,222,111,4,255,255,255,255,255,255,255,
|
|
92
|
-
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,0,0,0,
|
|
93
|
-
128,255,31,0,255,255,63,63,255,255,255,255,63,63,255,170,255,255,255,63,255,
|
|
94
|
-
255,255,255,255,255,223,95,220,31,207,15,255,31,220,31,0,0,0,0,0,0,0,0,0,0,0,
|
|
95
|
-
0,0,0,2,128,0,0,255,31,0,0,0,0,0,0,0,0,0,0,0,0,132,252,47,62,80,189,255,243,
|
|
96
|
-
224,67,0,0,255,255,255,255,255,1,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
97
|
-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,255,255,255,255,255,255,3,0,
|
|
98
|
-
0,255,255,255,255,255,127,255,255,255,255,255,127,255,255,255,255,255,255,255,
|
|
99
|
-
255,255,255,255,255,255,255,255,255,31,120,12,0,255,255,255,255,191,32,255,
|
|
100
|
-
255,255,255,255,255,255,128,0,0,255,255,127,0,127,127,127,127,127,127,127,127,
|
|
101
|
-
255,255,255,255,0,0,0,0,0,128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
102
|
-
0,0,224,0,0,0,254,3,62,31,254,255,255,255,255,255,255,255,255,255,127,224,254,
|
|
103
|
-
255,255,255,255,255,255,255,255,255,255,247,224,255,255,255,255,255,254,255,
|
|
104
|
-
255,255,255,255,255,255,255,255,255,127,0,0,255,255,255,255,0,0,0,0,0,0,255,
|
|
105
|
-
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
|
|
106
|
-
255,255,255,255,255,255,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,255,
|
|
107
|
-
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
|
|
108
|
-
255,255,255,
|
|
109
|
-
31,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,31,0,0,
|
|
110
|
-
0,0,0,0,0,0,255,255,255,255,255,63,255,31,255,255,255,15,0,0,255,255,255,255,
|
|
111
|
-
255,127,240,143,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,0,0,
|
|
112
|
-
0,128,255,252,255,255,255,255,255,255,255,255,255,255,255,255,249,255,255,255,
|
|
113
|
-
255,255,255,252,7,0,0,0,0,224,255,191,255,255,255,255,0,0,0,255,255,255,255,
|
|
114
|
-
255,255,15,0,255,255,255,255,255,255,255,255,47,0,255,3,0,0,252,232,255,255,
|
|
115
|
-
255,255,255,7,255,255,255,255,7,0,255,255,255,31,255,255,255,255,255,255,247,
|
|
116
|
-
255,0,128,255,3,255,255,255,127,255,255,255,255,255,255,127,0,255,63,255,3,
|
|
117
|
-
255,255,127,252,255,255,255,255,255,255,255,127,5,0,0,56,255,255,60,0,126,126,
|
|
118
|
-
126,0,127,127,255,255,255,255,255,247,255,3,255,255,255,255,255,255,255,255,
|
|
119
|
-
255,255,255,255,255,255,255,7,255,3,255,255,255,255,255,255,255,255,255,255,
|
|
120
|
-
255,255,255,255,255,255,255,255,255,255,15,0,255,255,127,248,255,255,255,255,
|
|
121
|
-
255,
|
|
122
|
-
15,255,255,255,255,255,255,255,255,255,255,255,255,255,63,255,255,255,255,255,
|
|
123
|
-
255,255,255,255,255,255,255,255,3,0,0,0,0,127,0,248,224,255,253,127,95,219,
|
|
124
|
-
255,255,255,255,255,255,255,255,255,255,255,255,255,3,0,0,0,248,255,255,255,
|
|
125
|
-
255,255,255,255,255,255,255,255,255,63,0,0,255,255,255,255,255,255,255,255,
|
|
126
|
-
252,255,255,255,255,255,255,0,0,0,0,0,255,15,0,0,0,0,0,0,0,0,0,0,0,0,0,0,223,
|
|
127
|
-
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,31,0,0,255,3,
|
|
128
|
-
254,255,255,7,254,255,255,7,192,255,255,255,255,255,255,255,255,255,255,127,
|
|
129
|
-
252,252,252,28,0,0,0,0,255,239,255,255,127,255,255,183,255,63,255,63,0,0,0,0,
|
|
130
|
-
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,7,0,0,0,0,0,0,0,0,
|
|
131
|
-
255,255,255,255,255,255,31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
132
|
-
0,0,0,0,0,0,0,0,255,255,255,31,255,255,255,255,255,255,1,0,0,0,0,
|
|
133
|
-
0,255,255,255,255,0,224,255,255,255,7,255,255,255,255,255,7,255,255,255,63,
|
|
134
|
-
255,255,255,255,15,255,62,0,0,0,0,0,255,255,255,255,255,255,255,255,255,255,
|
|
135
|
-
255,255,255,255,255,255,255,255,255,63,255,3,255,255,255,255,15,255,255,255,
|
|
136
|
-
255,15,255,255,255,255,255,0,255,255,255,255,255,255,15,0,0,0,0,0,0,0,0,0,0,0,
|
|
137
|
-
0,0,0,0,0,0,0,0,255,255,255,255,255,255,127,0,255,255,63,0,255,0,0,0,0,0,0,0,
|
|
138
|
-
0,0,0,0,0,0,0,0,0,0,0,0,63,253,255,255,255,255,191,145,255,255,63,0,255,255,
|
|
139
|
-
127,0,255,255,255,127,0,0,0,0,0,0,0,0,255,255,55,0,255,255,63,0,255,255,255,3,
|
|
140
|
-
0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,192,0,0,0,0,0,0,0,0,111,240,239,
|
|
141
|
-
254,255,255,63,0,0,0,0,0,255,255,255,31,255,255,255,31,0,0,0,0,255,254,255,
|
|
142
|
-
255,31,0,0,0,255,255,255,255,255,255,63,0,255,255,63,0,255,255,7,0,255,255,3,
|
|
143
|
-
0,0,0,0,0,0,0,0,0,0,0,0,
|
|
144
|
-
0,255,255,255,255,255,255,255,255,255,1,0,0,0,0,0,0,255,255,255,255,255,255,7,
|
|
145
|
-
0,255,255,255,255,255,255,7,0,255,255,255,255,255,0,255,3,0,0,0,0,0,0,0,0,0,0,
|
|
146
|
-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,
|
|
147
|
-
255,27,3,0,0,0,0,0,0,0,0,0,255,255,255,31,128,0,255,255,63,0,0,0,0,0,0,0,0,0,
|
|
148
|
-
0,0,0,0,255,255,31,0,0,0,255,255,127,0,255,255,255,255,255,255,255,255,63,0,0,
|
|
149
|
-
0,192,255,0,0,252,255,255,255,255,255,255,1,0,0,255,255,255,1,255,3,255,255,
|
|
150
|
-
255,255,255,255,199,255,240,0,255,255,255,255,71,0,255,255,255,255,255,255,
|
|
151
|
-
255,255,30,192,255,23,0,0,0,0,255,255,251,255,255,255,159,64,0,0,0,0,0,0,0,0,
|
|
152
|
-
127,189,255,191,255,1,255,255,255,255,255,255,255,1,255,3,239,159,249,255,255,
|
|
153
|
-
253,237,227,159,25,129,224,15,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
154
|
-
0,255,255,255,255,255,255,255,255,187,7,255,131,3,0,0,0,255,255,255,255,255,
|
|
155
|
-
255,255,255,179,0,255,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,
|
|
156
|
-
255,255,255,63,127,0,0,0,63,0,0,0,0,255,255,255,255,255,255,255,127,17,0,255,
|
|
157
|
-
3,0,0,0,0,255,255,255,255,255,255,63,1,255,3,0,0,0,0,0,0,255,255,255,231,255,
|
|
158
|
-
7,255,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,
|
|
159
|
-
255,255,1,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,255,3,0,128,
|
|
160
|
-
127,242,111,255,255,255,191,153,7,0,255,3,0,0,0,0,0,0,0,0,255,252,255,255,255,
|
|
161
|
-
255,255,252,26,0,0,0,255,255,255,255,255,255,231,127,0,0,255,255,255,255,255,
|
|
162
|
-
255,255,255,255,32,0,0,0,0,255,255,255,255,255,255,255,1,255,253,255,255,255,
|
|
163
|
-
255,127,127,1,0,255,3,0,0,252,255,255,255,252,255,255,254,127,0,0,0,0,0,0,0,0,
|
|
164
|
-
0,127,251,255,255,255,255,127,180,203,0,255,3,191,253,255,255,255,127,123,1,
|
|
165
|
-
255,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
166
|
-
0,0,255,255,127,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,
|
|
167
|
-
0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
|
|
168
|
-
255,3,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,255,255,255,255,
|
|
169
|
-
255,127,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
|
|
170
|
-
255,255,255,255,255,255,255,255,15,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
171
|
-
0,0,255,255,255,255,255,127,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
172
|
-
0,255,255,255,255,255,255,255,255,127,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
173
|
-
0,0,
|
|
174
|
-
0,255,255,255,255,255,255,255,1,255,255,255,127,255,3,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
175
|
-
255,255,255,63,0,0,255,255,255,255,255,255,0,0,15,0,255,3,248,255,255,224,255,
|
|
176
|
-
255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,
|
|
177
|
-
255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,255,135,
|
|
178
|
-
255,255,255,255,255,255,255,128,255,255,0,0,0,0,0,0,0,0,11,0,3,0,255,255,255,
|
|
179
|
-
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
|
|
180
|
-
255,255,255,255,255,255,255,255,255,0,255,255,255,255,255,255,255,255,255,255,
|
|
181
|
-
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,63,0,0,0,0,0,
|
|
182
|
-
255,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,
|
|
183
|
-
127,0,0,0,0,0,0,7,0,240,0,255,255,255,255,255,255,255,255,255,255,255,255,255,
|
|
184
|
-
255,255,255,255,
|
|
185
|
-
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
|
|
186
|
-
255,255,255,255,255,255,255,255,255,255,255,255,255,15,255,255,255,255,255,
|
|
187
|
-
255,255,255,255,255,255,255,255,7,255,31,255,1,255,67,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
188
|
-
255,255,255,255,255,255,255,255,255,255,223,255,255,255,255,255,255,255,255,
|
|
189
|
-
223,100,222,255,235,239,255,255,255,255,255,255,255,191,231,223,223,255,255,
|
|
190
|
-
255,123,95,252,253,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
|
|
191
|
-
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
|
|
192
|
-
255,255,255,255,255,255,255,255,63,255,255,255,253,255,255,247,255,255,255,
|
|
193
|
-
247,255,255,223,255,255,255,223,255,255,127,255,255,255,127,255,255,255,253,
|
|
194
|
-
255,255,255,253,255,255,247,207,255,255,255,255,255,255,127,255,255,249,219,7,
|
|
195
|
-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,31,
|
|
196
|
-
128,63,255,67,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
197
|
-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,15,255,
|
|
198
|
-
3,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
|
|
199
|
-
255,255,255,255,255,31,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,143,8,
|
|
200
|
-
255,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,239,255,255,255,150,254,247,10,
|
|
201
|
-
132,234,150,170,150,247,247,94,255,251,255,15,238,251,255,15,0,0,0,0,0,0,0,0,
|
|
202
|
-
0,0,0,0,0,0,255,255,255,3,255,255,255,3,255,255,255,3,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
203
|
-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,3
|
|
204
|
-
]);
|
|
205
|
-
|
|
206
|
-
// size: 1568 bytes (compressed to ~1380 bytes after binaryen)
|
|
207
|
-
// @ts-ignore: decorator
|
|
208
|
-
@lazy @inline const CASED = memory.data<u8>([
|
|
209
|
-
18,19,20,21,22,23,16,16,16,16,16,16,16,16,16,16,
|
|
210
|
-
24,16,16,25,16,16,16,16,16,16,16,16,26,27,17,28,
|
|
211
|
-
29,30,16,16,31,16,16,16,16,16,16,16,32,33,16,16,
|
|
212
|
-
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
213
|
-
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
214
|
-
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
215
|
-
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
216
|
-
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
217
|
-
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
218
|
-
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
219
|
-
16,16,16,16,16,16,34,35,16,16,16,36,16,16,16,16,
|
|
220
|
-
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
221
|
-
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
222
|
-
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
223
|
-
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
224
|
-
16,16,16,16,16,16,16,16,16,16,16,37,16,16,16,38,
|
|
225
|
-
16,16,16,16,39,16,16,16,16,16,16,16,40,16,16,16,
|
|
226
|
-
16,16,16,16,16,16,16,16,41,16,16,16,16,16,16,16,
|
|
227
|
-
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
228
|
-
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
229
|
-
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
230
|
-
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
231
|
-
16,16,16,16,16,16,16,16,16,16,16,16,16,16,42,16,
|
|
232
|
-
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
233
|
-
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
234
|
-
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
235
|
-
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
236
|
-
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
237
|
-
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
238
|
-
16,16,16,16,43,44,45,46,16,16,16,16,16,16,16,16,
|
|
239
|
-
16,16,16,16,16,16,16,16,16,47,16,16,16,16,16,16,
|
|
240
|
-
16,48,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
241
|
-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
242
|
-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
243
|
-
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
|
|
244
|
-
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
|
|
245
|
-
0,0,0,0,0,0,0,0,254,255,255,7,254,255,255,7,0,0,0,0,0,4,32,4,
|
|
246
|
-
255,255,127,255,255,255,127,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
|
|
247
|
-
255,255,255,255,255,255,255,247,240,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
|
|
248
|
-
255,255,255,255,255,255,255,255,255,255,239,255,255,255,255,1,3,0,0,0,31,0,0,0,
|
|
249
|
-
0,0,0,0,0,0,0,0,32,0,0,0,0,0,207,188,64,215,255,255,251,255,255,255,
|
|
250
|
-
255,255,255,255,255,255,191,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
|
|
251
|
-
3,252,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,255,
|
|
252
|
-
255,255,127,0,255,255,255,255,255,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
253
|
-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,
|
|
254
|
-
191,32,255,255,255,255,255,231,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
255
|
-
0,0,0,0,255,255,255,255,255,255,255,255,255,255,63,63,0,0,0,0,0,0,0,0,
|
|
256
|
-
0,0,0,0,0,0,0,0,255,1,255,255,255,255,255,231,0,0,0,0,0,0,0,0,
|
|
257
|
-
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
|
|
258
|
-
0,0,0,0,0,0,0,0,255,255,63,63,255,255,255,255,63,63,255,170,255,255,255,63,
|
|
259
|
-
255,255,255,255,255,255,223,95,220,31,207,15,255,31,220,31,0,0,0,0,0,0,0,0,
|
|
260
|
-
0,0,0,0,0,0,2,128,0,0,255,31,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
261
|
-
132,252,47,62,80,189,31,242,224,67,0,0,255,255,255,255,24,0,0,0,0,0,0,0,
|
|
262
|
-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
263
|
-
0,0,0,0,0,0,192,255,255,255,255,255,255,3,0,0,255,255,255,255,255,127,255,255,
|
|
264
|
-
255,255,255,127,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,31,120,12,0,
|
|
265
|
-
255,255,255,255,191,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
266
|
-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,63,0,0,
|
|
267
|
-
255,255,255,63,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,252,255,255,255,
|
|
268
|
-
255,255,255,255,255,255,255,255,255,120,255,255,255,255,255,255,252,7,0,0,0,0,96,7,
|
|
269
|
-
0,0,0,0,0,0,255,255,255,255,255,247,255,1,255,255,255,255,255,255,255,255,255,255,
|
|
270
|
-
0,0,0,0,0,0,0,0,127,0,248,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
271
|
-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,254,255,255,7,
|
|
272
|
-
254,255,255,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
273
|
-
255,255,255,255,255,255,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,255,255,
|
|
274
|
-
255,255,15,255,255,255,255,15,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
275
|
-
255,255,255,255,255,255,7,0,255,255,255,255,255,255,7,0,0,0,0,0,0,0,0,0,
|
|
276
|
-
0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,0,0,0,0,
|
|
277
|
-
0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,0,0,0,0,0,0,0,0,
|
|
278
|
-
0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,255,255,223,255,255,255,255,255,
|
|
279
|
-
255,255,255,223,100,222,255,235,239,255,255,255,255,255,255,255,191,231,223,223,255,255,255,123,
|
|
280
|
-
95,252,253,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
|
|
281
|
-
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,63,255,255,255,
|
|
282
|
-
253,255,255,247,255,255,255,247,255,255,223,255,255,255,223,255,255,127,255,255,255,127,255,255,
|
|
283
|
-
255,253,255,255,255,253,255,255,247,15,0,0,0,0,0,0,255,255,255,255,255,255,255,255,
|
|
284
|
-
15,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
285
|
-
0,0,0,0,0,0,255,255,255,3,255,255,255,3,255,255,255,3,0,0,0,0,0,0,
|
|
286
|
-
0,0,0,0,0,0,0,0
|
|
287
|
-
]);
|
|
288
|
-
|
|
289
|
-
// size: 2976 bytes (compressed to ~2050 bytes after binaryen)
|
|
290
|
-
// @ts-ignore: decorator
|
|
291
|
-
@lazy @inline const CASE_IGNORABLES = memory.data<u8>([
|
|
292
|
-
18,16,19,20,21,22,23,24,25,26,27,28,29,30,31,32,
|
|
293
|
-
33,16,16,34,16,16,16,35,36,37,38,39,40,41,16,42,
|
|
294
|
-
43,16,16,16,16,16,16,16,16,16,16,16,44,45,46,16,
|
|
295
|
-
47,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
296
|
-
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
297
|
-
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
298
|
-
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
299
|
-
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
300
|
-
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
301
|
-
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
302
|
-
48,16,16,16,49,16,50,51,52,53,54,55,16,16,16,16,
|
|
303
|
-
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
304
|
-
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
305
|
-
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
306
|
-
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
307
|
-
16,16,16,16,16,16,16,16,16,16,16,56,16,16,57,58,
|
|
308
|
-
16,59,60,61,16,16,16,16,16,16,62,16,16,63,64,65,
|
|
309
|
-
66,67,68,69,70,71,72,73,74,75,76,16,77,78,79,16,
|
|
310
|
-
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
311
|
-
16,16,16,16,80,16,16,16,16,16,16,16,16,16,16,16,
|
|
312
|
-
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
313
|
-
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
314
|
-
16,16,16,16,16,16,16,16,16,16,81,82,16,16,16,83,
|
|
315
|
-
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
316
|
-
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
317
|
-
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
318
|
-
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
319
|
-
16,16,16,16,16,16,16,16,16,16,16,16,84,16,16,16,
|
|
320
|
-
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
321
|
-
16,85,86,16,16,16,16,16,16,16,87,16,16,16,16,16,
|
|
322
|
-
88,89,90,16,16,16,16,16,91,92,16,16,16,16,16,16,
|
|
323
|
-
16,16,16,93,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
324
|
-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
325
|
-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
326
|
-
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
|
|
327
|
-
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
|
|
328
|
-
0,0,0,0,128,64,0,4,0,0,0,64,1,0,0,0,0,0,0,0,0,161,144,1,
|
|
329
|
-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
330
|
-
0,0,0,0,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
|
|
331
|
-
255,255,255,255,255,255,48,4,176,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
332
|
-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,248,3,0,0,0,0,0,0,
|
|
333
|
-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,130,0,0,0,0,
|
|
334
|
-
0,0,254,255,255,255,255,191,182,0,0,0,0,0,16,0,63,0,255,23,0,0,0,0,
|
|
335
|
-
1,248,255,255,0,0,1,0,0,0,0,0,0,0,0,0,0,0,192,191,255,61,0,0,
|
|
336
|
-
0,128,2,0,0,0,255,255,255,7,0,0,0,0,0,0,0,0,0,0,192,255,1,0,
|
|
337
|
-
0,0,0,0,0,248,63,36,0,0,192,255,255,63,0,0,0,0,0,14,0,0,0,0,
|
|
338
|
-
0,0,0,0,0,0,0,0,0,0,248,255,255,255,255,255,7,0,0,0,0,0,0,20,
|
|
339
|
-
254,33,254,0,12,0,2,0,2,0,0,0,0,0,0,16,30,32,0,0,12,0,0,64,
|
|
340
|
-
6,0,0,0,0,0,0,16,134,57,2,0,0,0,35,0,6,0,0,0,0,0,0,16,
|
|
341
|
-
190,33,0,0,12,0,0,252,2,0,0,0,0,0,0,144,30,32,96,0,12,0,0,0,
|
|
342
|
-
4,0,0,0,0,0,0,0,1,32,0,0,0,0,0,0,17,0,0,0,0,0,0,192,
|
|
343
|
-
193,61,96,0,12,0,0,0,2,0,0,0,0,0,0,144,64,48,0,0,12,0,0,0,
|
|
344
|
-
3,0,0,0,0,0,0,24,30,32,0,0,12,0,0,0,2,0,0,0,0,0,0,0,
|
|
345
|
-
0,4,92,0,0,0,0,0,0,0,0,0,0,0,242,7,192,127,0,0,0,0,0,0,
|
|
346
|
-
0,0,0,0,0,0,242,31,64,63,0,0,0,0,0,0,0,0,0,3,0,0,160,2,
|
|
347
|
-
0,0,0,0,0,0,254,127,223,224,255,254,255,255,255,31,64,0,0,0,0,0,0,0,
|
|
348
|
-
0,0,0,0,0,224,253,102,0,0,0,195,1,0,30,0,100,32,0,32,0,0,0,0,
|
|
349
|
-
0,0,0,0,0,0,0,16,0,0,0,0,0,0,0,0,0,0,0,224,0,0,0,0,
|
|
350
|
-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,28,0,0,0,28,0,
|
|
351
|
-
0,0,12,0,0,0,12,0,0,0,0,0,0,0,176,63,64,254,143,32,0,0,0,0,
|
|
352
|
-
0,120,0,0,0,0,0,0,8,0,0,0,0,0,0,0,96,0,0,0,0,2,0,0,
|
|
353
|
-
0,0,0,0,0,0,0,0,0,0,0,0,135,1,4,14,0,0,0,0,0,0,0,0,
|
|
354
|
-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,9,0,0,0,0,
|
|
355
|
-
0,0,64,127,229,31,248,159,0,0,0,0,128,0,255,255,1,0,0,0,0,0,0,0,
|
|
356
|
-
15,0,0,0,0,0,208,23,4,0,0,0,0,248,15,0,3,0,0,0,60,59,0,0,
|
|
357
|
-
0,0,0,0,64,163,3,0,0,0,0,0,0,240,207,0,0,0,0,0,0,0,0,63,
|
|
358
|
-
0,0,0,0,0,0,0,0,0,0,247,255,253,33,16,3,0,0,0,0,0,240,255,255,
|
|
359
|
-
255,255,255,255,255,7,0,1,0,0,0,248,255,255,255,255,255,255,255,255,255,255,255,251,
|
|
360
|
-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,160,
|
|
361
|
-
3,224,0,224,0,224,0,96,0,248,0,3,144,124,0,0,0,0,0,0,223,255,2,128,
|
|
362
|
-
0,0,255,31,0,0,0,0,0,0,255,255,255,255,1,0,0,0,0,0,0,0,0,0,
|
|
363
|
-
0,0,0,0,0,0,0,48,0,0,0,0,0,0,0,0,0,0,0,0,0,128,3,0,
|
|
364
|
-
0,0,0,0,0,0,0,0,0,0,0,0,0,128,0,128,0,0,0,0,0,0,0,0,
|
|
365
|
-
0,0,0,0,255,255,255,255,0,0,0,0,0,128,0,0,0,0,0,0,0,0,0,0,
|
|
366
|
-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,0,0,0,0,60,62,8,
|
|
367
|
-
0,0,0,0,0,0,0,0,0,0,0,126,0,0,0,0,0,0,0,0,0,0,0,112,
|
|
368
|
-
0,0,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
369
|
-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
370
|
-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,63,0,16,0,0,0,0,0,0,
|
|
371
|
-
0,0,0,0,0,128,247,191,0,0,0,240,0,0,0,0,0,0,0,0,0,0,3,0,
|
|
372
|
-
255,255,255,255,3,0,0,0,0,0,0,0,0,0,1,0,0,7,0,0,0,0,0,0,
|
|
373
|
-
0,0,0,0,0,0,0,3,68,8,0,0,96,16,0,0,0,0,0,0,0,0,0,0,
|
|
374
|
-
0,0,0,0,0,0,0,0,48,0,0,0,255,255,3,128,0,0,0,0,192,63,0,0,
|
|
375
|
-
128,255,3,0,0,0,0,0,7,0,0,0,0,0,200,51,0,128,0,0,96,0,0,0,
|
|
376
|
-
0,0,0,0,0,126,102,0,8,16,0,0,0,0,1,16,0,0,0,0,0,0,157,193,
|
|
377
|
-
2,0,0,32,0,48,88,0,0,0,0,0,0,0,0,0,0,0,0,248,0,14,0,0,
|
|
378
|
-
0,0,0,0,0,0,0,0,0,0,0,0,32,33,0,0,0,0,0,64,0,0,0,0,
|
|
379
|
-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,252,255,3,0,0,0,0,0,0,0,
|
|
380
|
-
255,255,8,0,255,255,0,0,0,0,36,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
381
|
-
0,0,0,0,0,0,0,128,128,64,0,4,0,0,0,64,1,0,0,0,0,0,1,0,
|
|
382
|
-
0,0,0,192,0,0,0,0,0,0,0,0,8,0,0,14,0,0,0,0,0,0,0,0,
|
|
383
|
-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,
|
|
384
|
-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
385
|
-
0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,7,
|
|
386
|
-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,110,240,0,0,0,0,0,135,
|
|
387
|
-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,96,0,0,0,
|
|
388
|
-
0,0,0,0,240,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
389
|
-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
390
|
-
0,0,0,0,0,24,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
391
|
-
192,255,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
392
|
-
2,0,0,0,0,0,0,255,127,0,0,0,0,0,0,128,3,0,0,0,0,0,120,38,
|
|
393
|
-
0,32,0,0,0,0,0,0,7,0,0,0,128,239,31,0,0,0,0,0,0,0,8,0,
|
|
394
|
-
3,0,0,0,0,0,192,127,0,158,0,0,0,0,0,0,0,0,0,0,0,128,211,64,
|
|
395
|
-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,248,7,0,0,
|
|
396
|
-
3,0,0,0,0,0,0,24,1,0,0,0,192,31,31,0,0,0,0,0,0,0,0,0,
|
|
397
|
-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,92,0,0,64,0,0,0,0,
|
|
398
|
-
0,0,0,0,0,0,248,133,13,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
399
|
-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,60,176,1,0,0,48,0,0,0,0,
|
|
400
|
-
0,0,0,0,0,0,248,167,1,0,0,0,0,0,0,0,0,0,0,0,0,40,191,0,
|
|
401
|
-
0,0,0,0,0,0,0,0,0,0,0,224,188,15,0,0,0,0,0,0,0,0,0,0,
|
|
402
|
-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,255,6,
|
|
403
|
-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
404
|
-
0,0,0,0,0,0,0,88,8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
405
|
-
0,0,240,12,1,0,0,0,254,7,0,0,0,0,248,121,128,0,126,14,0,0,0,0,
|
|
406
|
-
0,252,127,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,127,191,
|
|
407
|
-
0,0,0,0,0,0,0,0,0,0,252,255,255,252,109,0,0,0,0,0,0,0,0,0,
|
|
408
|
-
0,0,0,0,0,0,126,180,191,0,0,0,0,0,0,0,0,0,163,0,0,0,0,0,
|
|
409
|
-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
410
|
-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,0,0,0,0,0,0,0,255,1,
|
|
411
|
-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
412
|
-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
413
|
-
0,0,0,0,0,0,31,0,0,0,0,0,0,0,127,0,15,0,0,0,0,0,0,0,
|
|
414
|
-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
415
|
-
0,128,0,0,0,0,0,0,0,128,255,255,0,0,0,0,0,0,0,0,27,0,0,0,
|
|
416
|
-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,96,15,0,0,0,
|
|
417
|
-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,3,248,255,
|
|
418
|
-
231,15,0,0,0,60,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
419
|
-
28,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
420
|
-
255,255,255,255,255,255,127,248,255,255,255,255,255,31,32,0,16,0,0,248,254,255,0,0,
|
|
421
|
-
0,0,0,0,0,0,0,0,127,255,255,249,219,7,0,0,0,0,0,0,0,0,0,0,
|
|
422
|
-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,63,
|
|
423
|
-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
424
|
-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
425
|
-
0,0,0,0,0,240,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
426
|
-
0,0,0,0,0,0,0,0,0,0,127,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
427
|
-
240,15,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
428
|
-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
429
|
-
0,0,0,0,0,0,0,248
|
|
430
|
-
]);
|
|
431
|
-
|
|
432
|
-
// @ts-ignore: decorator
|
|
433
|
-
@lazy @inline const LOWER127 = memory.data<u8>([
|
|
434
|
-
0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,
|
|
435
|
-
16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,
|
|
436
|
-
32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,
|
|
437
|
-
48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,
|
|
438
|
-
64,
|
|
439
|
-
97,98,99,100,101,102,103,104,105,106,107,108,109,
|
|
440
|
-
110,111,112,113,114,115,116,117,118,119,120,121,122,
|
|
441
|
-
91,92,93,94,95,96,
|
|
442
|
-
97,98,99,100,101,102,103,104,105,106,107,108,109,
|
|
443
|
-
110,111,112,113,114,115,116,117,118,119,120,121,122,
|
|
444
|
-
123,124,125,126,127
|
|
445
|
-
]);
|
|
446
|
-
|
|
447
|
-
// @ts-ignore: decorator
|
|
448
|
-
@lazy @inline const UPPER127 = memory.data<u8>([
|
|
449
|
-
0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,
|
|
450
|
-
16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,
|
|
451
|
-
32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,
|
|
452
|
-
48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,
|
|
453
|
-
64,
|
|
454
|
-
65,66,67,68,69,70,71,72,73,74,75,76,77,
|
|
455
|
-
78,79,80,81,82,83,84,85,86,87,88,89,90,
|
|
456
|
-
91,92,93,94,95,96,
|
|
457
|
-
65,66,67,68,69,70,71,72,73,74,75,76,77,
|
|
458
|
-
78,79,80,81,82,83,84,85,86,87,88,89,90,
|
|
459
|
-
123,124,125,126,127
|
|
460
|
-
]);
|
|
461
|
-
|
|
462
|
-
// 23 * 8 = 184 bytes
|
|
463
|
-
// @ts-ignore: decorator
|
|
464
|
-
@lazy @inline const POWERS10 = memory.data<f64>([
|
|
465
|
-
1e00, 1e01, 1e02, 1e03, 1e04, 1e05, 1e06, 1e07, 1e08, 1e09,
|
|
466
|
-
1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19,
|
|
467
|
-
1e20, 1e21, 1e22
|
|
468
|
-
]);
|
|
469
|
-
|
|
470
|
-
// @ts-ignore: decorator
|
|
471
|
-
@inline
|
|
472
|
-
export const enum CharCode {
|
|
473
|
-
PERCENT = 0x25,
|
|
474
|
-
PLUS = 0x2B,
|
|
475
|
-
MINUS = 0x2D,
|
|
476
|
-
DOT = 0x2E,
|
|
477
|
-
_0 = 0x30,
|
|
478
|
-
_1 = 0x31,
|
|
479
|
-
_2 = 0x32,
|
|
480
|
-
_3 = 0x33,
|
|
481
|
-
_4 = 0x34,
|
|
482
|
-
_5 = 0x35,
|
|
483
|
-
_6 = 0x36,
|
|
484
|
-
_7 = 0x37,
|
|
485
|
-
_8 = 0x38,
|
|
486
|
-
_9 = 0x39,
|
|
487
|
-
A = 0x41,
|
|
488
|
-
B = 0x42,
|
|
489
|
-
E = 0x45,
|
|
490
|
-
I = 0x49,
|
|
491
|
-
N = 0x4E,
|
|
492
|
-
O = 0x4F,
|
|
493
|
-
X = 0x58,
|
|
494
|
-
Z = 0x5A,
|
|
495
|
-
a = 0x61,
|
|
496
|
-
b = 0x62,
|
|
497
|
-
e = 0x65,
|
|
498
|
-
n = 0x6E,
|
|
499
|
-
o = 0x6F,
|
|
500
|
-
u = 0x75,
|
|
501
|
-
x = 0x78,
|
|
502
|
-
z = 0x7A
|
|
503
|
-
}
|
|
504
|
-
|
|
505
|
-
// @ts-ignore: decorator
|
|
506
|
-
@inline
|
|
507
|
-
export function isAscii(c: u32): bool {
|
|
508
|
-
return !(c >> 7);
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
// @ts-ignore: decorator
|
|
512
|
-
@inline
|
|
513
|
-
export function isLower8(c: u32): bool {
|
|
514
|
-
return c - CharCode.a < 26;
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
// @ts-ignore: decorator
|
|
518
|
-
@inline
|
|
519
|
-
export function isUpper8(c: u32): bool {
|
|
520
|
-
return c - CharCode.A < 26;
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
export function isSpace(c: u32): bool {
|
|
524
|
-
if (c < 0x1680) { // < <LS> (1)
|
|
525
|
-
// <SP>, <TAB>, <LF>, <VT>, <FF>, <CR> and <NBSP>
|
|
526
|
-
// (c == 0x20 || c == 0xA0) was optimized to (c | 0x80) == 0xA0
|
|
527
|
-
return ((c | 0x80) == 0xA0) || (c - 0x09 <= 0x0D - 0x09);
|
|
528
|
-
}
|
|
529
|
-
if (c - 0x2000 <= 0x200A - 0x2000) return true;
|
|
530
|
-
switch (c) {
|
|
531
|
-
case 0x1680: // <LS> (1)
|
|
532
|
-
case 0x2028: // <LS> (2)
|
|
533
|
-
case 0x2029: // <PS>
|
|
534
|
-
case 0x202F: // <NNS>
|
|
535
|
-
case 0x205F: // <MMSP>
|
|
536
|
-
case 0x3000: // <IS>
|
|
537
|
-
case 0xFEFF: return true; // <ZWNBSP>
|
|
538
|
-
}
|
|
539
|
-
return false;
|
|
540
|
-
}
|
|
541
|
-
|
|
542
|
-
export function isAlpha(c: u32): bool {
|
|
543
|
-
if (isAscii(c)) return (c | 32) - CharCode.a < 26;
|
|
544
|
-
if (c < 0x20000) {
|
|
545
|
-
// @ts-ignore: cast
|
|
546
|
-
return stagedBinaryLookup(ALPHA_TABLE, c);
|
|
547
|
-
}
|
|
548
|
-
return c < 0x2FFFE;
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
// @ts-ignore: decorator
|
|
552
|
-
@inline
|
|
553
|
-
export function isCased(c: u32): bool {
|
|
554
|
-
// @ts-ignore: cast
|
|
555
|
-
return c < 0x1F18A && stagedBinaryLookup(CASED, c);
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
// @ts-ignore: decorator
|
|
559
|
-
@inline
|
|
560
|
-
export function isCaseIgnorable(c: u32): bool {
|
|
561
|
-
// @ts-ignore: cast
|
|
562
|
-
return c < 0xE01F0 && stagedBinaryLookup(CASE_IGNORABLES, c);
|
|
563
|
-
}
|
|
564
|
-
|
|
565
|
-
// @ts-ignore: decorator
|
|
566
|
-
@inline
|
|
567
|
-
export function isFinalSigma(buffer: usize, index: isize, len: isize): bool {
|
|
568
|
-
const lookaheadLimit = 30; // max lookahead limit
|
|
569
|
-
let found = false;
|
|
570
|
-
let pos = index;
|
|
571
|
-
let minPos = max(0, pos - lookaheadLimit);
|
|
572
|
-
while (pos > minPos) {
|
|
573
|
-
let c = codePointBefore(buffer, pos);
|
|
574
|
-
if (!isCaseIgnorable(c)) {
|
|
575
|
-
if (isCased(c)) {
|
|
576
|
-
found = true;
|
|
577
|
-
} else {
|
|
578
|
-
return false;
|
|
579
|
-
}
|
|
580
|
-
}
|
|
581
|
-
pos -= isize(c >= 0x10000) + 1;
|
|
582
|
-
}
|
|
583
|
-
if (!found) return false;
|
|
584
|
-
pos = index + 1;
|
|
585
|
-
let maxPos = min(pos + lookaheadLimit, len);
|
|
586
|
-
while (pos < maxPos) {
|
|
587
|
-
let c = <u32>load<u16>(buffer + (pos << 1));
|
|
588
|
-
if (u32((c & 0xFC00) == 0xD800) & u32(pos + 1 != len)) {
|
|
589
|
-
let c1 = <u32>load<u16>(buffer + (pos << 1), 2);
|
|
590
|
-
if ((c1 & 0xFC00) == 0xDC00) {
|
|
591
|
-
c = (c - 0xD800 << 10) + (c1 - 0xDC00) + 0x10000;
|
|
592
|
-
}
|
|
593
|
-
}
|
|
594
|
-
if (!isCaseIgnorable(c)) {
|
|
595
|
-
return !isCased(c);
|
|
596
|
-
}
|
|
597
|
-
pos += isize(c >= 0x10000) + 1;
|
|
598
|
-
}
|
|
599
|
-
return true;
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
// @ts-ignore: decorator
|
|
603
|
-
@inline
|
|
604
|
-
function codePointBefore(buffer: usize, index: isize): i32 {
|
|
605
|
-
if (index <= 0) return -1;
|
|
606
|
-
let c = <u32>load<u16>(buffer + (index - 1 << 1));
|
|
607
|
-
if (u32((c & 0xFC00) == 0xDC00) & u32(index - 2 >= 0)) {
|
|
608
|
-
let c1 = <u32>load<u16>(buffer + (index - 2 << 1));
|
|
609
|
-
if ((c1 & 0xFC00) == 0xD800) {
|
|
610
|
-
return ((c1 & 0x3FF) << 10) + (c & 0x3FF) + 0x10000;
|
|
611
|
-
}
|
|
612
|
-
}
|
|
613
|
-
return (c & 0xF800) == 0xD800 ? 0xFFFD : c;
|
|
614
|
-
}
|
|
615
|
-
|
|
616
|
-
// Search routine for two-staged lookup tables
|
|
617
|
-
function stagedBinaryLookup(table: usize, c: u32): bool {
|
|
618
|
-
return <bool>((load<u8>(table + (<u32>load<u8>(table + (c >>> 8)) << 5) + ((c & 255) >> 3)) >>> (c & 7)) & 1);
|
|
619
|
-
}
|
|
620
|
-
|
|
621
|
-
export function compareImpl(str1: string, index1: usize, str2: string, index2: usize, len: usize): i32 {
|
|
622
|
-
let ptr1 = changetype<usize>(str1) + (index1 << 1);
|
|
623
|
-
let ptr2 = changetype<usize>(str2) + (index2 << 1);
|
|
624
|
-
if (ASC_SHRINK_LEVEL < 2) {
|
|
625
|
-
if (len >= 4 && !((ptr1 & 7) | (ptr2 & 7))) {
|
|
626
|
-
do {
|
|
627
|
-
if (load<u64>(ptr1) != load<u64>(ptr2)) break;
|
|
628
|
-
ptr1 += 8;
|
|
629
|
-
ptr2 += 8;
|
|
630
|
-
len -= 4;
|
|
631
|
-
} while (len >= 4);
|
|
632
|
-
}
|
|
633
|
-
}
|
|
634
|
-
while (len--) {
|
|
635
|
-
let a = <i32>load<u16>(ptr1);
|
|
636
|
-
let b = <i32>load<u16>(ptr2);
|
|
637
|
-
if (a != b) return a - b;
|
|
638
|
-
ptr1 += 2;
|
|
639
|
-
ptr2 += 2;
|
|
640
|
-
}
|
|
641
|
-
return 0;
|
|
642
|
-
}
|
|
643
|
-
|
|
644
|
-
// @ts-ignore: decorator
|
|
645
|
-
@inline
|
|
646
|
-
export function toLower8(c: u32): u32 {
|
|
647
|
-
if (ASC_SHRINK_LEVEL > 0) {
|
|
648
|
-
return c | u32(isUpper8(c)) << 5;
|
|
649
|
-
} else {
|
|
650
|
-
return <u32>load<u8>(LOWER127 + c);
|
|
651
|
-
}
|
|
652
|
-
}
|
|
653
|
-
|
|
654
|
-
// @ts-ignore: decorator
|
|
655
|
-
@inline
|
|
656
|
-
export function toUpper8(c: u32): u32 {
|
|
657
|
-
if (ASC_SHRINK_LEVEL > 0) {
|
|
658
|
-
return c & ~(u32(isLower8(c)) << 5);
|
|
659
|
-
} else {
|
|
660
|
-
return <u32>load<u8>(UPPER127 + c);
|
|
661
|
-
}
|
|
662
|
-
}
|
|
663
|
-
|
|
664
|
-
/** Parses a string to an integer (usually), using the specified radix. */
|
|
665
|
-
export function strtol<T>(str: string, radix: i32 = 0): T {
|
|
666
|
-
let len = str.length;
|
|
667
|
-
if (!len) {
|
|
668
|
-
if (isFloat<T>()) {
|
|
669
|
-
// @ts-ignore: cast
|
|
670
|
-
return <T>NaN;
|
|
671
|
-
} else {
|
|
672
|
-
// @ts-ignore: cast
|
|
673
|
-
return <T>0;
|
|
674
|
-
}
|
|
675
|
-
}
|
|
676
|
-
|
|
677
|
-
let ptr = changetype<usize>(str) /* + HEAD -> offset */;
|
|
678
|
-
let code = <u32>load<u16>(ptr);
|
|
679
|
-
|
|
680
|
-
// trim white spaces
|
|
681
|
-
while (isSpace(code)) {
|
|
682
|
-
code = <u32>load<u16>(ptr += 2);
|
|
683
|
-
--len;
|
|
684
|
-
}
|
|
685
|
-
// determine sign
|
|
686
|
-
// @ts-ignore
|
|
687
|
-
let sign: T = 1;
|
|
688
|
-
if (code == CharCode.MINUS || code == CharCode.PLUS) {
|
|
689
|
-
if (!--len) {
|
|
690
|
-
if (isFloat<T>()) {
|
|
691
|
-
// @ts-ignore: cast
|
|
692
|
-
return <T>NaN;
|
|
693
|
-
} else {
|
|
694
|
-
// @ts-ignore: cast
|
|
695
|
-
return <T>0;
|
|
696
|
-
}
|
|
697
|
-
}
|
|
698
|
-
if (code == CharCode.MINUS) {
|
|
699
|
-
// @ts-ignore: type
|
|
700
|
-
sign = -1;
|
|
701
|
-
}
|
|
702
|
-
code = <u32>load<u16>(ptr += 2);
|
|
703
|
-
}
|
|
704
|
-
|
|
705
|
-
// See https://tc39.es/ecma262/#sec-parseint-string-radix
|
|
706
|
-
if (radix) {
|
|
707
|
-
if (radix < 2 || radix > 36) {
|
|
708
|
-
if (isFloat<T>()) {
|
|
709
|
-
// @ts-ignore: cast
|
|
710
|
-
return <T>NaN;
|
|
711
|
-
} else {
|
|
712
|
-
// @ts-ignore: cast
|
|
713
|
-
return <T>0;
|
|
714
|
-
}
|
|
715
|
-
}
|
|
716
|
-
// handle case as parseInt("0xFF", 16) by spec
|
|
717
|
-
if (radix == 16) {
|
|
718
|
-
if (
|
|
719
|
-
len > 2 &&
|
|
720
|
-
code == CharCode._0 &&
|
|
721
|
-
(<u32>load<u16>(ptr, 2) | 32) == CharCode.x
|
|
722
|
-
) {
|
|
723
|
-
ptr += 4; len -= 2;
|
|
724
|
-
}
|
|
725
|
-
}
|
|
726
|
-
} else {
|
|
727
|
-
// determine radix by literal prefix
|
|
728
|
-
if (code == CharCode._0 && len > 2) {
|
|
729
|
-
switch (<u32>load<u16>(ptr, 2) | 32) {
|
|
730
|
-
case CharCode.b: {
|
|
731
|
-
ptr += 4; len -= 2;
|
|
732
|
-
radix = 2;
|
|
733
|
-
break;
|
|
734
|
-
}
|
|
735
|
-
case CharCode.o: {
|
|
736
|
-
ptr += 4; len -= 2;
|
|
737
|
-
radix = 8;
|
|
738
|
-
break;
|
|
739
|
-
}
|
|
740
|
-
case CharCode.x: {
|
|
741
|
-
ptr += 4; len -= 2;
|
|
742
|
-
radix = 16;
|
|
743
|
-
break;
|
|
744
|
-
}
|
|
745
|
-
}
|
|
746
|
-
}
|
|
747
|
-
if (!radix) radix = 10;
|
|
748
|
-
}
|
|
749
|
-
|
|
750
|
-
// calculate value
|
|
751
|
-
// @ts-ignore: type
|
|
752
|
-
let num: T = 0;
|
|
753
|
-
let initial = len - 1;
|
|
754
|
-
while (len--) {
|
|
755
|
-
code = <u32>load<u16>(ptr);
|
|
756
|
-
if (code - CharCode._0 < 10) {
|
|
757
|
-
code -= CharCode._0;
|
|
758
|
-
} else if (code - CharCode.A <= <u32>(CharCode.Z - CharCode.A)) {
|
|
759
|
-
code -= CharCode.A - 10;
|
|
760
|
-
} else if (code - CharCode.a <= <u32>(CharCode.z - CharCode.a)) {
|
|
761
|
-
code -= CharCode.a - 10;
|
|
762
|
-
}
|
|
763
|
-
if (code >= <u32>radix) {
|
|
764
|
-
if (initial == len) {
|
|
765
|
-
if (isFloat<T>()) {
|
|
766
|
-
// @ts-ignore: cast
|
|
767
|
-
return <T>NaN;
|
|
768
|
-
} else {
|
|
769
|
-
// @ts-ignore: cast
|
|
770
|
-
return <T>0;
|
|
771
|
-
}
|
|
772
|
-
}
|
|
773
|
-
break;
|
|
774
|
-
}
|
|
775
|
-
// @ts-ignore: type
|
|
776
|
-
num = num * radix + code;
|
|
777
|
-
ptr += 2;
|
|
778
|
-
}
|
|
779
|
-
// @ts-ignore: type
|
|
780
|
-
return sign * num;
|
|
781
|
-
}
|
|
782
|
-
|
|
783
|
-
export function strtod(str: string): f64 {
|
|
784
|
-
let len = str.length;
|
|
785
|
-
if (!len) return NaN;
|
|
786
|
-
|
|
787
|
-
let ptr = changetype<usize>(str);
|
|
788
|
-
let code = <u32>load<u16>(ptr);
|
|
789
|
-
|
|
790
|
-
let sign = 1.0;
|
|
791
|
-
// skip white spaces
|
|
792
|
-
while (len && isSpace(code)) {
|
|
793
|
-
code = <u32>load<u16>(ptr += 2);
|
|
794
|
-
--len;
|
|
795
|
-
}
|
|
796
|
-
if (!len) return NaN;
|
|
797
|
-
|
|
798
|
-
// try parse '-' or '+'
|
|
799
|
-
if (code == CharCode.MINUS) {
|
|
800
|
-
if (!--len) return NaN;
|
|
801
|
-
code = <u32>load<u16>(ptr += 2);
|
|
802
|
-
sign = -1;
|
|
803
|
-
} else if (code == CharCode.PLUS) {
|
|
804
|
-
if (!--len) return NaN;
|
|
805
|
-
code = <u32>load<u16>(ptr += 2);
|
|
806
|
-
}
|
|
807
|
-
|
|
808
|
-
// try parse Infinity
|
|
809
|
-
if (len >= 8 && code == CharCode.I) {
|
|
810
|
-
if (
|
|
811
|
-
load<u64>(ptr, 0) == 0x690066006E0049 && // ifnI
|
|
812
|
-
load<u64>(ptr, 8) == 0x7900740069006E // ytin
|
|
813
|
-
) {
|
|
814
|
-
return Infinity * sign;
|
|
815
|
-
}
|
|
816
|
-
return NaN;
|
|
817
|
-
}
|
|
818
|
-
// validate next symbol
|
|
819
|
-
if (code != CharCode.DOT && <u32>(code - CharCode._0) >= 10) {
|
|
820
|
-
return NaN;
|
|
821
|
-
}
|
|
822
|
-
let savedPtr = ptr;
|
|
823
|
-
// skip zeros
|
|
824
|
-
while (code == CharCode._0) {
|
|
825
|
-
code = <u32>load<u16>(ptr += 2);
|
|
826
|
-
--len;
|
|
827
|
-
}
|
|
828
|
-
if (len <= 0) return 0.0 * sign;
|
|
829
|
-
const capacity = 19; // int(64 * 0.3010)
|
|
830
|
-
let pointed = false;
|
|
831
|
-
let consumed = 0;
|
|
832
|
-
let position = 0;
|
|
833
|
-
let x: u64 = 0;
|
|
834
|
-
if (code == CharCode.DOT) {
|
|
835
|
-
let noDigits = !(savedPtr - ptr);
|
|
836
|
-
ptr += 2; --len;
|
|
837
|
-
if (!len && noDigits) return NaN;
|
|
838
|
-
for (pointed = true; (code = <u32>load<u16>(ptr)) == CharCode._0; --position, ptr += 2) --len;
|
|
839
|
-
if (len <= 0) return 0.0 * sign;
|
|
840
|
-
if (!position && noDigits && code - CharCode._0 >= 10) return NaN;
|
|
841
|
-
}
|
|
842
|
-
for (let digit = code - CharCode._0; digit < 10 || (code == CharCode.DOT && !pointed); digit = code - CharCode._0) {
|
|
843
|
-
if (digit < 10) {
|
|
844
|
-
x = consumed < capacity ? 10 * x + digit : x | u64(!!digit);
|
|
845
|
-
++consumed;
|
|
846
|
-
} else {
|
|
847
|
-
position = consumed;
|
|
848
|
-
pointed = true;
|
|
849
|
-
}
|
|
850
|
-
if (!--len) break;
|
|
851
|
-
code = <u32>load<u16>(ptr += 2);
|
|
852
|
-
}
|
|
853
|
-
|
|
854
|
-
if (!pointed) position = consumed;
|
|
855
|
-
return copysign<f64>(scientific(x, position - min(capacity, consumed) + parseExp(ptr, len)), sign);
|
|
856
|
-
}
|
|
857
|
-
|
|
858
|
-
export function strtob(str: string): bool {
|
|
859
|
-
let size: usize = str.length << 1;
|
|
860
|
-
let offset: usize = 0;
|
|
861
|
-
if (size > 8) {
|
|
862
|
-
// try trim end whitespaces first
|
|
863
|
-
while (size && isSpace(load<u16>(changetype<usize>(str) + size - 2))) size -= 2;
|
|
864
|
-
if (size > 8) {
|
|
865
|
-
// trim start whitespaces
|
|
866
|
-
while (offset < size && isSpace(load<u16>(changetype<usize>(str) + offset))) offset += 2;
|
|
867
|
-
size -= offset;
|
|
868
|
-
}
|
|
869
|
-
}
|
|
870
|
-
if (size != 8) return false;
|
|
871
|
-
// "true" represents as \00\e\00\u\00\e\00\t (00 65 00 75 00 72 00 74)
|
|
872
|
-
return load<u64>(changetype<usize>(str) + offset) == 0x0065_0075_0072_0074;
|
|
873
|
-
}
|
|
874
|
-
|
|
875
|
-
export function joinBooleanArray(dataStart: usize, length: i32, separator: string): string {
|
|
876
|
-
let lastIndex = length - 1;
|
|
877
|
-
if (lastIndex < 0) return "";
|
|
878
|
-
if (!lastIndex) return select("true", "false", load<bool>(dataStart));
|
|
879
|
-
|
|
880
|
-
let sepLen = separator.length;
|
|
881
|
-
let valueLen = 5; // max possible length of element len("false")
|
|
882
|
-
let estLen = (valueLen + sepLen) * lastIndex + valueLen;
|
|
883
|
-
let result = changetype<string>(__new(estLen << 1, idof<string>()));
|
|
884
|
-
let offset = 0;
|
|
885
|
-
let value: bool;
|
|
886
|
-
for (let i = 0; i < lastIndex; ++i) {
|
|
887
|
-
value = load<bool>(dataStart + i);
|
|
888
|
-
valueLen = 4 + i32(!value);
|
|
889
|
-
memory.copy(
|
|
890
|
-
changetype<usize>(result) + (<usize>offset << 1),
|
|
891
|
-
changetype<usize>(select("true", "false", value)),
|
|
892
|
-
<usize>valueLen << 1
|
|
893
|
-
);
|
|
894
|
-
offset += valueLen;
|
|
895
|
-
if (sepLen) {
|
|
896
|
-
memory.copy(
|
|
897
|
-
changetype<usize>(result) + (<usize>offset << 1),
|
|
898
|
-
changetype<usize>(separator),
|
|
899
|
-
<usize>sepLen << 1
|
|
900
|
-
);
|
|
901
|
-
offset += sepLen;
|
|
902
|
-
}
|
|
903
|
-
}
|
|
904
|
-
value = load<bool>(dataStart + <usize>lastIndex);
|
|
905
|
-
valueLen = 4 + i32(!value);
|
|
906
|
-
memory.copy(
|
|
907
|
-
changetype<usize>(result) + (<usize>offset << 1),
|
|
908
|
-
changetype<usize>(select("true", "false", value)),
|
|
909
|
-
valueLen << 1
|
|
910
|
-
);
|
|
911
|
-
offset += valueLen;
|
|
912
|
-
|
|
913
|
-
if (estLen > offset) return result.substring(0, offset);
|
|
914
|
-
return result;
|
|
915
|
-
}
|
|
916
|
-
|
|
917
|
-
export function joinIntegerArray<T>(dataStart: usize, length: i32, separator: string): string {
|
|
918
|
-
let lastIndex = length - 1;
|
|
919
|
-
if (lastIndex < 0) return "";
|
|
920
|
-
if (!lastIndex) {
|
|
921
|
-
let value = load<T>(dataStart);
|
|
922
|
-
if (isSigned<T>()) {
|
|
923
|
-
if (sizeof<T>() <= 4) {
|
|
924
|
-
// @ts-ignore: type
|
|
925
|
-
return changetype<string>(itoa32(<i32>value, 10));
|
|
926
|
-
} else {
|
|
927
|
-
// @ts-ignore: type
|
|
928
|
-
return changetype<string>(itoa64(<i32>value, 10));
|
|
929
|
-
}
|
|
930
|
-
} else {
|
|
931
|
-
if (sizeof<T>() <= 4) {
|
|
932
|
-
// @ts-ignore: type
|
|
933
|
-
return changetype<string>(utoa32(<u32>value, 10));
|
|
934
|
-
} else {
|
|
935
|
-
// @ts-ignore: type
|
|
936
|
-
return changetype<string>(utoa64(<u64>value, 10));
|
|
937
|
-
}
|
|
938
|
-
}
|
|
939
|
-
}
|
|
940
|
-
|
|
941
|
-
let sepLen = separator.length;
|
|
942
|
-
const valueLen = (sizeof<T>() <= 4 ? 10 : 20) + i32(isSigned<T>());
|
|
943
|
-
let estLen = (valueLen + sepLen) * lastIndex + valueLen;
|
|
944
|
-
let result = changetype<string>(__new(estLen << 1, idof<string>()));
|
|
945
|
-
let offset = 0;
|
|
946
|
-
let value: T;
|
|
947
|
-
for (let i = 0; i < lastIndex; ++i) {
|
|
948
|
-
value = load<T>(dataStart + (<usize>i << alignof<T>()));
|
|
949
|
-
// @ts-ignore: type
|
|
950
|
-
offset += itoa_buffered<T>(changetype<usize>(result) + (<usize>offset << 1), value);
|
|
951
|
-
if (sepLen) {
|
|
952
|
-
memory.copy(
|
|
953
|
-
changetype<usize>(result) + (<usize>offset << 1),
|
|
954
|
-
changetype<usize>(separator),
|
|
955
|
-
<usize>sepLen << 1
|
|
956
|
-
);
|
|
957
|
-
offset += sepLen;
|
|
958
|
-
}
|
|
959
|
-
}
|
|
960
|
-
value = load<T>(dataStart + (<usize>lastIndex << alignof<T>()));
|
|
961
|
-
// @ts-ignore: type
|
|
962
|
-
offset += itoa_buffered<T>(changetype<usize>(result) + (<usize>offset << 1), value);
|
|
963
|
-
if (estLen > offset) return result.substring(0, offset);
|
|
964
|
-
return result;
|
|
965
|
-
}
|
|
966
|
-
|
|
967
|
-
export function joinFloatArray<T>(dataStart: usize, length: i32, separator: string): string {
|
|
968
|
-
let lastIndex = length - 1;
|
|
969
|
-
if (lastIndex < 0) return "";
|
|
970
|
-
if (!lastIndex) {
|
|
971
|
-
return changetype<string>(dtoa(
|
|
972
|
-
// @ts-ignore: type
|
|
973
|
-
load<T>(dataStart))
|
|
974
|
-
);
|
|
975
|
-
}
|
|
976
|
-
|
|
977
|
-
const valueLen = MAX_DOUBLE_LENGTH;
|
|
978
|
-
let sepLen = separator.length;
|
|
979
|
-
let estLen = (valueLen + sepLen) * lastIndex + valueLen;
|
|
980
|
-
let result = changetype<string>(__new(estLen << 1, idof<string>()));
|
|
981
|
-
let offset = 0;
|
|
982
|
-
let value: T;
|
|
983
|
-
for (let i = 0; i < lastIndex; ++i) {
|
|
984
|
-
value = load<T>(dataStart + (<usize>i << alignof<T>()));
|
|
985
|
-
// @ts-ignore: type
|
|
986
|
-
offset += dtoa_buffered(changetype<usize>(result) + (<usize>offset << 1), value);
|
|
987
|
-
if (sepLen) {
|
|
988
|
-
memory.copy(
|
|
989
|
-
changetype<usize>(result) + (<usize>offset << 1),
|
|
990
|
-
changetype<usize>(separator),
|
|
991
|
-
<usize>sepLen << 1
|
|
992
|
-
);
|
|
993
|
-
offset += sepLen;
|
|
994
|
-
}
|
|
995
|
-
}
|
|
996
|
-
value = load<T>(dataStart + (<usize>lastIndex << alignof<T>()));
|
|
997
|
-
// @ts-ignore: type
|
|
998
|
-
offset += dtoa_buffered(changetype<usize>(result) + (<usize>offset << 1), value);
|
|
999
|
-
if (estLen > offset) return result.substring(0, offset);
|
|
1000
|
-
return result;
|
|
1001
|
-
}
|
|
1002
|
-
|
|
1003
|
-
export function joinStringArray(dataStart: usize, length: i32, separator: string): string {
|
|
1004
|
-
let lastIndex = length - 1;
|
|
1005
|
-
if (lastIndex < 0) return "";
|
|
1006
|
-
if (!lastIndex) {
|
|
1007
|
-
// @ts-ignore: type
|
|
1008
|
-
return load<string>(dataStart) || "";
|
|
1009
|
-
}
|
|
1010
|
-
let estLen = 0;
|
|
1011
|
-
let value: string;
|
|
1012
|
-
for (let i = 0; i < length; ++i) {
|
|
1013
|
-
value = load<string>(dataStart + (<usize>i << alignof<string>()));
|
|
1014
|
-
if (changetype<usize>(value) != 0) estLen += value.length;
|
|
1015
|
-
}
|
|
1016
|
-
let offset = 0;
|
|
1017
|
-
let sepLen = separator.length;
|
|
1018
|
-
let result = changetype<string>(__new((estLen + sepLen * lastIndex) << 1, idof<string>()));
|
|
1019
|
-
for (let i = 0; i < lastIndex; ++i) {
|
|
1020
|
-
value = load<string>(dataStart + (<usize>i << alignof<string>()));
|
|
1021
|
-
if (changetype<usize>(value) != 0) {
|
|
1022
|
-
let valueLen = value.length;
|
|
1023
|
-
memory.copy(
|
|
1024
|
-
changetype<usize>(result) + (<usize>offset << 1),
|
|
1025
|
-
changetype<usize>(value),
|
|
1026
|
-
<usize>valueLen << 1
|
|
1027
|
-
);
|
|
1028
|
-
offset += valueLen;
|
|
1029
|
-
}
|
|
1030
|
-
if (sepLen) {
|
|
1031
|
-
memory.copy(
|
|
1032
|
-
changetype<usize>(result) + (<usize>offset << 1),
|
|
1033
|
-
changetype<usize>(separator),
|
|
1034
|
-
<usize>sepLen << 1
|
|
1035
|
-
);
|
|
1036
|
-
offset += sepLen;
|
|
1037
|
-
}
|
|
1038
|
-
}
|
|
1039
|
-
value = load<string>(dataStart + (<usize>lastIndex << alignof<string>()));
|
|
1040
|
-
if (changetype<usize>(value) != 0) {
|
|
1041
|
-
memory.copy(
|
|
1042
|
-
changetype<usize>(result) + (<usize>offset << 1),
|
|
1043
|
-
changetype<usize>(value),
|
|
1044
|
-
<usize>value.length << 1
|
|
1045
|
-
);
|
|
1046
|
-
}
|
|
1047
|
-
return result;
|
|
1048
|
-
}
|
|
1049
|
-
|
|
1050
|
-
export function joinReferenceArray<T>(dataStart: usize, length: i32, separator: string): string {
|
|
1051
|
-
let lastIndex = length - 1;
|
|
1052
|
-
if (lastIndex < 0) return "";
|
|
1053
|
-
let value: T;
|
|
1054
|
-
if (!lastIndex) {
|
|
1055
|
-
value = load<T>(dataStart);
|
|
1056
|
-
// @ts-ignore: type
|
|
1057
|
-
return value != null ? value.toString() : "";
|
|
1058
|
-
}
|
|
1059
|
-
let result = "";
|
|
1060
|
-
let sepLen = separator.length;
|
|
1061
|
-
for (let i = 0; i < lastIndex; ++i) {
|
|
1062
|
-
value = load<T>(dataStart + (<usize>i << alignof<T>()));
|
|
1063
|
-
// @ts-ignore: type
|
|
1064
|
-
if (value != null) result += value.toString();
|
|
1065
|
-
if (sepLen) result += separator;
|
|
1066
|
-
}
|
|
1067
|
-
value = load<T>(dataStart + (<usize>lastIndex << alignof<T>()));
|
|
1068
|
-
// @ts-ignore: type
|
|
1069
|
-
if (value != null) result += value.toString();
|
|
1070
|
-
return result;
|
|
1071
|
-
}
|
|
1072
|
-
|
|
1073
|
-
// @ts-ignore: decorator
|
|
1074
|
-
@inline
|
|
1075
|
-
function scientific(significand: u64, exp: i32): f64 {
|
|
1076
|
-
if (!significand || exp < -342) return 0;
|
|
1077
|
-
if (exp > 308) return Infinity;
|
|
1078
|
-
// Try use fast path
|
|
1079
|
-
// Use fast path for string-to-double conversion if possible
|
|
1080
|
-
// see http://www.exploringbinary.com/fast-path-decimal-to-floating-point-conversion
|
|
1081
|
-
// Simple integer
|
|
1082
|
-
let significandf = <f64>significand;
|
|
1083
|
-
if (!exp) return significandf;
|
|
1084
|
-
if (exp > 22 && exp <= 22 + 15) {
|
|
1085
|
-
significandf *= pow10(exp - 22);
|
|
1086
|
-
exp = 22;
|
|
1087
|
-
}
|
|
1088
|
-
if (significand <= 9007199254740991 && abs(exp) <= 22) {
|
|
1089
|
-
if (exp > 0) return significandf * pow10(exp);
|
|
1090
|
-
return significandf / pow10(-exp);
|
|
1091
|
-
} else if (exp < 0) {
|
|
1092
|
-
return scaledown(significand, exp);
|
|
1093
|
-
} else {
|
|
1094
|
-
return scaleup(significand, exp);
|
|
1095
|
-
}
|
|
1096
|
-
}
|
|
1097
|
-
|
|
1098
|
-
// Adopted from metallic lib:
|
|
1099
|
-
// https://github.com/jdh8/metallic/blob/master/src/stdlib/parse/scientific.h
|
|
1100
|
-
// @ts-ignore: decorator
|
|
1101
|
-
@inline
|
|
1102
|
-
function scaledown(significand: u64, exp: i32): f64 {
|
|
1103
|
-
const denom: u64 = 6103515625; // 1e14 * 0x1p-14
|
|
1104
|
-
const scale = reinterpret<f64>(0x3F06849B86A12B9B); // 1e-14 * 0x1p32
|
|
1105
|
-
|
|
1106
|
-
let shift = clz(significand);
|
|
1107
|
-
significand <<= shift;
|
|
1108
|
-
shift = exp - shift;
|
|
1109
|
-
|
|
1110
|
-
for (; exp <= -14; exp += 14) {
|
|
1111
|
-
let q = significand / denom;
|
|
1112
|
-
let r = significand % denom;
|
|
1113
|
-
let s = clz(q);
|
|
1114
|
-
significand = (q << s) + <u64>nearest(scale * <f64>(r << (s - 18)));
|
|
1115
|
-
shift -= s;
|
|
1116
|
-
}
|
|
1117
|
-
let b = <u64>ipow32(5, -exp);
|
|
1118
|
-
let q = significand / b;
|
|
1119
|
-
let r = significand % b;
|
|
1120
|
-
let s = clz(q);
|
|
1121
|
-
significand = (q << s) + <u64>(reinterpret<f64>(reinterpret<u64>(<f64>r) + (s << 52)) / <f64>b);
|
|
1122
|
-
shift -= s;
|
|
1123
|
-
|
|
1124
|
-
return NativeMath.scalbn(<f64>significand, <i32>shift);
|
|
1125
|
-
}
|
|
1126
|
-
|
|
1127
|
-
// Adopted from metallic lib:
|
|
1128
|
-
// https://github.com/jdh8/metallic/blob/master/src/stdlib/parse/scientific.h
|
|
1129
|
-
// @ts-ignore: decorator
|
|
1130
|
-
@inline
|
|
1131
|
-
function scaleup(significand: u64, exp: i32): f64 {
|
|
1132
|
-
const coeff: u32 = 1220703125; // 1e13 * 0x1p-13;
|
|
1133
|
-
let shift = ctz(significand);
|
|
1134
|
-
significand >>= shift;
|
|
1135
|
-
shift += exp;
|
|
1136
|
-
|
|
1137
|
-
__fixmulShift = shift;
|
|
1138
|
-
for (; exp >= 13; exp -= 13) {
|
|
1139
|
-
significand = fixmul(significand, coeff);
|
|
1140
|
-
}
|
|
1141
|
-
significand = fixmul(significand, <u32>ipow32(5, exp));
|
|
1142
|
-
shift = __fixmulShift;
|
|
1143
|
-
return NativeMath.scalbn(<f64>significand, <i32>shift);
|
|
1144
|
-
}
|
|
1145
|
-
|
|
1146
|
-
// Adopted from metallic lib:
|
|
1147
|
-
// https://github.com/jdh8/metallic/blob/master/src/stdlib/parse/scientific.h
|
|
1148
|
-
// @ts-ignore: decorator
|
|
1149
|
-
@inline
|
|
1150
|
-
function parseExp(ptr: usize, len: i32): i32 {
|
|
1151
|
-
let sign = 1, magnitude = 0;
|
|
1152
|
-
let code = <u32>load<u16>(ptr);
|
|
1153
|
-
// check code is 'e' or 'E'
|
|
1154
|
-
if ((code | 32) != CharCode.e) return 0;
|
|
1155
|
-
|
|
1156
|
-
if (!--len) return 0;
|
|
1157
|
-
code = <u32>load<u16>(ptr += 2);
|
|
1158
|
-
if (code == CharCode.MINUS) {
|
|
1159
|
-
if (!--len) return 0;
|
|
1160
|
-
code = <u32>load<u16>(ptr += 2);
|
|
1161
|
-
sign = -1;
|
|
1162
|
-
} else if (code == CharCode.PLUS) {
|
|
1163
|
-
if (!--len) return 0;
|
|
1164
|
-
code = <u32>load<u16>(ptr += 2);
|
|
1165
|
-
}
|
|
1166
|
-
// skip zeros
|
|
1167
|
-
while (code == CharCode._0) {
|
|
1168
|
-
if (!--len) return 0;
|
|
1169
|
-
code = <u32>load<u16>(ptr += 2);
|
|
1170
|
-
}
|
|
1171
|
-
for (let digit: u32 = code - CharCode._0; len && digit < 10; digit = code - CharCode._0) {
|
|
1172
|
-
if (magnitude >= 3200) return sign * 3200;
|
|
1173
|
-
magnitude = 10 * magnitude + digit;
|
|
1174
|
-
code = <u32>load<u16>(ptr += 2);
|
|
1175
|
-
--len;
|
|
1176
|
-
}
|
|
1177
|
-
return sign * magnitude;
|
|
1178
|
-
}
|
|
1179
|
-
|
|
1180
|
-
// @ts-ignore: decorator
|
|
1181
|
-
@lazy let __fixmulShift: u64 = 0;
|
|
1182
|
-
|
|
1183
|
-
// Adopted from metallic lib:
|
|
1184
|
-
// https://github.com/jdh8/metallic/blob/master/src/stdlib/parse/scientific.h
|
|
1185
|
-
// @ts-ignore: decorator
|
|
1186
|
-
@inline
|
|
1187
|
-
function fixmul(a: u64, b: u32): u64 {
|
|
1188
|
-
let low = (a & 0xFFFFFFFF) * b;
|
|
1189
|
-
let high = (a >> 32) * b + (low >> 32);
|
|
1190
|
-
let overflow = <u32>(high >> 32);
|
|
1191
|
-
let space = clz(overflow);
|
|
1192
|
-
let revspace: u64 = 32 - space;
|
|
1193
|
-
__fixmulShift += revspace;
|
|
1194
|
-
return (high << space | (low & 0xFFFFFFFF) >> revspace) + (low << space >> 31 & 1);
|
|
1195
|
-
}
|
|
1196
|
-
|
|
1197
|
-
// @ts-ignore: decorator
|
|
1198
|
-
@inline
|
|
1199
|
-
function pow10(n: i32): f64 {
|
|
1200
|
-
// argument `n` should bounds in [0, 22] range
|
|
1201
|
-
return load<f64>(POWERS10 + (n << alignof<f64>()));
|
|
1202
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
itoa32,
|
|
3
|
+
utoa32,
|
|
4
|
+
itoa64,
|
|
5
|
+
utoa64,
|
|
6
|
+
dtoa,
|
|
7
|
+
itoa_buffered,
|
|
8
|
+
dtoa_buffered,
|
|
9
|
+
MAX_DOUBLE_LENGTH
|
|
10
|
+
} from "./number";
|
|
11
|
+
|
|
12
|
+
import {
|
|
13
|
+
ipow32
|
|
14
|
+
} from "../math";
|
|
15
|
+
|
|
16
|
+
// All tables are stored as two staged lookup tables (static tries)
|
|
17
|
+
// because the full range of Unicode symbols can't be efficiently
|
|
18
|
+
// represented as-is in memory (see Unicode spec ch 5, p.196):
|
|
19
|
+
// https://www.unicode.org/versions/Unicode12.0.0/ch05.pdf
|
|
20
|
+
// Tables have been generated using these forked musl tools:
|
|
21
|
+
// https://github.com/MaxGraey/musl-chartable-tools/tree/case-ignorable
|
|
22
|
+
|
|
23
|
+
// Lookup table to check if a character is alphanumeric or not
|
|
24
|
+
// See: https://git.musl-libc.org/cgit/musl/tree/src/ctype/alpha.h
|
|
25
|
+
// size: 3904 bytes
|
|
26
|
+
// @ts-ignore
|
|
27
|
+
@inline @lazy const ALPHA_TABLE = memory.data<u8>([
|
|
28
|
+
18,17,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,17,34,35,36,17,37,38,39,40,
|
|
29
|
+
41,42,43,44,17,45,46,47,16,16,48,16,16,16,16,16,16,16,49,50,51,16,52,53,16,16,
|
|
30
|
+
17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,54,
|
|
31
|
+
17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,
|
|
32
|
+
17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,
|
|
33
|
+
17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,
|
|
34
|
+
17,17,17,55,17,17,17,17,56,17,57,58,59,60,61,62,17,17,17,17,17,17,17,17,17,17,
|
|
35
|
+
17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,
|
|
36
|
+
17,17,17,17,17,17,17,63,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
37
|
+
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,17,64,65,17,66,67,
|
|
38
|
+
68,69,70,71,72,73,74,17,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,
|
|
39
|
+
93,94,16,95,96,97,98,17,17,17,99,100,101,16,16,16,16,16,16,16,16,16,16,17,17,
|
|
40
|
+
17,17,102,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,17,17,103,16,16,16,16,
|
|
41
|
+
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
42
|
+
16,16,16,17,17,104,105,16,16,106,107,17,17,17,17,17,17,17,17,17,17,17,17,17,
|
|
43
|
+
17,17,17,17,17,17,17,17,17,17,108,17,17,17,17,109,110,16,16,16,16,16,16,16,16,
|
|
44
|
+
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
45
|
+
17,111,112,16,16,16,16,16,16,16,16,16,113,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
46
|
+
16,16,16,16,16,16,16,16,16,16,16,114,115,116,117,16,16,16,16,16,16,16,16,118,
|
|
47
|
+
119,120,16,16,16,16,16,121,122,16,16,16,16,123,16,16,124,16,16,16,16,16,16,16,
|
|
48
|
+
16,16,125,16,16,16,
|
|
49
|
+
16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,
|
|
50
|
+
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
|
|
51
|
+
255,255,255,255,255,255,255,255,255,255,255,0,0,0,0,0,0,0,0,254,255,255,7,254,
|
|
52
|
+
255,255,7,0,0,0,0,0,4,32,4,255,255,127,255,255,255,127,255,255,255,255,255,
|
|
53
|
+
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
|
|
54
|
+
255,195,255,3,0,31,80,0,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,223,188,64,215,255,255,
|
|
55
|
+
251,255,255,255,255,255,255,255,255,255,191,255,255,255,255,255,255,255,255,
|
|
56
|
+
255,255,255,255,255,255,255,255,255,3,252,255,255,255,255,255,255,255,255,255,
|
|
57
|
+
255,255,255,255,255,255,255,255,255,255,255,254,255,255,255,127,2,255,255,255,
|
|
58
|
+
255,255,1,0,0,0,0,255,191,182,0,255,255,255,135,7,0,0,0,255,7,255,255,255,255,
|
|
59
|
+
255,255,255,254,255,195,255,255,255,255,255,255,255,255,255,255,255,255,239,
|
|
60
|
+
31,254,225,255,
|
|
61
|
+
159,0,0,255,255,255,255,255,255,0,224,255,255,255,255,255,255,255,255,255,255,
|
|
62
|
+
255,255,3,0,255,255,255,255,255,7,48,4,255,255,255,252,255,31,0,0,255,255,255,
|
|
63
|
+
1,255,7,0,0,0,0,0,0,255,255,223,255,255,0,240,255,248,3,255,255,255,255,255,
|
|
64
|
+
255,255,255,255,239,255,223,225,255,207,255,254,255,239,159,249,255,255,253,
|
|
65
|
+
197,227,159,89,128,176,207,255,3,16,238,135,249,255,255,253,109,195,135,25,2,
|
|
66
|
+
94,192,255,63,0,238,191,251,255,255,253,237,227,191,27,1,0,207,255,0,30,238,
|
|
67
|
+
159,249,255,255,253,237,227,159,25,192,176,207,255,2,0,236,199,61,214,24,199,
|
|
68
|
+
255,195,199,29,129,0,192,255,0,0,239,223,253,255,255,253,255,227,223,29,96,7,
|
|
69
|
+
207,255,0,0,239,223,253,255,255,253,239,227,223,29,96,64,207,255,6,0,255,223,
|
|
70
|
+
253,255,255,255,255,231,223,93,240,128,207,255,0,252,238,255,127,252,255,255,
|
|
71
|
+
251,47,127,128,95,255,192,255,12,0,254,255,255,255,255,127,255,7,63,32,255,3,
|
|
72
|
+
0,0,0,0,214,247,255,255,175,255,255,59,95,32,255,243,0,0,0,
|
|
73
|
+
0,1,0,0,0,255,3,0,0,255,254,255,255,255,31,254,255,3,255,255,254,255,255,255,
|
|
74
|
+
31,0,0,0,0,0,0,0,0,255,255,255,255,255,255,127,249,255,3,255,255,255,255,255,
|
|
75
|
+
255,255,255,255,63,255,255,255,255,191,32,255,255,255,255,255,247,255,255,255,
|
|
76
|
+
255,255,255,255,255,255,61,127,61,255,255,255,255,255,61,255,255,255,255,61,
|
|
77
|
+
127,61,255,127,255,255,255,255,255,255,255,61,255,255,255,255,255,255,255,255,
|
|
78
|
+
7,0,0,0,0,255,255,0,0,255,255,255,255,255,255,255,255,255,255,63,63,254,255,
|
|
79
|
+
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
|
|
80
|
+
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
|
|
81
|
+
255,255,255,255,255,159,255,255,254,255,255,7,255,255,255,255,255,255,255,255,
|
|
82
|
+
255,199,255,1,255,223,15,0,255,255,15,0,255,255,15,0,255,223,13,0,255,255,255,
|
|
83
|
+
255,255,255,207,255,255,1,128,16,255,3,0,0,0,0,255,3,255,255,255,255,255,255,
|
|
84
|
+
255,255,255,255,255,1,255,255,255,255,255,7,255,255,255,255,255,255,255,255,
|
|
85
|
+
63,
|
|
86
|
+
0,255,255,255,127,255,15,255,1,192,255,255,255,255,63,31,0,255,255,255,255,
|
|
87
|
+
255,15,255,255,255,3,255,3,0,0,0,0,255,255,255,15,255,255,255,255,255,255,255,
|
|
88
|
+
127,254,255,31,0,255,3,255,3,128,0,0,128,1,0,0,0,0,0,0,0,255,255,255,255,255,
|
|
89
|
+
255,239,255,239,15,255,3,0,0,0,0,255,255,255,255,255,243,255,255,255,255,255,
|
|
90
|
+
255,191,255,3,0,255,255,255,255,255,255,127,0,255,227,255,255,255,255,255,63,
|
|
91
|
+
255,1,255,255,255,255,255,231,0,0,0,0,0,222,111,4,255,255,255,255,255,255,255,
|
|
92
|
+
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,0,0,0,
|
|
93
|
+
128,255,31,0,255,255,63,63,255,255,255,255,63,63,255,170,255,255,255,63,255,
|
|
94
|
+
255,255,255,255,255,223,95,220,31,207,15,255,31,220,31,0,0,0,0,0,0,0,0,0,0,0,
|
|
95
|
+
0,0,0,2,128,0,0,255,31,0,0,0,0,0,0,0,0,0,0,0,0,132,252,47,62,80,189,255,243,
|
|
96
|
+
224,67,0,0,255,255,255,255,255,1,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
97
|
+
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,255,255,255,255,255,255,3,0,
|
|
98
|
+
0,255,255,255,255,255,127,255,255,255,255,255,127,255,255,255,255,255,255,255,
|
|
99
|
+
255,255,255,255,255,255,255,255,255,31,120,12,0,255,255,255,255,191,32,255,
|
|
100
|
+
255,255,255,255,255,255,128,0,0,255,255,127,0,127,127,127,127,127,127,127,127,
|
|
101
|
+
255,255,255,255,0,0,0,0,0,128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
102
|
+
0,0,224,0,0,0,254,3,62,31,254,255,255,255,255,255,255,255,255,255,127,224,254,
|
|
103
|
+
255,255,255,255,255,255,255,255,255,255,247,224,255,255,255,255,255,254,255,
|
|
104
|
+
255,255,255,255,255,255,255,255,255,127,0,0,255,255,255,255,0,0,0,0,0,0,255,
|
|
105
|
+
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
|
|
106
|
+
255,255,255,255,255,255,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,255,
|
|
107
|
+
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
|
|
108
|
+
255,255,255,
|
|
109
|
+
31,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,31,0,0,
|
|
110
|
+
0,0,0,0,0,0,255,255,255,255,255,63,255,31,255,255,255,15,0,0,255,255,255,255,
|
|
111
|
+
255,127,240,143,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,0,0,
|
|
112
|
+
0,128,255,252,255,255,255,255,255,255,255,255,255,255,255,255,249,255,255,255,
|
|
113
|
+
255,255,255,252,7,0,0,0,0,224,255,191,255,255,255,255,0,0,0,255,255,255,255,
|
|
114
|
+
255,255,15,0,255,255,255,255,255,255,255,255,47,0,255,3,0,0,252,232,255,255,
|
|
115
|
+
255,255,255,7,255,255,255,255,7,0,255,255,255,31,255,255,255,255,255,255,247,
|
|
116
|
+
255,0,128,255,3,255,255,255,127,255,255,255,255,255,255,127,0,255,63,255,3,
|
|
117
|
+
255,255,127,252,255,255,255,255,255,255,255,127,5,0,0,56,255,255,60,0,126,126,
|
|
118
|
+
126,0,127,127,255,255,255,255,255,247,255,3,255,255,255,255,255,255,255,255,
|
|
119
|
+
255,255,255,255,255,255,255,7,255,3,255,255,255,255,255,255,255,255,255,255,
|
|
120
|
+
255,255,255,255,255,255,255,255,255,255,15,0,255,255,127,248,255,255,255,255,
|
|
121
|
+
255,
|
|
122
|
+
15,255,255,255,255,255,255,255,255,255,255,255,255,255,63,255,255,255,255,255,
|
|
123
|
+
255,255,255,255,255,255,255,255,3,0,0,0,0,127,0,248,224,255,253,127,95,219,
|
|
124
|
+
255,255,255,255,255,255,255,255,255,255,255,255,255,3,0,0,0,248,255,255,255,
|
|
125
|
+
255,255,255,255,255,255,255,255,255,63,0,0,255,255,255,255,255,255,255,255,
|
|
126
|
+
252,255,255,255,255,255,255,0,0,0,0,0,255,15,0,0,0,0,0,0,0,0,0,0,0,0,0,0,223,
|
|
127
|
+
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,31,0,0,255,3,
|
|
128
|
+
254,255,255,7,254,255,255,7,192,255,255,255,255,255,255,255,255,255,255,127,
|
|
129
|
+
252,252,252,28,0,0,0,0,255,239,255,255,127,255,255,183,255,63,255,63,0,0,0,0,
|
|
130
|
+
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,7,0,0,0,0,0,0,0,0,
|
|
131
|
+
255,255,255,255,255,255,31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
132
|
+
0,0,0,0,0,0,0,0,255,255,255,31,255,255,255,255,255,255,1,0,0,0,0,
|
|
133
|
+
0,255,255,255,255,0,224,255,255,255,7,255,255,255,255,255,7,255,255,255,63,
|
|
134
|
+
255,255,255,255,15,255,62,0,0,0,0,0,255,255,255,255,255,255,255,255,255,255,
|
|
135
|
+
255,255,255,255,255,255,255,255,255,63,255,3,255,255,255,255,15,255,255,255,
|
|
136
|
+
255,15,255,255,255,255,255,0,255,255,255,255,255,255,15,0,0,0,0,0,0,0,0,0,0,0,
|
|
137
|
+
0,0,0,0,0,0,0,0,255,255,255,255,255,255,127,0,255,255,63,0,255,0,0,0,0,0,0,0,
|
|
138
|
+
0,0,0,0,0,0,0,0,0,0,0,0,63,253,255,255,255,255,191,145,255,255,63,0,255,255,
|
|
139
|
+
127,0,255,255,255,127,0,0,0,0,0,0,0,0,255,255,55,0,255,255,63,0,255,255,255,3,
|
|
140
|
+
0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,192,0,0,0,0,0,0,0,0,111,240,239,
|
|
141
|
+
254,255,255,63,0,0,0,0,0,255,255,255,31,255,255,255,31,0,0,0,0,255,254,255,
|
|
142
|
+
255,31,0,0,0,255,255,255,255,255,255,63,0,255,255,63,0,255,255,7,0,255,255,3,
|
|
143
|
+
0,0,0,0,0,0,0,0,0,0,0,0,
|
|
144
|
+
0,255,255,255,255,255,255,255,255,255,1,0,0,0,0,0,0,255,255,255,255,255,255,7,
|
|
145
|
+
0,255,255,255,255,255,255,7,0,255,255,255,255,255,0,255,3,0,0,0,0,0,0,0,0,0,0,
|
|
146
|
+
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,
|
|
147
|
+
255,27,3,0,0,0,0,0,0,0,0,0,255,255,255,31,128,0,255,255,63,0,0,0,0,0,0,0,0,0,
|
|
148
|
+
0,0,0,0,255,255,31,0,0,0,255,255,127,0,255,255,255,255,255,255,255,255,63,0,0,
|
|
149
|
+
0,192,255,0,0,252,255,255,255,255,255,255,1,0,0,255,255,255,1,255,3,255,255,
|
|
150
|
+
255,255,255,255,199,255,240,0,255,255,255,255,71,0,255,255,255,255,255,255,
|
|
151
|
+
255,255,30,192,255,23,0,0,0,0,255,255,251,255,255,255,159,64,0,0,0,0,0,0,0,0,
|
|
152
|
+
127,189,255,191,255,1,255,255,255,255,255,255,255,1,255,3,239,159,249,255,255,
|
|
153
|
+
253,237,227,159,25,129,224,15,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
154
|
+
0,255,255,255,255,255,255,255,255,187,7,255,131,3,0,0,0,255,255,255,255,255,
|
|
155
|
+
255,255,255,179,0,255,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,
|
|
156
|
+
255,255,255,63,127,0,0,0,63,0,0,0,0,255,255,255,255,255,255,255,127,17,0,255,
|
|
157
|
+
3,0,0,0,0,255,255,255,255,255,255,63,1,255,3,0,0,0,0,0,0,255,255,255,231,255,
|
|
158
|
+
7,255,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,
|
|
159
|
+
255,255,1,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,255,3,0,128,
|
|
160
|
+
127,242,111,255,255,255,191,153,7,0,255,3,0,0,0,0,0,0,0,0,255,252,255,255,255,
|
|
161
|
+
255,255,252,26,0,0,0,255,255,255,255,255,255,231,127,0,0,255,255,255,255,255,
|
|
162
|
+
255,255,255,255,32,0,0,0,0,255,255,255,255,255,255,255,1,255,253,255,255,255,
|
|
163
|
+
255,127,127,1,0,255,3,0,0,252,255,255,255,252,255,255,254,127,0,0,0,0,0,0,0,0,
|
|
164
|
+
0,127,251,255,255,255,255,127,180,203,0,255,3,191,253,255,255,255,127,123,1,
|
|
165
|
+
255,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
166
|
+
0,0,255,255,127,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,
|
|
167
|
+
0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
|
|
168
|
+
255,3,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,255,255,255,255,
|
|
169
|
+
255,127,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
|
|
170
|
+
255,255,255,255,255,255,255,255,15,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
171
|
+
0,0,255,255,255,255,255,127,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
172
|
+
0,255,255,255,255,255,255,255,255,127,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
173
|
+
0,0,
|
|
174
|
+
0,255,255,255,255,255,255,255,1,255,255,255,127,255,3,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
175
|
+
255,255,255,63,0,0,255,255,255,255,255,255,0,0,15,0,255,3,248,255,255,224,255,
|
|
176
|
+
255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,
|
|
177
|
+
255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,255,135,
|
|
178
|
+
255,255,255,255,255,255,255,128,255,255,0,0,0,0,0,0,0,0,11,0,3,0,255,255,255,
|
|
179
|
+
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
|
|
180
|
+
255,255,255,255,255,255,255,255,255,0,255,255,255,255,255,255,255,255,255,255,
|
|
181
|
+
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,63,0,0,0,0,0,
|
|
182
|
+
255,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,
|
|
183
|
+
127,0,0,0,0,0,0,7,0,240,0,255,255,255,255,255,255,255,255,255,255,255,255,255,
|
|
184
|
+
255,255,255,255,
|
|
185
|
+
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
|
|
186
|
+
255,255,255,255,255,255,255,255,255,255,255,255,255,15,255,255,255,255,255,
|
|
187
|
+
255,255,255,255,255,255,255,255,7,255,31,255,1,255,67,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
188
|
+
255,255,255,255,255,255,255,255,255,255,223,255,255,255,255,255,255,255,255,
|
|
189
|
+
223,100,222,255,235,239,255,255,255,255,255,255,255,191,231,223,223,255,255,
|
|
190
|
+
255,123,95,252,253,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
|
|
191
|
+
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
|
|
192
|
+
255,255,255,255,255,255,255,255,63,255,255,255,253,255,255,247,255,255,255,
|
|
193
|
+
247,255,255,223,255,255,255,223,255,255,127,255,255,255,127,255,255,255,253,
|
|
194
|
+
255,255,255,253,255,255,247,207,255,255,255,255,255,255,127,255,255,249,219,7,
|
|
195
|
+
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,31,
|
|
196
|
+
128,63,255,67,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
197
|
+
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,15,255,
|
|
198
|
+
3,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
|
|
199
|
+
255,255,255,255,255,31,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,143,8,
|
|
200
|
+
255,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,239,255,255,255,150,254,247,10,
|
|
201
|
+
132,234,150,170,150,247,247,94,255,251,255,15,238,251,255,15,0,0,0,0,0,0,0,0,
|
|
202
|
+
0,0,0,0,0,0,255,255,255,3,255,255,255,3,255,255,255,3,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
203
|
+
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,3
|
|
204
|
+
]);
|
|
205
|
+
|
|
206
|
+
// size: 1568 bytes (compressed to ~1380 bytes after binaryen)
|
|
207
|
+
// @ts-ignore: decorator
|
|
208
|
+
@lazy @inline const CASED = memory.data<u8>([
|
|
209
|
+
18,19,20,21,22,23,16,16,16,16,16,16,16,16,16,16,
|
|
210
|
+
24,16,16,25,16,16,16,16,16,16,16,16,26,27,17,28,
|
|
211
|
+
29,30,16,16,31,16,16,16,16,16,16,16,32,33,16,16,
|
|
212
|
+
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
213
|
+
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
214
|
+
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
215
|
+
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
216
|
+
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
217
|
+
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
218
|
+
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
219
|
+
16,16,16,16,16,16,34,35,16,16,16,36,16,16,16,16,
|
|
220
|
+
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
221
|
+
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
222
|
+
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
223
|
+
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
224
|
+
16,16,16,16,16,16,16,16,16,16,16,37,16,16,16,38,
|
|
225
|
+
16,16,16,16,39,16,16,16,16,16,16,16,40,16,16,16,
|
|
226
|
+
16,16,16,16,16,16,16,16,41,16,16,16,16,16,16,16,
|
|
227
|
+
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
228
|
+
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
229
|
+
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
230
|
+
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
231
|
+
16,16,16,16,16,16,16,16,16,16,16,16,16,16,42,16,
|
|
232
|
+
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
233
|
+
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
234
|
+
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
235
|
+
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
236
|
+
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
237
|
+
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
238
|
+
16,16,16,16,43,44,45,46,16,16,16,16,16,16,16,16,
|
|
239
|
+
16,16,16,16,16,16,16,16,16,47,16,16,16,16,16,16,
|
|
240
|
+
16,48,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
241
|
+
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
242
|
+
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
243
|
+
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
|
|
244
|
+
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
|
|
245
|
+
0,0,0,0,0,0,0,0,254,255,255,7,254,255,255,7,0,0,0,0,0,4,32,4,
|
|
246
|
+
255,255,127,255,255,255,127,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
|
|
247
|
+
255,255,255,255,255,255,255,247,240,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
|
|
248
|
+
255,255,255,255,255,255,255,255,255,255,239,255,255,255,255,1,3,0,0,0,31,0,0,0,
|
|
249
|
+
0,0,0,0,0,0,0,0,32,0,0,0,0,0,207,188,64,215,255,255,251,255,255,255,
|
|
250
|
+
255,255,255,255,255,255,191,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
|
|
251
|
+
3,252,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,255,
|
|
252
|
+
255,255,127,0,255,255,255,255,255,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
253
|
+
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,
|
|
254
|
+
191,32,255,255,255,255,255,231,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
255
|
+
0,0,0,0,255,255,255,255,255,255,255,255,255,255,63,63,0,0,0,0,0,0,0,0,
|
|
256
|
+
0,0,0,0,0,0,0,0,255,1,255,255,255,255,255,231,0,0,0,0,0,0,0,0,
|
|
257
|
+
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
|
|
258
|
+
0,0,0,0,0,0,0,0,255,255,63,63,255,255,255,255,63,63,255,170,255,255,255,63,
|
|
259
|
+
255,255,255,255,255,255,223,95,220,31,207,15,255,31,220,31,0,0,0,0,0,0,0,0,
|
|
260
|
+
0,0,0,0,0,0,2,128,0,0,255,31,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
261
|
+
132,252,47,62,80,189,31,242,224,67,0,0,255,255,255,255,24,0,0,0,0,0,0,0,
|
|
262
|
+
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
263
|
+
0,0,0,0,0,0,192,255,255,255,255,255,255,3,0,0,255,255,255,255,255,127,255,255,
|
|
264
|
+
255,255,255,127,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,31,120,12,0,
|
|
265
|
+
255,255,255,255,191,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
266
|
+
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,63,0,0,
|
|
267
|
+
255,255,255,63,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,252,255,255,255,
|
|
268
|
+
255,255,255,255,255,255,255,255,255,120,255,255,255,255,255,255,252,7,0,0,0,0,96,7,
|
|
269
|
+
0,0,0,0,0,0,255,255,255,255,255,247,255,1,255,255,255,255,255,255,255,255,255,255,
|
|
270
|
+
0,0,0,0,0,0,0,0,127,0,248,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
271
|
+
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,254,255,255,7,
|
|
272
|
+
254,255,255,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
273
|
+
255,255,255,255,255,255,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,255,255,
|
|
274
|
+
255,255,15,255,255,255,255,15,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
275
|
+
255,255,255,255,255,255,7,0,255,255,255,255,255,255,7,0,0,0,0,0,0,0,0,0,
|
|
276
|
+
0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,0,0,0,0,
|
|
277
|
+
0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,0,0,0,0,0,0,0,0,
|
|
278
|
+
0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,255,255,223,255,255,255,255,255,
|
|
279
|
+
255,255,255,223,100,222,255,235,239,255,255,255,255,255,255,255,191,231,223,223,255,255,255,123,
|
|
280
|
+
95,252,253,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
|
|
281
|
+
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,63,255,255,255,
|
|
282
|
+
253,255,255,247,255,255,255,247,255,255,223,255,255,255,223,255,255,127,255,255,255,127,255,255,
|
|
283
|
+
255,253,255,255,255,253,255,255,247,15,0,0,0,0,0,0,255,255,255,255,255,255,255,255,
|
|
284
|
+
15,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
285
|
+
0,0,0,0,0,0,255,255,255,3,255,255,255,3,255,255,255,3,0,0,0,0,0,0,
|
|
286
|
+
0,0,0,0,0,0,0,0
|
|
287
|
+
]);
|
|
288
|
+
|
|
289
|
+
// size: 2976 bytes (compressed to ~2050 bytes after binaryen)
|
|
290
|
+
// @ts-ignore: decorator
|
|
291
|
+
@lazy @inline const CASE_IGNORABLES = memory.data<u8>([
|
|
292
|
+
18,16,19,20,21,22,23,24,25,26,27,28,29,30,31,32,
|
|
293
|
+
33,16,16,34,16,16,16,35,36,37,38,39,40,41,16,42,
|
|
294
|
+
43,16,16,16,16,16,16,16,16,16,16,16,44,45,46,16,
|
|
295
|
+
47,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
296
|
+
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
297
|
+
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
298
|
+
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
299
|
+
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
300
|
+
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
301
|
+
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
302
|
+
48,16,16,16,49,16,50,51,52,53,54,55,16,16,16,16,
|
|
303
|
+
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
304
|
+
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
305
|
+
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
306
|
+
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
307
|
+
16,16,16,16,16,16,16,16,16,16,16,56,16,16,57,58,
|
|
308
|
+
16,59,60,61,16,16,16,16,16,16,62,16,16,63,64,65,
|
|
309
|
+
66,67,68,69,70,71,72,73,74,75,76,16,77,78,79,16,
|
|
310
|
+
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
311
|
+
16,16,16,16,80,16,16,16,16,16,16,16,16,16,16,16,
|
|
312
|
+
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
313
|
+
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
314
|
+
16,16,16,16,16,16,16,16,16,16,81,82,16,16,16,83,
|
|
315
|
+
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
316
|
+
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
317
|
+
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
318
|
+
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
319
|
+
16,16,16,16,16,16,16,16,16,16,16,16,84,16,16,16,
|
|
320
|
+
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
321
|
+
16,85,86,16,16,16,16,16,16,16,87,16,16,16,16,16,
|
|
322
|
+
88,89,90,16,16,16,16,16,91,92,16,16,16,16,16,16,
|
|
323
|
+
16,16,16,93,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
324
|
+
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
325
|
+
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
326
|
+
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
|
|
327
|
+
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
|
|
328
|
+
0,0,0,0,128,64,0,4,0,0,0,64,1,0,0,0,0,0,0,0,0,161,144,1,
|
|
329
|
+
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
330
|
+
0,0,0,0,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
|
|
331
|
+
255,255,255,255,255,255,48,4,176,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
332
|
+
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,248,3,0,0,0,0,0,0,
|
|
333
|
+
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,130,0,0,0,0,
|
|
334
|
+
0,0,254,255,255,255,255,191,182,0,0,0,0,0,16,0,63,0,255,23,0,0,0,0,
|
|
335
|
+
1,248,255,255,0,0,1,0,0,0,0,0,0,0,0,0,0,0,192,191,255,61,0,0,
|
|
336
|
+
0,128,2,0,0,0,255,255,255,7,0,0,0,0,0,0,0,0,0,0,192,255,1,0,
|
|
337
|
+
0,0,0,0,0,248,63,36,0,0,192,255,255,63,0,0,0,0,0,14,0,0,0,0,
|
|
338
|
+
0,0,0,0,0,0,0,0,0,0,248,255,255,255,255,255,7,0,0,0,0,0,0,20,
|
|
339
|
+
254,33,254,0,12,0,2,0,2,0,0,0,0,0,0,16,30,32,0,0,12,0,0,64,
|
|
340
|
+
6,0,0,0,0,0,0,16,134,57,2,0,0,0,35,0,6,0,0,0,0,0,0,16,
|
|
341
|
+
190,33,0,0,12,0,0,252,2,0,0,0,0,0,0,144,30,32,96,0,12,0,0,0,
|
|
342
|
+
4,0,0,0,0,0,0,0,1,32,0,0,0,0,0,0,17,0,0,0,0,0,0,192,
|
|
343
|
+
193,61,96,0,12,0,0,0,2,0,0,0,0,0,0,144,64,48,0,0,12,0,0,0,
|
|
344
|
+
3,0,0,0,0,0,0,24,30,32,0,0,12,0,0,0,2,0,0,0,0,0,0,0,
|
|
345
|
+
0,4,92,0,0,0,0,0,0,0,0,0,0,0,242,7,192,127,0,0,0,0,0,0,
|
|
346
|
+
0,0,0,0,0,0,242,31,64,63,0,0,0,0,0,0,0,0,0,3,0,0,160,2,
|
|
347
|
+
0,0,0,0,0,0,254,127,223,224,255,254,255,255,255,31,64,0,0,0,0,0,0,0,
|
|
348
|
+
0,0,0,0,0,224,253,102,0,0,0,195,1,0,30,0,100,32,0,32,0,0,0,0,
|
|
349
|
+
0,0,0,0,0,0,0,16,0,0,0,0,0,0,0,0,0,0,0,224,0,0,0,0,
|
|
350
|
+
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,28,0,0,0,28,0,
|
|
351
|
+
0,0,12,0,0,0,12,0,0,0,0,0,0,0,176,63,64,254,143,32,0,0,0,0,
|
|
352
|
+
0,120,0,0,0,0,0,0,8,0,0,0,0,0,0,0,96,0,0,0,0,2,0,0,
|
|
353
|
+
0,0,0,0,0,0,0,0,0,0,0,0,135,1,4,14,0,0,0,0,0,0,0,0,
|
|
354
|
+
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,9,0,0,0,0,
|
|
355
|
+
0,0,64,127,229,31,248,159,0,0,0,0,128,0,255,255,1,0,0,0,0,0,0,0,
|
|
356
|
+
15,0,0,0,0,0,208,23,4,0,0,0,0,248,15,0,3,0,0,0,60,59,0,0,
|
|
357
|
+
0,0,0,0,64,163,3,0,0,0,0,0,0,240,207,0,0,0,0,0,0,0,0,63,
|
|
358
|
+
0,0,0,0,0,0,0,0,0,0,247,255,253,33,16,3,0,0,0,0,0,240,255,255,
|
|
359
|
+
255,255,255,255,255,7,0,1,0,0,0,248,255,255,255,255,255,255,255,255,255,255,255,251,
|
|
360
|
+
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,160,
|
|
361
|
+
3,224,0,224,0,224,0,96,0,248,0,3,144,124,0,0,0,0,0,0,223,255,2,128,
|
|
362
|
+
0,0,255,31,0,0,0,0,0,0,255,255,255,255,1,0,0,0,0,0,0,0,0,0,
|
|
363
|
+
0,0,0,0,0,0,0,48,0,0,0,0,0,0,0,0,0,0,0,0,0,128,3,0,
|
|
364
|
+
0,0,0,0,0,0,0,0,0,0,0,0,0,128,0,128,0,0,0,0,0,0,0,0,
|
|
365
|
+
0,0,0,0,255,255,255,255,0,0,0,0,0,128,0,0,0,0,0,0,0,0,0,0,
|
|
366
|
+
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,0,0,0,0,60,62,8,
|
|
367
|
+
0,0,0,0,0,0,0,0,0,0,0,126,0,0,0,0,0,0,0,0,0,0,0,112,
|
|
368
|
+
0,0,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
369
|
+
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
370
|
+
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,63,0,16,0,0,0,0,0,0,
|
|
371
|
+
0,0,0,0,0,128,247,191,0,0,0,240,0,0,0,0,0,0,0,0,0,0,3,0,
|
|
372
|
+
255,255,255,255,3,0,0,0,0,0,0,0,0,0,1,0,0,7,0,0,0,0,0,0,
|
|
373
|
+
0,0,0,0,0,0,0,3,68,8,0,0,96,16,0,0,0,0,0,0,0,0,0,0,
|
|
374
|
+
0,0,0,0,0,0,0,0,48,0,0,0,255,255,3,128,0,0,0,0,192,63,0,0,
|
|
375
|
+
128,255,3,0,0,0,0,0,7,0,0,0,0,0,200,51,0,128,0,0,96,0,0,0,
|
|
376
|
+
0,0,0,0,0,126,102,0,8,16,0,0,0,0,1,16,0,0,0,0,0,0,157,193,
|
|
377
|
+
2,0,0,32,0,48,88,0,0,0,0,0,0,0,0,0,0,0,0,248,0,14,0,0,
|
|
378
|
+
0,0,0,0,0,0,0,0,0,0,0,0,32,33,0,0,0,0,0,64,0,0,0,0,
|
|
379
|
+
0,0,0,0,0,0,0,0,0,0,0,0,0,0,252,255,3,0,0,0,0,0,0,0,
|
|
380
|
+
255,255,8,0,255,255,0,0,0,0,36,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
381
|
+
0,0,0,0,0,0,0,128,128,64,0,4,0,0,0,64,1,0,0,0,0,0,1,0,
|
|
382
|
+
0,0,0,192,0,0,0,0,0,0,0,0,8,0,0,14,0,0,0,0,0,0,0,0,
|
|
383
|
+
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,
|
|
384
|
+
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
385
|
+
0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,7,
|
|
386
|
+
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,110,240,0,0,0,0,0,135,
|
|
387
|
+
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,96,0,0,0,
|
|
388
|
+
0,0,0,0,240,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
389
|
+
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
390
|
+
0,0,0,0,0,24,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
391
|
+
192,255,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
392
|
+
2,0,0,0,0,0,0,255,127,0,0,0,0,0,0,128,3,0,0,0,0,0,120,38,
|
|
393
|
+
0,32,0,0,0,0,0,0,7,0,0,0,128,239,31,0,0,0,0,0,0,0,8,0,
|
|
394
|
+
3,0,0,0,0,0,192,127,0,158,0,0,0,0,0,0,0,0,0,0,0,128,211,64,
|
|
395
|
+
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,248,7,0,0,
|
|
396
|
+
3,0,0,0,0,0,0,24,1,0,0,0,192,31,31,0,0,0,0,0,0,0,0,0,
|
|
397
|
+
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,92,0,0,64,0,0,0,0,
|
|
398
|
+
0,0,0,0,0,0,248,133,13,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
399
|
+
0,0,0,0,0,0,0,0,0,0,0,0,0,0,60,176,1,0,0,48,0,0,0,0,
|
|
400
|
+
0,0,0,0,0,0,248,167,1,0,0,0,0,0,0,0,0,0,0,0,0,40,191,0,
|
|
401
|
+
0,0,0,0,0,0,0,0,0,0,0,224,188,15,0,0,0,0,0,0,0,0,0,0,
|
|
402
|
+
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,255,6,
|
|
403
|
+
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
404
|
+
0,0,0,0,0,0,0,88,8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
405
|
+
0,0,240,12,1,0,0,0,254,7,0,0,0,0,248,121,128,0,126,14,0,0,0,0,
|
|
406
|
+
0,252,127,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,127,191,
|
|
407
|
+
0,0,0,0,0,0,0,0,0,0,252,255,255,252,109,0,0,0,0,0,0,0,0,0,
|
|
408
|
+
0,0,0,0,0,0,126,180,191,0,0,0,0,0,0,0,0,0,163,0,0,0,0,0,
|
|
409
|
+
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
410
|
+
0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,0,0,0,0,0,0,0,255,1,
|
|
411
|
+
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
412
|
+
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
413
|
+
0,0,0,0,0,0,31,0,0,0,0,0,0,0,127,0,15,0,0,0,0,0,0,0,
|
|
414
|
+
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
415
|
+
0,128,0,0,0,0,0,0,0,128,255,255,0,0,0,0,0,0,0,0,27,0,0,0,
|
|
416
|
+
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,96,15,0,0,0,
|
|
417
|
+
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,3,248,255,
|
|
418
|
+
231,15,0,0,0,60,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
419
|
+
28,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
420
|
+
255,255,255,255,255,255,127,248,255,255,255,255,255,31,32,0,16,0,0,248,254,255,0,0,
|
|
421
|
+
0,0,0,0,0,0,0,0,127,255,255,249,219,7,0,0,0,0,0,0,0,0,0,0,
|
|
422
|
+
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,63,
|
|
423
|
+
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
424
|
+
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
425
|
+
0,0,0,0,0,240,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
426
|
+
0,0,0,0,0,0,0,0,0,0,127,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
427
|
+
240,15,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
428
|
+
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
429
|
+
0,0,0,0,0,0,0,248
|
|
430
|
+
]);
|
|
431
|
+
|
|
432
|
+
// @ts-ignore: decorator
|
|
433
|
+
@lazy @inline const LOWER127 = memory.data<u8>([
|
|
434
|
+
0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,
|
|
435
|
+
16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,
|
|
436
|
+
32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,
|
|
437
|
+
48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,
|
|
438
|
+
64,
|
|
439
|
+
97,98,99,100,101,102,103,104,105,106,107,108,109,
|
|
440
|
+
110,111,112,113,114,115,116,117,118,119,120,121,122,
|
|
441
|
+
91,92,93,94,95,96,
|
|
442
|
+
97,98,99,100,101,102,103,104,105,106,107,108,109,
|
|
443
|
+
110,111,112,113,114,115,116,117,118,119,120,121,122,
|
|
444
|
+
123,124,125,126,127
|
|
445
|
+
]);
|
|
446
|
+
|
|
447
|
+
// @ts-ignore: decorator
|
|
448
|
+
@lazy @inline const UPPER127 = memory.data<u8>([
|
|
449
|
+
0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,
|
|
450
|
+
16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,
|
|
451
|
+
32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,
|
|
452
|
+
48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,
|
|
453
|
+
64,
|
|
454
|
+
65,66,67,68,69,70,71,72,73,74,75,76,77,
|
|
455
|
+
78,79,80,81,82,83,84,85,86,87,88,89,90,
|
|
456
|
+
91,92,93,94,95,96,
|
|
457
|
+
65,66,67,68,69,70,71,72,73,74,75,76,77,
|
|
458
|
+
78,79,80,81,82,83,84,85,86,87,88,89,90,
|
|
459
|
+
123,124,125,126,127
|
|
460
|
+
]);
|
|
461
|
+
|
|
462
|
+
// 23 * 8 = 184 bytes
|
|
463
|
+
// @ts-ignore: decorator
|
|
464
|
+
@lazy @inline const POWERS10 = memory.data<f64>([
|
|
465
|
+
1e00, 1e01, 1e02, 1e03, 1e04, 1e05, 1e06, 1e07, 1e08, 1e09,
|
|
466
|
+
1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19,
|
|
467
|
+
1e20, 1e21, 1e22
|
|
468
|
+
]);
|
|
469
|
+
|
|
470
|
+
// @ts-ignore: decorator
|
|
471
|
+
@inline
|
|
472
|
+
export const enum CharCode {
|
|
473
|
+
PERCENT = 0x25,
|
|
474
|
+
PLUS = 0x2B,
|
|
475
|
+
MINUS = 0x2D,
|
|
476
|
+
DOT = 0x2E,
|
|
477
|
+
_0 = 0x30,
|
|
478
|
+
_1 = 0x31,
|
|
479
|
+
_2 = 0x32,
|
|
480
|
+
_3 = 0x33,
|
|
481
|
+
_4 = 0x34,
|
|
482
|
+
_5 = 0x35,
|
|
483
|
+
_6 = 0x36,
|
|
484
|
+
_7 = 0x37,
|
|
485
|
+
_8 = 0x38,
|
|
486
|
+
_9 = 0x39,
|
|
487
|
+
A = 0x41,
|
|
488
|
+
B = 0x42,
|
|
489
|
+
E = 0x45,
|
|
490
|
+
I = 0x49,
|
|
491
|
+
N = 0x4E,
|
|
492
|
+
O = 0x4F,
|
|
493
|
+
X = 0x58,
|
|
494
|
+
Z = 0x5A,
|
|
495
|
+
a = 0x61,
|
|
496
|
+
b = 0x62,
|
|
497
|
+
e = 0x65,
|
|
498
|
+
n = 0x6E,
|
|
499
|
+
o = 0x6F,
|
|
500
|
+
u = 0x75,
|
|
501
|
+
x = 0x78,
|
|
502
|
+
z = 0x7A
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
// @ts-ignore: decorator
|
|
506
|
+
@inline
|
|
507
|
+
export function isAscii(c: u32): bool {
|
|
508
|
+
return !(c >> 7);
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
// @ts-ignore: decorator
|
|
512
|
+
@inline
|
|
513
|
+
export function isLower8(c: u32): bool {
|
|
514
|
+
return c - CharCode.a < 26;
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
// @ts-ignore: decorator
|
|
518
|
+
@inline
|
|
519
|
+
export function isUpper8(c: u32): bool {
|
|
520
|
+
return c - CharCode.A < 26;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
export function isSpace(c: u32): bool {
|
|
524
|
+
if (c < 0x1680) { // < <LS> (1)
|
|
525
|
+
// <SP>, <TAB>, <LF>, <VT>, <FF>, <CR> and <NBSP>
|
|
526
|
+
// (c == 0x20 || c == 0xA0) was optimized to (c | 0x80) == 0xA0
|
|
527
|
+
return ((c | 0x80) == 0xA0) || (c - 0x09 <= 0x0D - 0x09);
|
|
528
|
+
}
|
|
529
|
+
if (c - 0x2000 <= 0x200A - 0x2000) return true;
|
|
530
|
+
switch (c) {
|
|
531
|
+
case 0x1680: // <LS> (1)
|
|
532
|
+
case 0x2028: // <LS> (2)
|
|
533
|
+
case 0x2029: // <PS>
|
|
534
|
+
case 0x202F: // <NNS>
|
|
535
|
+
case 0x205F: // <MMSP>
|
|
536
|
+
case 0x3000: // <IS>
|
|
537
|
+
case 0xFEFF: return true; // <ZWNBSP>
|
|
538
|
+
}
|
|
539
|
+
return false;
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
export function isAlpha(c: u32): bool {
|
|
543
|
+
if (isAscii(c)) return (c | 32) - CharCode.a < 26;
|
|
544
|
+
if (c < 0x20000) {
|
|
545
|
+
// @ts-ignore: cast
|
|
546
|
+
return stagedBinaryLookup(ALPHA_TABLE, c);
|
|
547
|
+
}
|
|
548
|
+
return c < 0x2FFFE;
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
// @ts-ignore: decorator
|
|
552
|
+
@inline
|
|
553
|
+
export function isCased(c: u32): bool {
|
|
554
|
+
// @ts-ignore: cast
|
|
555
|
+
return c < 0x1F18A && stagedBinaryLookup(CASED, c);
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
// @ts-ignore: decorator
|
|
559
|
+
@inline
|
|
560
|
+
export function isCaseIgnorable(c: u32): bool {
|
|
561
|
+
// @ts-ignore: cast
|
|
562
|
+
return c < 0xE01F0 && stagedBinaryLookup(CASE_IGNORABLES, c);
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
// @ts-ignore: decorator
|
|
566
|
+
@inline
|
|
567
|
+
export function isFinalSigma(buffer: usize, index: isize, len: isize): bool {
|
|
568
|
+
const lookaheadLimit = 30; // max lookahead limit
|
|
569
|
+
let found = false;
|
|
570
|
+
let pos = index;
|
|
571
|
+
let minPos = max(0, pos - lookaheadLimit);
|
|
572
|
+
while (pos > minPos) {
|
|
573
|
+
let c = codePointBefore(buffer, pos);
|
|
574
|
+
if (!isCaseIgnorable(c)) {
|
|
575
|
+
if (isCased(c)) {
|
|
576
|
+
found = true;
|
|
577
|
+
} else {
|
|
578
|
+
return false;
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
pos -= isize(c >= 0x10000) + 1;
|
|
582
|
+
}
|
|
583
|
+
if (!found) return false;
|
|
584
|
+
pos = index + 1;
|
|
585
|
+
let maxPos = min(pos + lookaheadLimit, len);
|
|
586
|
+
while (pos < maxPos) {
|
|
587
|
+
let c = <u32>load<u16>(buffer + (pos << 1));
|
|
588
|
+
if (u32((c & 0xFC00) == 0xD800) & u32(pos + 1 != len)) {
|
|
589
|
+
let c1 = <u32>load<u16>(buffer + (pos << 1), 2);
|
|
590
|
+
if ((c1 & 0xFC00) == 0xDC00) {
|
|
591
|
+
c = (c - 0xD800 << 10) + (c1 - 0xDC00) + 0x10000;
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
if (!isCaseIgnorable(c)) {
|
|
595
|
+
return !isCased(c);
|
|
596
|
+
}
|
|
597
|
+
pos += isize(c >= 0x10000) + 1;
|
|
598
|
+
}
|
|
599
|
+
return true;
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
// @ts-ignore: decorator
|
|
603
|
+
@inline
|
|
604
|
+
function codePointBefore(buffer: usize, index: isize): i32 {
|
|
605
|
+
if (index <= 0) return -1;
|
|
606
|
+
let c = <u32>load<u16>(buffer + (index - 1 << 1));
|
|
607
|
+
if (u32((c & 0xFC00) == 0xDC00) & u32(index - 2 >= 0)) {
|
|
608
|
+
let c1 = <u32>load<u16>(buffer + (index - 2 << 1));
|
|
609
|
+
if ((c1 & 0xFC00) == 0xD800) {
|
|
610
|
+
return ((c1 & 0x3FF) << 10) + (c & 0x3FF) + 0x10000;
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
return (c & 0xF800) == 0xD800 ? 0xFFFD : c;
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
// Search routine for two-staged lookup tables
|
|
617
|
+
function stagedBinaryLookup(table: usize, c: u32): bool {
|
|
618
|
+
return <bool>((load<u8>(table + (<u32>load<u8>(table + (c >>> 8)) << 5) + ((c & 255) >> 3)) >>> (c & 7)) & 1);
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
export function compareImpl(str1: string, index1: usize, str2: string, index2: usize, len: usize): i32 {
|
|
622
|
+
let ptr1 = changetype<usize>(str1) + (index1 << 1);
|
|
623
|
+
let ptr2 = changetype<usize>(str2) + (index2 << 1);
|
|
624
|
+
if (ASC_SHRINK_LEVEL < 2) {
|
|
625
|
+
if (len >= 4 && !((ptr1 & 7) | (ptr2 & 7))) {
|
|
626
|
+
do {
|
|
627
|
+
if (load<u64>(ptr1) != load<u64>(ptr2)) break;
|
|
628
|
+
ptr1 += 8;
|
|
629
|
+
ptr2 += 8;
|
|
630
|
+
len -= 4;
|
|
631
|
+
} while (len >= 4);
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
while (len--) {
|
|
635
|
+
let a = <i32>load<u16>(ptr1);
|
|
636
|
+
let b = <i32>load<u16>(ptr2);
|
|
637
|
+
if (a != b) return a - b;
|
|
638
|
+
ptr1 += 2;
|
|
639
|
+
ptr2 += 2;
|
|
640
|
+
}
|
|
641
|
+
return 0;
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
// @ts-ignore: decorator
|
|
645
|
+
@inline
|
|
646
|
+
export function toLower8(c: u32): u32 {
|
|
647
|
+
if (ASC_SHRINK_LEVEL > 0) {
|
|
648
|
+
return c | u32(isUpper8(c)) << 5;
|
|
649
|
+
} else {
|
|
650
|
+
return <u32>load<u8>(LOWER127 + c);
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
// @ts-ignore: decorator
|
|
655
|
+
@inline
|
|
656
|
+
export function toUpper8(c: u32): u32 {
|
|
657
|
+
if (ASC_SHRINK_LEVEL > 0) {
|
|
658
|
+
return c & ~(u32(isLower8(c)) << 5);
|
|
659
|
+
} else {
|
|
660
|
+
return <u32>load<u8>(UPPER127 + c);
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
/** Parses a string to an integer (usually), using the specified radix. */
|
|
665
|
+
export function strtol<T>(str: string, radix: i32 = 0): T {
|
|
666
|
+
let len = str.length;
|
|
667
|
+
if (!len) {
|
|
668
|
+
if (isFloat<T>()) {
|
|
669
|
+
// @ts-ignore: cast
|
|
670
|
+
return <T>NaN;
|
|
671
|
+
} else {
|
|
672
|
+
// @ts-ignore: cast
|
|
673
|
+
return <T>0;
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
let ptr = changetype<usize>(str) /* + HEAD -> offset */;
|
|
678
|
+
let code = <u32>load<u16>(ptr);
|
|
679
|
+
|
|
680
|
+
// trim white spaces
|
|
681
|
+
while (isSpace(code)) {
|
|
682
|
+
code = <u32>load<u16>(ptr += 2);
|
|
683
|
+
--len;
|
|
684
|
+
}
|
|
685
|
+
// determine sign
|
|
686
|
+
// @ts-ignore
|
|
687
|
+
let sign: T = 1;
|
|
688
|
+
if (code == CharCode.MINUS || code == CharCode.PLUS) {
|
|
689
|
+
if (!--len) {
|
|
690
|
+
if (isFloat<T>()) {
|
|
691
|
+
// @ts-ignore: cast
|
|
692
|
+
return <T>NaN;
|
|
693
|
+
} else {
|
|
694
|
+
// @ts-ignore: cast
|
|
695
|
+
return <T>0;
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
if (code == CharCode.MINUS) {
|
|
699
|
+
// @ts-ignore: type
|
|
700
|
+
sign = -1;
|
|
701
|
+
}
|
|
702
|
+
code = <u32>load<u16>(ptr += 2);
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
// See https://tc39.es/ecma262/#sec-parseint-string-radix
|
|
706
|
+
if (radix) {
|
|
707
|
+
if (radix < 2 || radix > 36) {
|
|
708
|
+
if (isFloat<T>()) {
|
|
709
|
+
// @ts-ignore: cast
|
|
710
|
+
return <T>NaN;
|
|
711
|
+
} else {
|
|
712
|
+
// @ts-ignore: cast
|
|
713
|
+
return <T>0;
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
// handle case as parseInt("0xFF", 16) by spec
|
|
717
|
+
if (radix == 16) {
|
|
718
|
+
if (
|
|
719
|
+
len > 2 &&
|
|
720
|
+
code == CharCode._0 &&
|
|
721
|
+
(<u32>load<u16>(ptr, 2) | 32) == CharCode.x
|
|
722
|
+
) {
|
|
723
|
+
ptr += 4; len -= 2;
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
} else {
|
|
727
|
+
// determine radix by literal prefix
|
|
728
|
+
if (code == CharCode._0 && len > 2) {
|
|
729
|
+
switch (<u32>load<u16>(ptr, 2) | 32) {
|
|
730
|
+
case CharCode.b: {
|
|
731
|
+
ptr += 4; len -= 2;
|
|
732
|
+
radix = 2;
|
|
733
|
+
break;
|
|
734
|
+
}
|
|
735
|
+
case CharCode.o: {
|
|
736
|
+
ptr += 4; len -= 2;
|
|
737
|
+
radix = 8;
|
|
738
|
+
break;
|
|
739
|
+
}
|
|
740
|
+
case CharCode.x: {
|
|
741
|
+
ptr += 4; len -= 2;
|
|
742
|
+
radix = 16;
|
|
743
|
+
break;
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
if (!radix) radix = 10;
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
// calculate value
|
|
751
|
+
// @ts-ignore: type
|
|
752
|
+
let num: T = 0;
|
|
753
|
+
let initial = len - 1;
|
|
754
|
+
while (len--) {
|
|
755
|
+
code = <u32>load<u16>(ptr);
|
|
756
|
+
if (code - CharCode._0 < 10) {
|
|
757
|
+
code -= CharCode._0;
|
|
758
|
+
} else if (code - CharCode.A <= <u32>(CharCode.Z - CharCode.A)) {
|
|
759
|
+
code -= CharCode.A - 10;
|
|
760
|
+
} else if (code - CharCode.a <= <u32>(CharCode.z - CharCode.a)) {
|
|
761
|
+
code -= CharCode.a - 10;
|
|
762
|
+
}
|
|
763
|
+
if (code >= <u32>radix) {
|
|
764
|
+
if (initial == len) {
|
|
765
|
+
if (isFloat<T>()) {
|
|
766
|
+
// @ts-ignore: cast
|
|
767
|
+
return <T>NaN;
|
|
768
|
+
} else {
|
|
769
|
+
// @ts-ignore: cast
|
|
770
|
+
return <T>0;
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
break;
|
|
774
|
+
}
|
|
775
|
+
// @ts-ignore: type
|
|
776
|
+
num = num * radix + code;
|
|
777
|
+
ptr += 2;
|
|
778
|
+
}
|
|
779
|
+
// @ts-ignore: type
|
|
780
|
+
return sign * num;
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
export function strtod(str: string): f64 {
|
|
784
|
+
let len = str.length;
|
|
785
|
+
if (!len) return NaN;
|
|
786
|
+
|
|
787
|
+
let ptr = changetype<usize>(str);
|
|
788
|
+
let code = <u32>load<u16>(ptr);
|
|
789
|
+
|
|
790
|
+
let sign = 1.0;
|
|
791
|
+
// skip white spaces
|
|
792
|
+
while (len && isSpace(code)) {
|
|
793
|
+
code = <u32>load<u16>(ptr += 2);
|
|
794
|
+
--len;
|
|
795
|
+
}
|
|
796
|
+
if (!len) return NaN;
|
|
797
|
+
|
|
798
|
+
// try parse '-' or '+'
|
|
799
|
+
if (code == CharCode.MINUS) {
|
|
800
|
+
if (!--len) return NaN;
|
|
801
|
+
code = <u32>load<u16>(ptr += 2);
|
|
802
|
+
sign = -1;
|
|
803
|
+
} else if (code == CharCode.PLUS) {
|
|
804
|
+
if (!--len) return NaN;
|
|
805
|
+
code = <u32>load<u16>(ptr += 2);
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
// try parse Infinity
|
|
809
|
+
if (len >= 8 && code == CharCode.I) {
|
|
810
|
+
if (
|
|
811
|
+
load<u64>(ptr, 0) == 0x690066006E0049 && // ifnI
|
|
812
|
+
load<u64>(ptr, 8) == 0x7900740069006E // ytin
|
|
813
|
+
) {
|
|
814
|
+
return Infinity * sign;
|
|
815
|
+
}
|
|
816
|
+
return NaN;
|
|
817
|
+
}
|
|
818
|
+
// validate next symbol
|
|
819
|
+
if (code != CharCode.DOT && <u32>(code - CharCode._0) >= 10) {
|
|
820
|
+
return NaN;
|
|
821
|
+
}
|
|
822
|
+
let savedPtr = ptr;
|
|
823
|
+
// skip zeros
|
|
824
|
+
while (code == CharCode._0) {
|
|
825
|
+
code = <u32>load<u16>(ptr += 2);
|
|
826
|
+
--len;
|
|
827
|
+
}
|
|
828
|
+
if (len <= 0) return 0.0 * sign;
|
|
829
|
+
const capacity = 19; // int(64 * 0.3010)
|
|
830
|
+
let pointed = false;
|
|
831
|
+
let consumed = 0;
|
|
832
|
+
let position = 0;
|
|
833
|
+
let x: u64 = 0;
|
|
834
|
+
if (code == CharCode.DOT) {
|
|
835
|
+
let noDigits = !(savedPtr - ptr);
|
|
836
|
+
ptr += 2; --len;
|
|
837
|
+
if (!len && noDigits) return NaN;
|
|
838
|
+
for (pointed = true; (code = <u32>load<u16>(ptr)) == CharCode._0; --position, ptr += 2) --len;
|
|
839
|
+
if (len <= 0) return 0.0 * sign;
|
|
840
|
+
if (!position && noDigits && code - CharCode._0 >= 10) return NaN;
|
|
841
|
+
}
|
|
842
|
+
for (let digit = code - CharCode._0; digit < 10 || (code == CharCode.DOT && !pointed); digit = code - CharCode._0) {
|
|
843
|
+
if (digit < 10) {
|
|
844
|
+
x = consumed < capacity ? 10 * x + digit : x | u64(!!digit);
|
|
845
|
+
++consumed;
|
|
846
|
+
} else {
|
|
847
|
+
position = consumed;
|
|
848
|
+
pointed = true;
|
|
849
|
+
}
|
|
850
|
+
if (!--len) break;
|
|
851
|
+
code = <u32>load<u16>(ptr += 2);
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
if (!pointed) position = consumed;
|
|
855
|
+
return copysign<f64>(scientific(x, position - min(capacity, consumed) + parseExp(ptr, len)), sign);
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
export function strtob(str: string): bool {
|
|
859
|
+
let size: usize = str.length << 1;
|
|
860
|
+
let offset: usize = 0;
|
|
861
|
+
if (size > 8) {
|
|
862
|
+
// try trim end whitespaces first
|
|
863
|
+
while (size && isSpace(load<u16>(changetype<usize>(str) + size - 2))) size -= 2;
|
|
864
|
+
if (size > 8) {
|
|
865
|
+
// trim start whitespaces
|
|
866
|
+
while (offset < size && isSpace(load<u16>(changetype<usize>(str) + offset))) offset += 2;
|
|
867
|
+
size -= offset;
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
if (size != 8) return false;
|
|
871
|
+
// "true" represents as \00\e\00\u\00\e\00\t (00 65 00 75 00 72 00 74)
|
|
872
|
+
return load<u64>(changetype<usize>(str) + offset) == 0x0065_0075_0072_0074;
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
export function joinBooleanArray(dataStart: usize, length: i32, separator: string): string {
|
|
876
|
+
let lastIndex = length - 1;
|
|
877
|
+
if (lastIndex < 0) return "";
|
|
878
|
+
if (!lastIndex) return select("true", "false", load<bool>(dataStart));
|
|
879
|
+
|
|
880
|
+
let sepLen = separator.length;
|
|
881
|
+
let valueLen = 5; // max possible length of element len("false")
|
|
882
|
+
let estLen = (valueLen + sepLen) * lastIndex + valueLen;
|
|
883
|
+
let result = changetype<string>(__new(estLen << 1, idof<string>()));
|
|
884
|
+
let offset = 0;
|
|
885
|
+
let value: bool;
|
|
886
|
+
for (let i = 0; i < lastIndex; ++i) {
|
|
887
|
+
value = load<bool>(dataStart + i);
|
|
888
|
+
valueLen = 4 + i32(!value);
|
|
889
|
+
memory.copy(
|
|
890
|
+
changetype<usize>(result) + (<usize>offset << 1),
|
|
891
|
+
changetype<usize>(select("true", "false", value)),
|
|
892
|
+
<usize>valueLen << 1
|
|
893
|
+
);
|
|
894
|
+
offset += valueLen;
|
|
895
|
+
if (sepLen) {
|
|
896
|
+
memory.copy(
|
|
897
|
+
changetype<usize>(result) + (<usize>offset << 1),
|
|
898
|
+
changetype<usize>(separator),
|
|
899
|
+
<usize>sepLen << 1
|
|
900
|
+
);
|
|
901
|
+
offset += sepLen;
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
value = load<bool>(dataStart + <usize>lastIndex);
|
|
905
|
+
valueLen = 4 + i32(!value);
|
|
906
|
+
memory.copy(
|
|
907
|
+
changetype<usize>(result) + (<usize>offset << 1),
|
|
908
|
+
changetype<usize>(select("true", "false", value)),
|
|
909
|
+
valueLen << 1
|
|
910
|
+
);
|
|
911
|
+
offset += valueLen;
|
|
912
|
+
|
|
913
|
+
if (estLen > offset) return result.substring(0, offset);
|
|
914
|
+
return result;
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
export function joinIntegerArray<T>(dataStart: usize, length: i32, separator: string): string {
|
|
918
|
+
let lastIndex = length - 1;
|
|
919
|
+
if (lastIndex < 0) return "";
|
|
920
|
+
if (!lastIndex) {
|
|
921
|
+
let value = load<T>(dataStart);
|
|
922
|
+
if (isSigned<T>()) {
|
|
923
|
+
if (sizeof<T>() <= 4) {
|
|
924
|
+
// @ts-ignore: type
|
|
925
|
+
return changetype<string>(itoa32(<i32>value, 10));
|
|
926
|
+
} else {
|
|
927
|
+
// @ts-ignore: type
|
|
928
|
+
return changetype<string>(itoa64(<i32>value, 10));
|
|
929
|
+
}
|
|
930
|
+
} else {
|
|
931
|
+
if (sizeof<T>() <= 4) {
|
|
932
|
+
// @ts-ignore: type
|
|
933
|
+
return changetype<string>(utoa32(<u32>value, 10));
|
|
934
|
+
} else {
|
|
935
|
+
// @ts-ignore: type
|
|
936
|
+
return changetype<string>(utoa64(<u64>value, 10));
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
let sepLen = separator.length;
|
|
942
|
+
const valueLen = (sizeof<T>() <= 4 ? 10 : 20) + i32(isSigned<T>());
|
|
943
|
+
let estLen = (valueLen + sepLen) * lastIndex + valueLen;
|
|
944
|
+
let result = changetype<string>(__new(estLen << 1, idof<string>()));
|
|
945
|
+
let offset = 0;
|
|
946
|
+
let value: T;
|
|
947
|
+
for (let i = 0; i < lastIndex; ++i) {
|
|
948
|
+
value = load<T>(dataStart + (<usize>i << alignof<T>()));
|
|
949
|
+
// @ts-ignore: type
|
|
950
|
+
offset += itoa_buffered<T>(changetype<usize>(result) + (<usize>offset << 1), value);
|
|
951
|
+
if (sepLen) {
|
|
952
|
+
memory.copy(
|
|
953
|
+
changetype<usize>(result) + (<usize>offset << 1),
|
|
954
|
+
changetype<usize>(separator),
|
|
955
|
+
<usize>sepLen << 1
|
|
956
|
+
);
|
|
957
|
+
offset += sepLen;
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
value = load<T>(dataStart + (<usize>lastIndex << alignof<T>()));
|
|
961
|
+
// @ts-ignore: type
|
|
962
|
+
offset += itoa_buffered<T>(changetype<usize>(result) + (<usize>offset << 1), value);
|
|
963
|
+
if (estLen > offset) return result.substring(0, offset);
|
|
964
|
+
return result;
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
export function joinFloatArray<T>(dataStart: usize, length: i32, separator: string): string {
|
|
968
|
+
let lastIndex = length - 1;
|
|
969
|
+
if (lastIndex < 0) return "";
|
|
970
|
+
if (!lastIndex) {
|
|
971
|
+
return changetype<string>(dtoa(
|
|
972
|
+
// @ts-ignore: type
|
|
973
|
+
load<T>(dataStart))
|
|
974
|
+
);
|
|
975
|
+
}
|
|
976
|
+
|
|
977
|
+
const valueLen = MAX_DOUBLE_LENGTH;
|
|
978
|
+
let sepLen = separator.length;
|
|
979
|
+
let estLen = (valueLen + sepLen) * lastIndex + valueLen;
|
|
980
|
+
let result = changetype<string>(__new(estLen << 1, idof<string>()));
|
|
981
|
+
let offset = 0;
|
|
982
|
+
let value: T;
|
|
983
|
+
for (let i = 0; i < lastIndex; ++i) {
|
|
984
|
+
value = load<T>(dataStart + (<usize>i << alignof<T>()));
|
|
985
|
+
// @ts-ignore: type
|
|
986
|
+
offset += dtoa_buffered(changetype<usize>(result) + (<usize>offset << 1), value);
|
|
987
|
+
if (sepLen) {
|
|
988
|
+
memory.copy(
|
|
989
|
+
changetype<usize>(result) + (<usize>offset << 1),
|
|
990
|
+
changetype<usize>(separator),
|
|
991
|
+
<usize>sepLen << 1
|
|
992
|
+
);
|
|
993
|
+
offset += sepLen;
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
value = load<T>(dataStart + (<usize>lastIndex << alignof<T>()));
|
|
997
|
+
// @ts-ignore: type
|
|
998
|
+
offset += dtoa_buffered(changetype<usize>(result) + (<usize>offset << 1), value);
|
|
999
|
+
if (estLen > offset) return result.substring(0, offset);
|
|
1000
|
+
return result;
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
export function joinStringArray(dataStart: usize, length: i32, separator: string): string {
|
|
1004
|
+
let lastIndex = length - 1;
|
|
1005
|
+
if (lastIndex < 0) return "";
|
|
1006
|
+
if (!lastIndex) {
|
|
1007
|
+
// @ts-ignore: type
|
|
1008
|
+
return load<string>(dataStart) || "";
|
|
1009
|
+
}
|
|
1010
|
+
let estLen = 0;
|
|
1011
|
+
let value: string;
|
|
1012
|
+
for (let i = 0; i < length; ++i) {
|
|
1013
|
+
value = load<string>(dataStart + (<usize>i << alignof<string>()));
|
|
1014
|
+
if (changetype<usize>(value) != 0) estLen += value.length;
|
|
1015
|
+
}
|
|
1016
|
+
let offset = 0;
|
|
1017
|
+
let sepLen = separator.length;
|
|
1018
|
+
let result = changetype<string>(__new((estLen + sepLen * lastIndex) << 1, idof<string>()));
|
|
1019
|
+
for (let i = 0; i < lastIndex; ++i) {
|
|
1020
|
+
value = load<string>(dataStart + (<usize>i << alignof<string>()));
|
|
1021
|
+
if (changetype<usize>(value) != 0) {
|
|
1022
|
+
let valueLen = value.length;
|
|
1023
|
+
memory.copy(
|
|
1024
|
+
changetype<usize>(result) + (<usize>offset << 1),
|
|
1025
|
+
changetype<usize>(value),
|
|
1026
|
+
<usize>valueLen << 1
|
|
1027
|
+
);
|
|
1028
|
+
offset += valueLen;
|
|
1029
|
+
}
|
|
1030
|
+
if (sepLen) {
|
|
1031
|
+
memory.copy(
|
|
1032
|
+
changetype<usize>(result) + (<usize>offset << 1),
|
|
1033
|
+
changetype<usize>(separator),
|
|
1034
|
+
<usize>sepLen << 1
|
|
1035
|
+
);
|
|
1036
|
+
offset += sepLen;
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
value = load<string>(dataStart + (<usize>lastIndex << alignof<string>()));
|
|
1040
|
+
if (changetype<usize>(value) != 0) {
|
|
1041
|
+
memory.copy(
|
|
1042
|
+
changetype<usize>(result) + (<usize>offset << 1),
|
|
1043
|
+
changetype<usize>(value),
|
|
1044
|
+
<usize>value.length << 1
|
|
1045
|
+
);
|
|
1046
|
+
}
|
|
1047
|
+
return result;
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1050
|
+
export function joinReferenceArray<T>(dataStart: usize, length: i32, separator: string): string {
|
|
1051
|
+
let lastIndex = length - 1;
|
|
1052
|
+
if (lastIndex < 0) return "";
|
|
1053
|
+
let value: T;
|
|
1054
|
+
if (!lastIndex) {
|
|
1055
|
+
value = load<T>(dataStart);
|
|
1056
|
+
// @ts-ignore: type
|
|
1057
|
+
return value != null ? value.toString() : "";
|
|
1058
|
+
}
|
|
1059
|
+
let result = "";
|
|
1060
|
+
let sepLen = separator.length;
|
|
1061
|
+
for (let i = 0; i < lastIndex; ++i) {
|
|
1062
|
+
value = load<T>(dataStart + (<usize>i << alignof<T>()));
|
|
1063
|
+
// @ts-ignore: type
|
|
1064
|
+
if (value != null) result += value.toString();
|
|
1065
|
+
if (sepLen) result += separator;
|
|
1066
|
+
}
|
|
1067
|
+
value = load<T>(dataStart + (<usize>lastIndex << alignof<T>()));
|
|
1068
|
+
// @ts-ignore: type
|
|
1069
|
+
if (value != null) result += value.toString();
|
|
1070
|
+
return result;
|
|
1071
|
+
}
|
|
1072
|
+
|
|
1073
|
+
// @ts-ignore: decorator
|
|
1074
|
+
@inline
|
|
1075
|
+
function scientific(significand: u64, exp: i32): f64 {
|
|
1076
|
+
if (!significand || exp < -342) return 0;
|
|
1077
|
+
if (exp > 308) return Infinity;
|
|
1078
|
+
// Try use fast path
|
|
1079
|
+
// Use fast path for string-to-double conversion if possible
|
|
1080
|
+
// see http://www.exploringbinary.com/fast-path-decimal-to-floating-point-conversion
|
|
1081
|
+
// Simple integer
|
|
1082
|
+
let significandf = <f64>significand;
|
|
1083
|
+
if (!exp) return significandf;
|
|
1084
|
+
if (exp > 22 && exp <= 22 + 15) {
|
|
1085
|
+
significandf *= pow10(exp - 22);
|
|
1086
|
+
exp = 22;
|
|
1087
|
+
}
|
|
1088
|
+
if (significand <= 9007199254740991 && abs(exp) <= 22) {
|
|
1089
|
+
if (exp > 0) return significandf * pow10(exp);
|
|
1090
|
+
return significandf / pow10(-exp);
|
|
1091
|
+
} else if (exp < 0) {
|
|
1092
|
+
return scaledown(significand, exp);
|
|
1093
|
+
} else {
|
|
1094
|
+
return scaleup(significand, exp);
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1098
|
+
// Adopted from metallic lib:
|
|
1099
|
+
// https://github.com/jdh8/metallic/blob/master/src/stdlib/parse/scientific.h
|
|
1100
|
+
// @ts-ignore: decorator
|
|
1101
|
+
@inline
|
|
1102
|
+
function scaledown(significand: u64, exp: i32): f64 {
|
|
1103
|
+
const denom: u64 = 6103515625; // 1e14 * 0x1p-14
|
|
1104
|
+
const scale = reinterpret<f64>(0x3F06849B86A12B9B); // 1e-14 * 0x1p32
|
|
1105
|
+
|
|
1106
|
+
let shift = clz(significand);
|
|
1107
|
+
significand <<= shift;
|
|
1108
|
+
shift = exp - shift;
|
|
1109
|
+
|
|
1110
|
+
for (; exp <= -14; exp += 14) {
|
|
1111
|
+
let q = significand / denom;
|
|
1112
|
+
let r = significand % denom;
|
|
1113
|
+
let s = clz(q);
|
|
1114
|
+
significand = (q << s) + <u64>nearest(scale * <f64>(r << (s - 18)));
|
|
1115
|
+
shift -= s;
|
|
1116
|
+
}
|
|
1117
|
+
let b = <u64>ipow32(5, -exp);
|
|
1118
|
+
let q = significand / b;
|
|
1119
|
+
let r = significand % b;
|
|
1120
|
+
let s = clz(q);
|
|
1121
|
+
significand = (q << s) + <u64>(reinterpret<f64>(reinterpret<u64>(<f64>r) + (s << 52)) / <f64>b);
|
|
1122
|
+
shift -= s;
|
|
1123
|
+
|
|
1124
|
+
return NativeMath.scalbn(<f64>significand, <i32>shift);
|
|
1125
|
+
}
|
|
1126
|
+
|
|
1127
|
+
// Adopted from metallic lib:
|
|
1128
|
+
// https://github.com/jdh8/metallic/blob/master/src/stdlib/parse/scientific.h
|
|
1129
|
+
// @ts-ignore: decorator
|
|
1130
|
+
@inline
|
|
1131
|
+
function scaleup(significand: u64, exp: i32): f64 {
|
|
1132
|
+
const coeff: u32 = 1220703125; // 1e13 * 0x1p-13;
|
|
1133
|
+
let shift = ctz(significand);
|
|
1134
|
+
significand >>= shift;
|
|
1135
|
+
shift += exp;
|
|
1136
|
+
|
|
1137
|
+
__fixmulShift = shift;
|
|
1138
|
+
for (; exp >= 13; exp -= 13) {
|
|
1139
|
+
significand = fixmul(significand, coeff);
|
|
1140
|
+
}
|
|
1141
|
+
significand = fixmul(significand, <u32>ipow32(5, exp));
|
|
1142
|
+
shift = __fixmulShift;
|
|
1143
|
+
return NativeMath.scalbn(<f64>significand, <i32>shift);
|
|
1144
|
+
}
|
|
1145
|
+
|
|
1146
|
+
// Adopted from metallic lib:
|
|
1147
|
+
// https://github.com/jdh8/metallic/blob/master/src/stdlib/parse/scientific.h
|
|
1148
|
+
// @ts-ignore: decorator
|
|
1149
|
+
@inline
|
|
1150
|
+
function parseExp(ptr: usize, len: i32): i32 {
|
|
1151
|
+
let sign = 1, magnitude = 0;
|
|
1152
|
+
let code = <u32>load<u16>(ptr);
|
|
1153
|
+
// check code is 'e' or 'E'
|
|
1154
|
+
if ((code | 32) != CharCode.e) return 0;
|
|
1155
|
+
|
|
1156
|
+
if (!--len) return 0;
|
|
1157
|
+
code = <u32>load<u16>(ptr += 2);
|
|
1158
|
+
if (code == CharCode.MINUS) {
|
|
1159
|
+
if (!--len) return 0;
|
|
1160
|
+
code = <u32>load<u16>(ptr += 2);
|
|
1161
|
+
sign = -1;
|
|
1162
|
+
} else if (code == CharCode.PLUS) {
|
|
1163
|
+
if (!--len) return 0;
|
|
1164
|
+
code = <u32>load<u16>(ptr += 2);
|
|
1165
|
+
}
|
|
1166
|
+
// skip zeros
|
|
1167
|
+
while (code == CharCode._0) {
|
|
1168
|
+
if (!--len) return 0;
|
|
1169
|
+
code = <u32>load<u16>(ptr += 2);
|
|
1170
|
+
}
|
|
1171
|
+
for (let digit: u32 = code - CharCode._0; len && digit < 10; digit = code - CharCode._0) {
|
|
1172
|
+
if (magnitude >= 3200) return sign * 3200;
|
|
1173
|
+
magnitude = 10 * magnitude + digit;
|
|
1174
|
+
code = <u32>load<u16>(ptr += 2);
|
|
1175
|
+
--len;
|
|
1176
|
+
}
|
|
1177
|
+
return sign * magnitude;
|
|
1178
|
+
}
|
|
1179
|
+
|
|
1180
|
+
// @ts-ignore: decorator
|
|
1181
|
+
@lazy let __fixmulShift: u64 = 0;
|
|
1182
|
+
|
|
1183
|
+
// Adopted from metallic lib:
|
|
1184
|
+
// https://github.com/jdh8/metallic/blob/master/src/stdlib/parse/scientific.h
|
|
1185
|
+
// @ts-ignore: decorator
|
|
1186
|
+
@inline
|
|
1187
|
+
function fixmul(a: u64, b: u32): u64 {
|
|
1188
|
+
let low = (a & 0xFFFFFFFF) * b;
|
|
1189
|
+
let high = (a >> 32) * b + (low >> 32);
|
|
1190
|
+
let overflow = <u32>(high >> 32);
|
|
1191
|
+
let space = clz(overflow);
|
|
1192
|
+
let revspace: u64 = 32 - space;
|
|
1193
|
+
__fixmulShift += revspace;
|
|
1194
|
+
return (high << space | (low & 0xFFFFFFFF) >> revspace) + (low << space >> 31 & 1);
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1197
|
+
// @ts-ignore: decorator
|
|
1198
|
+
@inline
|
|
1199
|
+
function pow10(n: i32): f64 {
|
|
1200
|
+
// argument `n` should bounds in [0, 22] range
|
|
1201
|
+
return load<f64>(POWERS10 + (n << alignof<f64>()));
|
|
1202
|
+
}
|