toilscript 0.0.1 → 0.1.0
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 +0 -0
- package/dist/asc.generated.d.ts +10022 -0
- package/dist/asc.js +24457 -0
- package/dist/asc.js.map +7 -0
- package/dist/importmap.json +9 -0
- package/dist/toilscript.generated.d.ts +11237 -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 +2891 -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/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,1954 +1,1954 @@
|
|
|
1
|
-
import { COMPARATOR, SORT } from "./util/sort";
|
|
2
|
-
import { E_INDEXOUTOFRANGE, E_INVALIDLENGTH, E_NOTIMPLEMENTED } from "./util/error";
|
|
3
|
-
import { joinIntegerArray, joinFloatArray } from "./util/string";
|
|
4
|
-
import { Runtime } from "shared/runtime";
|
|
5
|
-
import { REVERSE, FILL } from "./util/bytes";
|
|
6
|
-
import { idof } from "./builtins";
|
|
7
|
-
import { ArrayBufferView } from "./arraybuffer";
|
|
8
|
-
|
|
9
|
-
export class Int8Array extends ArrayBufferView {
|
|
10
|
-
[key: number]: i8;
|
|
11
|
-
|
|
12
|
-
// @ts-ignore: decorator
|
|
13
|
-
@lazy
|
|
14
|
-
static readonly BYTES_PER_ELEMENT: i32 = sizeof<i8>();
|
|
15
|
-
|
|
16
|
-
constructor(length: i32) {
|
|
17
|
-
super(length, alignof<i8>());
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
get length(): i32 {
|
|
21
|
-
return this.byteLength;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
@operator("[]")
|
|
25
|
-
private __get(index: i32): i8 {
|
|
26
|
-
if (<u32>index >= <u32>this.byteLength) throw new RangeError(E_INDEXOUTOFRANGE);
|
|
27
|
-
return load<i8>(this.dataStart + <usize>index);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
@unsafe @operator("{}")
|
|
31
|
-
private __uget(index: i32): i8 {
|
|
32
|
-
return load<i8>(this.dataStart + <usize>index);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
@operator("[]=")
|
|
36
|
-
private __set(index: i32, value: native<i8>): void {
|
|
37
|
-
if (<u32>index >= <u32>this.byteLength) throw new RangeError(E_INDEXOUTOFRANGE);
|
|
38
|
-
store<i8>(this.dataStart + <usize>index, value);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
@unsafe @operator("{}=")
|
|
42
|
-
private __uset(index: i32, value: native<i8>): void {
|
|
43
|
-
store<i8>(this.dataStart + <usize>index, value);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
at(index: i32): i8 {
|
|
47
|
-
let len = this.byteLength;
|
|
48
|
-
index += select(0, len, index >= 0);
|
|
49
|
-
if (<u32>index >= <u32>len) throw new RangeError(E_INDEXOUTOFRANGE);
|
|
50
|
-
return load<i8>(this.dataStart + <usize>index);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
includes(searchElement: i8, fromIndex: i32 = 0): bool {
|
|
54
|
-
return INCLUDES<Int8Array, i8>(this, searchElement, fromIndex);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
indexOf(searchElement: i8, fromIndex: i32 = 0): i32 {
|
|
58
|
-
return INDEX_OF<Int8Array, i8>(this, searchElement, fromIndex);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
lastIndexOf(searchElement: i8, fromIndex: i32 = this.length): i32 {
|
|
62
|
-
return LAST_INDEX_OF<Int8Array, i8>(this, searchElement, fromIndex);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
fill(value: i32, start: i32 = 0, end: i32 = i32.MAX_VALUE): Int8Array {
|
|
66
|
-
FILL<u8>(this.dataStart, this.length, u8(value), start, end);
|
|
67
|
-
return this;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
sort(comparator: (a: i8, b: i8) => i32 = COMPARATOR<i8>()): Int8Array {
|
|
71
|
-
SORT<i8>(this.dataStart, this.length, comparator);
|
|
72
|
-
return this;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
slice(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Int8Array {
|
|
76
|
-
return SLICE<Int8Array, i8>(this, begin, end);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
subarray(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Int8Array {
|
|
80
|
-
return SUBARRAY<Int8Array, i8>(this, begin, end);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
copyWithin(target: i32, start: i32, end: i32 = i32.MAX_VALUE): Int8Array {
|
|
84
|
-
return COPY_WITHIN<Int8Array, i8>(this, target, start, end);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
reduce<T extends number>(
|
|
88
|
-
fn: (accumulator: T, value: i8, index: i32, array: Int8Array) => T,
|
|
89
|
-
initialValue: T,
|
|
90
|
-
): T {
|
|
91
|
-
return REDUCE<Int8Array, i8, T>(this, fn, initialValue);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
reduceRight<T extends number>(
|
|
95
|
-
fn: (accumulator: T, value: i8, index: i32, array: Int8Array) => T,
|
|
96
|
-
initialValue: T,
|
|
97
|
-
): T {
|
|
98
|
-
return REDUCE_RIGHT<Int8Array, i8, T>(this, fn, initialValue);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
map(fn: (value: i8, index: i32, self: Int8Array) => i8): Int8Array {
|
|
102
|
-
return MAP<Int8Array, i8>(this, fn);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
filter(fn: (value: i8, index: i32, self: Int8Array) => bool): Int8Array {
|
|
106
|
-
return FILTER<Int8Array, i8>(this, fn);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
findIndex(fn: (value: i8, index: i32, self: Int8Array) => bool): i32 {
|
|
110
|
-
return FIND_INDEX<Int8Array, i8>(this, fn);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
findLastIndex(fn: (value: i8, index: i32, self: Int8Array) => bool): i32 {
|
|
114
|
-
return FIND_LAST_INDEX<Int8Array, i8>(this, fn);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
some(fn: (value: i8, index: i32, self: Int8Array) => bool): bool {
|
|
118
|
-
return SOME<Int8Array, i8>(this, fn);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
every(fn: (value: i8, index: i32, self: Int8Array) => bool): bool {
|
|
122
|
-
return EVERY<Int8Array, i8>(this, fn);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
forEach(fn: (value: i8, index: i32, self: Int8Array) => void): void {
|
|
126
|
-
FOREACH<Int8Array, i8>(this, fn);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
reverse(): Int8Array {
|
|
130
|
-
REVERSE<u8>(this.dataStart, this.length);
|
|
131
|
-
return this;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
join(separator: string = ","): string {
|
|
135
|
-
return joinIntegerArray<i8>(this.dataStart, this.length, separator);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
toString(): string {
|
|
139
|
-
return this.join();
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
set<U extends ArrayLike<number>>(source: U, offset: i32 = 0): void {
|
|
143
|
-
SET(this, source, offset);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
static wrap(buffer: ArrayBuffer, byteOffset: i32 = 0, length: i32 = -1): Int8Array {
|
|
147
|
-
return WRAP<Int8Array, i8>(buffer, byteOffset, length);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
export class Uint8Array extends ArrayBufferView {
|
|
152
|
-
[key: number]: u8;
|
|
153
|
-
|
|
154
|
-
// @ts-ignore: decorator
|
|
155
|
-
@lazy
|
|
156
|
-
static readonly BYTES_PER_ELEMENT: i32 = sizeof<u8>();
|
|
157
|
-
|
|
158
|
-
constructor(length: i32) {
|
|
159
|
-
super(length, alignof<u8>());
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
get length(): i32 {
|
|
163
|
-
return this.byteLength;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
@operator("[]")
|
|
167
|
-
private __get(index: i32): u8 {
|
|
168
|
-
if (<u32>index >= <u32>this.byteLength) throw new RangeError(E_INDEXOUTOFRANGE);
|
|
169
|
-
return load<u8>(this.dataStart + <usize>index);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
@unsafe @operator("{}")
|
|
173
|
-
private __uget(index: i32): u8 {
|
|
174
|
-
return load<u8>(this.dataStart + <usize>index);
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
@operator("[]=")
|
|
178
|
-
private __set(index: i32, value: native<u8>): void {
|
|
179
|
-
if (<u32>index >= <u32>this.byteLength) throw new RangeError(E_INDEXOUTOFRANGE);
|
|
180
|
-
store<u8>(this.dataStart + <usize>index, value);
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
@unsafe @operator("{}=")
|
|
184
|
-
private __uset(index: i32, value: native<u8>): void {
|
|
185
|
-
store<u8>(this.dataStart + <usize>index, value);
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
at(index: i32): u8 {
|
|
189
|
-
let len = this.byteLength;
|
|
190
|
-
index += select(0, len, index >= 0);
|
|
191
|
-
if (<u32>index >= <u32>len) throw new RangeError(E_INDEXOUTOFRANGE);
|
|
192
|
-
return load<u8>(this.dataStart + <usize>index);
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
includes(searchElement: u8, fromIndex: i32 = 0): bool {
|
|
196
|
-
return INCLUDES<Uint8Array, u8>(this, searchElement, fromIndex);
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
indexOf(searchElement: u8, fromIndex: i32 = 0): i32 {
|
|
200
|
-
return INDEX_OF<Uint8Array, u8>(this, searchElement, fromIndex);
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
lastIndexOf(searchElement: u8, fromIndex: i32 = this.length): i32 {
|
|
204
|
-
return LAST_INDEX_OF<Uint8Array, u8>(this, searchElement, fromIndex);
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
fill(value: u32, start: i32 = 0, end: i32 = i32.MAX_VALUE): Uint8Array {
|
|
208
|
-
FILL<u8>(this.dataStart, this.length, u8(value), start, end);
|
|
209
|
-
return this;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
sort(comparator: (a: u8, b: u8) => i32 = COMPARATOR<u8>()): Uint8Array {
|
|
213
|
-
SORT<u8>(this.dataStart, this.length, comparator);
|
|
214
|
-
return this;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
slice(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Uint8Array {
|
|
218
|
-
return SLICE<Uint8Array, u8>(this, begin, end);
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
subarray(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Uint8Array {
|
|
222
|
-
return SUBARRAY<Uint8Array, u8>(this, begin, end);
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
copyWithin(target: i32, start: i32, end: i32 = i32.MAX_VALUE): Uint8Array {
|
|
226
|
-
return COPY_WITHIN<Uint8Array, u8>(this, target, start, end);
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
reduce<T extends number>(
|
|
230
|
-
fn: (accumulator: T, value: u8, index: i32, array: Uint8Array) => T,
|
|
231
|
-
initialValue: T,
|
|
232
|
-
): T {
|
|
233
|
-
return REDUCE<Uint8Array, u8, T>(this, fn, initialValue);
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
reduceRight<T extends number>(
|
|
237
|
-
fn: (accumulator: T, value: u8, index: i32, array: Uint8Array) => T,
|
|
238
|
-
initialValue: T,
|
|
239
|
-
): T {
|
|
240
|
-
return REDUCE_RIGHT<Uint8Array, u8, T>(this, fn, initialValue);
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
map(fn: (value: u8, index: i32, self: Uint8Array) => u8): Uint8Array {
|
|
244
|
-
return MAP<Uint8Array, u8>(this, fn);
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
filter(fn: (value: u8, index: i32, self: Uint8Array) => bool): Uint8Array {
|
|
248
|
-
return FILTER<Uint8Array, u8>(this, fn);
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
findIndex(fn: (value: u8, index: i32, self: Uint8Array) => bool): i32 {
|
|
252
|
-
return FIND_INDEX<Uint8Array, u8>(this, fn);
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
findLastIndex(fn: (value: u8, index: i32, self: Uint8Array) => bool): i32 {
|
|
256
|
-
return FIND_LAST_INDEX<Uint8Array, u8>(this, fn);
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
some(fn: (value: u8, index: i32, self: Uint8Array) => bool): bool {
|
|
260
|
-
return SOME<Uint8Array, u8>(this, fn);
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
every(fn: (value: u8, index: i32, self: Uint8Array) => bool): bool {
|
|
264
|
-
return EVERY<Uint8Array, u8>(this, fn);
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
forEach(fn: (value: u8, index: i32, self: Uint8Array) => void): void {
|
|
268
|
-
FOREACH<Uint8Array, u8>(this, fn);
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
reverse(): Uint8Array {
|
|
272
|
-
REVERSE<u8>(this.dataStart, this.length);
|
|
273
|
-
return this;
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
join(separator: string = ","): string {
|
|
277
|
-
return joinIntegerArray<u8>(this.dataStart, this.length, separator);
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
set<U extends ArrayLike<number>>(source: U, offset: i32 = 0): void {
|
|
281
|
-
SET(this, source, offset);
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
toString(): string {
|
|
285
|
-
return this.join();
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
static wrap(buffer: ArrayBuffer, byteOffset: i32 = 0, length: i32 = -1): Uint8Array {
|
|
289
|
-
return WRAP<Uint8Array, u8>(buffer, byteOffset, length);
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
export class Uint8ClampedArray extends ArrayBufferView {
|
|
294
|
-
[key: number]: u8;
|
|
295
|
-
|
|
296
|
-
// @ts-ignore: decorator
|
|
297
|
-
@lazy
|
|
298
|
-
static readonly BYTES_PER_ELEMENT: i32 = sizeof<u8>();
|
|
299
|
-
|
|
300
|
-
constructor(length: i32) {
|
|
301
|
-
super(length, alignof<u8>());
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
get length(): i32 {
|
|
305
|
-
return this.byteLength;
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
@operator("[]")
|
|
309
|
-
private __get(index: i32): u8 {
|
|
310
|
-
if (<u32>index >= <u32>this.byteLength) throw new RangeError(E_INDEXOUTOFRANGE);
|
|
311
|
-
return load<u8>(this.dataStart + <usize>index);
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
@unsafe @operator("{}")
|
|
315
|
-
private __uget(index: i32): u8 {
|
|
316
|
-
return load<u8>(this.dataStart + <usize>index);
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
@operator("[]=")
|
|
320
|
-
private __set(index: i32, value: native<u8>): void {
|
|
321
|
-
if (<u32>index >= <u32>this.byteLength) throw new RangeError(E_INDEXOUTOFRANGE);
|
|
322
|
-
store<u8>(this.dataStart + <usize>index, ~(<i32>value >> 31) & (((255 - value) >> 31) | value));
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
@unsafe @operator("{}=")
|
|
326
|
-
private __uset(index: i32, value: native<u8>): void {
|
|
327
|
-
store<u8>(this.dataStart + <usize>index, ~(<i32>value >> 31) & (((255 - value) >> 31) | value));
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
at(index: i32): u8 {
|
|
331
|
-
let len = this.byteLength;
|
|
332
|
-
index += select(0, len, index >= 0);
|
|
333
|
-
if (<u32>index >= <u32>len) throw new RangeError(E_INDEXOUTOFRANGE);
|
|
334
|
-
return load<u8>(this.dataStart + <usize>index);
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
includes(searchElement: u8, fromIndex: i32 = 0): bool {
|
|
338
|
-
return INCLUDES<Uint8ClampedArray, u8>(this, searchElement, fromIndex);
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
indexOf(searchElement: u8, fromIndex: i32 = 0): i32 {
|
|
342
|
-
return INDEX_OF<Uint8ClampedArray, u8>(this, searchElement, fromIndex);
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
lastIndexOf(searchElement: u8, fromIndex: i32 = this.length): i32 {
|
|
346
|
-
return LAST_INDEX_OF<Uint8ClampedArray, u8>(this, searchElement, fromIndex);
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
fill(value: i32, start: i32 = 0, end: i32 = i32.MAX_VALUE): Uint8ClampedArray {
|
|
350
|
-
value = ~(value >> 31) & (((255 - value) >> 31) | value);
|
|
351
|
-
FILL<u8>(this.dataStart, this.length, u8(value), start, end);
|
|
352
|
-
return this;
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
sort(comparator: (a: u8, b: u8) => i32 = COMPARATOR<u8>()): Uint8ClampedArray {
|
|
356
|
-
SORT<u8>(this.dataStart, this.length, comparator);
|
|
357
|
-
return this;
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
slice(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Uint8ClampedArray {
|
|
361
|
-
return SLICE<Uint8ClampedArray, u8>(this, begin, end);
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
subarray(start: i32 = 0, end: i32 = i32.MAX_VALUE): Uint8ClampedArray {
|
|
365
|
-
return SUBARRAY<Uint8ClampedArray, u8>(this, start, end);
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
copyWithin(target: i32, start: i32, end: i32 = i32.MAX_VALUE): Uint8ClampedArray {
|
|
369
|
-
return COPY_WITHIN<Uint8ClampedArray, u8>(this, target, start, end);
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
reduce<T extends number>(
|
|
373
|
-
fn: (accumulator: T, value: u8, index: i32, array: Uint8ClampedArray) => T,
|
|
374
|
-
initialValue: T,
|
|
375
|
-
): T {
|
|
376
|
-
return REDUCE<Uint8ClampedArray, u8, T>(this, fn, initialValue);
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
reduceRight<T extends number>(
|
|
380
|
-
fn: (accumulator: T, value: u8, index: i32, array: Uint8ClampedArray) => T,
|
|
381
|
-
initialValue: T,
|
|
382
|
-
): T {
|
|
383
|
-
return REDUCE_RIGHT<Uint8ClampedArray, u8, T>(this, fn, initialValue);
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
map(fn: (value: u8, index: i32, self: Uint8ClampedArray) => u8): Uint8ClampedArray {
|
|
387
|
-
return MAP<Uint8ClampedArray, u8>(this, fn);
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
filter(fn: (value: u8, index: i32, self: Uint8ClampedArray) => bool): Uint8ClampedArray {
|
|
391
|
-
return FILTER<Uint8ClampedArray, u8>(this, fn);
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
findIndex(fn: (value: u8, index: i32, self: Uint8ClampedArray) => bool): i32 {
|
|
395
|
-
return FIND_INDEX<Uint8ClampedArray, u8>(this, fn);
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
findLastIndex(fn: (value: u8, index: i32, self: Uint8ClampedArray) => bool): i32 {
|
|
399
|
-
return FIND_LAST_INDEX<Uint8ClampedArray, u8>(this, fn);
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
some(fn: (value: u8, index: i32, self: Uint8ClampedArray) => bool): bool {
|
|
403
|
-
return SOME<Uint8ClampedArray, u8>(this, fn);
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
every(fn: (value: u8, index: i32, self: Uint8ClampedArray) => bool): bool {
|
|
407
|
-
return EVERY<Uint8ClampedArray, u8>(this, fn);
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
forEach(fn: (value: u8, index: i32, self: Uint8ClampedArray) => void): void {
|
|
411
|
-
FOREACH<Uint8ClampedArray, u8>(this, fn);
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
reverse(): Uint8ClampedArray {
|
|
415
|
-
REVERSE<u8>(this.dataStart, this.length);
|
|
416
|
-
return this;
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
join(separator: string = ","): string {
|
|
420
|
-
return joinIntegerArray<u8>(this.dataStart, this.length, separator);
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
set<U extends ArrayLike<number>>(source: U, offset: i32 = 0): void {
|
|
424
|
-
SET(this, source, offset);
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
toString(): string {
|
|
428
|
-
return this.join();
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
static wrap(buffer: ArrayBuffer, byteOffset: i32 = 0, length: i32 = -1): Uint8ClampedArray {
|
|
432
|
-
return WRAP<Uint8ClampedArray, u8>(buffer, byteOffset, length);
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
export class Int16Array extends ArrayBufferView {
|
|
437
|
-
[key: number]: i16;
|
|
438
|
-
|
|
439
|
-
// @ts-ignore: decorator
|
|
440
|
-
@lazy
|
|
441
|
-
static readonly BYTES_PER_ELEMENT: i32 = sizeof<i16>();
|
|
442
|
-
|
|
443
|
-
constructor(length: i32) {
|
|
444
|
-
super(length, alignof<i16>());
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
get length(): i32 {
|
|
448
|
-
return this.byteLength >>> alignof<i16>();
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
@operator("[]")
|
|
452
|
-
private __get(index: i32): i16 {
|
|
453
|
-
if (<u32>index >= <u32>this.byteLength >>> alignof<i16>()) throw new RangeError(E_INDEXOUTOFRANGE);
|
|
454
|
-
return load<i16>(this.dataStart + (<usize>index << alignof<i16>()));
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
@unsafe @operator("{}")
|
|
458
|
-
private __uget(index: i32): i16 {
|
|
459
|
-
return load<i16>(this.dataStart + (<usize>index << alignof<i16>()));
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
@operator("[]=")
|
|
463
|
-
private __set(index: i32, value: native<i16>): void {
|
|
464
|
-
if (<u32>index >= <u32>this.byteLength >>> alignof<i16>()) throw new RangeError(E_INDEXOUTOFRANGE);
|
|
465
|
-
store<i16>(this.dataStart + (<usize>index << alignof<i16>()), value);
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
@unsafe @operator("{}=")
|
|
469
|
-
private __uset(index: i32, value: native<i16>): void {
|
|
470
|
-
store<i16>(this.dataStart + (<usize>index << alignof<i16>()), value);
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
at(index: i32): i16 {
|
|
474
|
-
let len = this.byteLength >>> alignof<i16>();
|
|
475
|
-
index += select(0, len, index >= 0);
|
|
476
|
-
if (<u32>index >= <u32>len) throw new RangeError(E_INDEXOUTOFRANGE);
|
|
477
|
-
return load<i16>(this.dataStart + (<usize>index << alignof<i16>()));
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
includes(searchElement: i16, fromIndex: i32 = 0): bool {
|
|
481
|
-
return INCLUDES<Int16Array, i16>(this, searchElement, fromIndex);
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
indexOf(searchElement: i16, fromIndex: i32 = 0): i32 {
|
|
485
|
-
return INDEX_OF<Int16Array, i16>(this, searchElement, fromIndex);
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
lastIndexOf(searchElement: i16, fromIndex: i32 = this.length): i32 {
|
|
489
|
-
return LAST_INDEX_OF<Int16Array, i16>(this, searchElement, fromIndex);
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
fill(value: i32, start: i32 = 0, end: i32 = i32.MAX_VALUE): Int16Array {
|
|
493
|
-
FILL<u16>(this.dataStart, this.length, u16(value), start, end);
|
|
494
|
-
return this;
|
|
495
|
-
}
|
|
496
|
-
|
|
497
|
-
sort(comparator: (a: i16, b: i16) => i32 = COMPARATOR<i16>()): Int16Array {
|
|
498
|
-
SORT<i16>(this.dataStart, this.length, comparator);
|
|
499
|
-
return this;
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
slice(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Int16Array {
|
|
503
|
-
return SLICE<Int16Array, i16>(this, begin, end);
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
subarray(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Int16Array {
|
|
507
|
-
return SUBARRAY<Int16Array, i16>(this, begin, end);
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
copyWithin(target: i32, start: i32, end: i32 = i32.MAX_VALUE): Int16Array {
|
|
511
|
-
return COPY_WITHIN<Int16Array, i16>(this, target, start, end);
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
reduce<T extends number>(
|
|
515
|
-
fn: (accumulator: T, value: i16, index: i32, array: Int16Array) => T,
|
|
516
|
-
initialValue: T,
|
|
517
|
-
): T {
|
|
518
|
-
return REDUCE<Int16Array, i16, T>(this, fn, initialValue);
|
|
519
|
-
}
|
|
520
|
-
|
|
521
|
-
reduceRight<T extends number>(
|
|
522
|
-
fn: (accumulator: T, value: i16, index: i32, array: Int16Array) => T,
|
|
523
|
-
initialValue: T,
|
|
524
|
-
): T {
|
|
525
|
-
return REDUCE_RIGHT<Int16Array, i16, T>(this, fn, initialValue);
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
map(fn: (value: i16, index: i32, self: Int16Array) => i16): Int16Array {
|
|
529
|
-
return MAP<Int16Array, i16>(this, fn);
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
filter(fn: (value: i16, index: i32, self: Int16Array) => bool): Int16Array {
|
|
533
|
-
return FILTER<Int16Array, i16>(this, fn);
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
findIndex(fn: (value: i16, index: i32, self: Int16Array) => bool): i32 {
|
|
537
|
-
return FIND_INDEX<Int16Array, i16>(this, fn);
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
findLastIndex(fn: (value: i16, index: i32, self: Int16Array) => bool): i32 {
|
|
541
|
-
return FIND_LAST_INDEX<Int16Array, i16>(this, fn);
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
some(fn: (value: i16, index: i32, self: Int16Array) => bool): bool {
|
|
545
|
-
return SOME<Int16Array, i16>(this, fn);
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
every(fn: (value: i16, index: i32, self: Int16Array) => bool): bool {
|
|
549
|
-
return EVERY<Int16Array, i16>(this, fn);
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
forEach(fn: (value: i16, index: i32, self: Int16Array) => void): void {
|
|
553
|
-
FOREACH<Int16Array, i16>(this, fn);
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
reverse(): Int16Array {
|
|
557
|
-
REVERSE<u16>(this.dataStart, this.length);
|
|
558
|
-
return this;
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
join(separator: string = ","): string {
|
|
562
|
-
return joinIntegerArray<i16>(this.dataStart, this.length, separator);
|
|
563
|
-
}
|
|
564
|
-
|
|
565
|
-
set<U extends ArrayLike<number>>(source: U, offset: i32 = 0): void {
|
|
566
|
-
SET(this, source, offset);
|
|
567
|
-
}
|
|
568
|
-
|
|
569
|
-
toString(): string {
|
|
570
|
-
return this.join();
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
static wrap(buffer: ArrayBuffer, byteOffset: i32 = 0, length: i32 = -1): Int16Array {
|
|
574
|
-
return WRAP<Int16Array, i16>(buffer, byteOffset, length);
|
|
575
|
-
}
|
|
576
|
-
}
|
|
577
|
-
|
|
578
|
-
export class Uint16Array extends ArrayBufferView {
|
|
579
|
-
[key: number]: u16;
|
|
580
|
-
|
|
581
|
-
// @ts-ignore: decorator
|
|
582
|
-
@lazy
|
|
583
|
-
static readonly BYTES_PER_ELEMENT: i32 = sizeof<u16>();
|
|
584
|
-
|
|
585
|
-
constructor(length: i32) {
|
|
586
|
-
super(length, alignof<u16>());
|
|
587
|
-
}
|
|
588
|
-
|
|
589
|
-
get length(): i32 {
|
|
590
|
-
return this.byteLength >>> alignof<u16>();
|
|
591
|
-
}
|
|
592
|
-
|
|
593
|
-
@operator("[]")
|
|
594
|
-
private __get(index: i32): u16 {
|
|
595
|
-
if (<u32>index >= <u32>this.byteLength >>> alignof<u16>()) throw new RangeError(E_INDEXOUTOFRANGE);
|
|
596
|
-
return load<u16>(this.dataStart + (<usize>index << alignof<u16>()));
|
|
597
|
-
}
|
|
598
|
-
|
|
599
|
-
@unsafe @operator("{}")
|
|
600
|
-
private __uget(index: i32): u16 {
|
|
601
|
-
return load<u16>(this.dataStart + (<usize>index << alignof<u16>()));
|
|
602
|
-
}
|
|
603
|
-
|
|
604
|
-
@operator("[]=")
|
|
605
|
-
private __set(index: i32, value: native<u16>): void {
|
|
606
|
-
if (<u32>index >= <u32>this.byteLength >>> alignof<u16>()) throw new RangeError(E_INDEXOUTOFRANGE);
|
|
607
|
-
store<u16>(this.dataStart + (<usize>index << alignof<u16>()), value);
|
|
608
|
-
}
|
|
609
|
-
|
|
610
|
-
@unsafe @operator("{}=")
|
|
611
|
-
private __uset(index: i32, value: native<u16>): void {
|
|
612
|
-
store<u16>(this.dataStart + (<usize>index << alignof<u16>()), value);
|
|
613
|
-
}
|
|
614
|
-
|
|
615
|
-
at(index: i32): u16 {
|
|
616
|
-
let len = this.byteLength >>> alignof<u16>();
|
|
617
|
-
index += select(0, len, index >= 0);
|
|
618
|
-
if (<u32>index >= <u32>len) throw new RangeError(E_INDEXOUTOFRANGE);
|
|
619
|
-
return load<u16>(this.dataStart + (<usize>index << alignof<u16>()));
|
|
620
|
-
}
|
|
621
|
-
|
|
622
|
-
includes(searchElement: u16, fromIndex: i32 = 0): bool {
|
|
623
|
-
return INCLUDES<Uint16Array, u16>(this, searchElement, fromIndex);
|
|
624
|
-
}
|
|
625
|
-
|
|
626
|
-
indexOf(searchElement: u16, fromIndex: i32 = 0): i32 {
|
|
627
|
-
return INDEX_OF<Uint16Array, u16>(this, searchElement, fromIndex);
|
|
628
|
-
}
|
|
629
|
-
|
|
630
|
-
lastIndexOf(searchElement: u16, fromIndex: i32 = this.length): i32 {
|
|
631
|
-
return LAST_INDEX_OF<Uint16Array, u16>(this, searchElement, fromIndex);
|
|
632
|
-
}
|
|
633
|
-
|
|
634
|
-
fill(value: u32, start: i32 = 0, end: i32 = i32.MAX_VALUE): Uint16Array {
|
|
635
|
-
FILL<u16>(this.dataStart, this.length, u16(value), start, end);
|
|
636
|
-
return this;
|
|
637
|
-
}
|
|
638
|
-
|
|
639
|
-
sort(comparator: (a: u16, b: u16) => i32 = COMPARATOR<u16>()): Uint16Array {
|
|
640
|
-
SORT<u16>(this.dataStart, this.length, comparator);
|
|
641
|
-
return this;
|
|
642
|
-
}
|
|
643
|
-
|
|
644
|
-
slice(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Uint16Array {
|
|
645
|
-
return SLICE<Uint16Array, u16>(this, begin, end);
|
|
646
|
-
}
|
|
647
|
-
|
|
648
|
-
subarray(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Uint16Array {
|
|
649
|
-
return SUBARRAY<Uint16Array, u16>(this, begin, end);
|
|
650
|
-
}
|
|
651
|
-
|
|
652
|
-
copyWithin(target: i32, start: i32, end: i32 = i32.MAX_VALUE): Uint16Array {
|
|
653
|
-
return COPY_WITHIN<Uint16Array, u16>(this, target, start, end);
|
|
654
|
-
}
|
|
655
|
-
|
|
656
|
-
reduce<T extends number>(
|
|
657
|
-
fn: (accumulator: T, value: u16, index: i32, array: Uint16Array) => T,
|
|
658
|
-
initialValue: T,
|
|
659
|
-
): T {
|
|
660
|
-
return REDUCE<Uint16Array, u16, T>(this, fn, initialValue);
|
|
661
|
-
}
|
|
662
|
-
|
|
663
|
-
reduceRight<T extends number>(
|
|
664
|
-
fn: (accumulator: T, value: u16, index: i32, array: Uint16Array) => T,
|
|
665
|
-
initialValue: T,
|
|
666
|
-
): T {
|
|
667
|
-
return REDUCE_RIGHT<Uint16Array, u16, T>(this, fn, initialValue);
|
|
668
|
-
}
|
|
669
|
-
|
|
670
|
-
map(fn: (value: u16, index: i32, self: Uint16Array) => u16): Uint16Array {
|
|
671
|
-
return MAP<Uint16Array, u16>(this, fn);
|
|
672
|
-
}
|
|
673
|
-
|
|
674
|
-
filter(fn: (value: u16, index: i32, self: Uint16Array) => bool): Uint16Array {
|
|
675
|
-
return FILTER<Uint16Array, u16>(this, fn);
|
|
676
|
-
}
|
|
677
|
-
|
|
678
|
-
findIndex(fn: (value: u16, index: i32, self: Uint16Array) => bool): i32 {
|
|
679
|
-
return FIND_INDEX<Uint16Array, u16>(this, fn);
|
|
680
|
-
}
|
|
681
|
-
|
|
682
|
-
findLastIndex(fn: (value: u16, index: i32, self: Uint16Array) => bool): i32 {
|
|
683
|
-
return FIND_LAST_INDEX<Uint16Array, u16>(this, fn);
|
|
684
|
-
}
|
|
685
|
-
|
|
686
|
-
some(fn: (value: u16, index: i32, self: Uint16Array) => bool): bool {
|
|
687
|
-
return SOME<Uint16Array, u16>(this, fn);
|
|
688
|
-
}
|
|
689
|
-
|
|
690
|
-
every(fn: (value: u16, index: i32, self: Uint16Array) => bool): bool {
|
|
691
|
-
return EVERY<Uint16Array, u16>(this, fn);
|
|
692
|
-
}
|
|
693
|
-
|
|
694
|
-
forEach(fn: (value: u16, index: i32, self: Uint16Array) => void): void {
|
|
695
|
-
FOREACH<Uint16Array, u16>(this, fn);
|
|
696
|
-
}
|
|
697
|
-
|
|
698
|
-
reverse(): Uint16Array {
|
|
699
|
-
REVERSE<u16>(this.dataStart, this.length);
|
|
700
|
-
return this;
|
|
701
|
-
}
|
|
702
|
-
|
|
703
|
-
join(separator: string = ","): string {
|
|
704
|
-
return joinIntegerArray<u16>(this.dataStart, this.length, separator);
|
|
705
|
-
}
|
|
706
|
-
|
|
707
|
-
set<U extends ArrayLike<number>>(source: U, offset: i32 = 0): void {
|
|
708
|
-
SET(this, source, offset);
|
|
709
|
-
}
|
|
710
|
-
|
|
711
|
-
toString(): string {
|
|
712
|
-
return this.join();
|
|
713
|
-
}
|
|
714
|
-
|
|
715
|
-
static wrap(buffer: ArrayBuffer, byteOffset: i32 = 0, length: i32 = -1): Uint16Array {
|
|
716
|
-
return WRAP<Uint16Array, u16>(buffer, byteOffset, length);
|
|
717
|
-
}
|
|
718
|
-
}
|
|
719
|
-
|
|
720
|
-
export class Int32Array extends ArrayBufferView {
|
|
721
|
-
[key: number]: i32;
|
|
722
|
-
|
|
723
|
-
// @ts-ignore: decorator
|
|
724
|
-
@lazy
|
|
725
|
-
static readonly BYTES_PER_ELEMENT: i32 = sizeof<i32>();
|
|
726
|
-
|
|
727
|
-
constructor(length: i32) {
|
|
728
|
-
super(length, alignof<i32>());
|
|
729
|
-
}
|
|
730
|
-
|
|
731
|
-
get length(): i32 {
|
|
732
|
-
return this.byteLength >>> alignof<i32>();
|
|
733
|
-
}
|
|
734
|
-
|
|
735
|
-
@operator("[]")
|
|
736
|
-
private __get(index: i32): i32 {
|
|
737
|
-
if (<u32>index >= <u32>this.byteLength >>> alignof<i32>()) throw new RangeError(E_INDEXOUTOFRANGE);
|
|
738
|
-
return load<i32>(this.dataStart + (<usize>index << alignof<i32>()));
|
|
739
|
-
}
|
|
740
|
-
|
|
741
|
-
@unsafe @operator("{}")
|
|
742
|
-
private __uget(index: i32): i32 {
|
|
743
|
-
return load<i32>(this.dataStart + (<usize>index << alignof<i32>()));
|
|
744
|
-
}
|
|
745
|
-
|
|
746
|
-
@operator("[]=")
|
|
747
|
-
private __set(index: i32, value: i32): void {
|
|
748
|
-
if (<u32>index >= <u32>this.byteLength >>> alignof<i32>()) throw new RangeError(E_INDEXOUTOFRANGE);
|
|
749
|
-
store<i32>(this.dataStart + (<usize>index << alignof<i32>()), value);
|
|
750
|
-
}
|
|
751
|
-
|
|
752
|
-
@unsafe @operator("{}=")
|
|
753
|
-
private __uset(index: i32, value: i32): void {
|
|
754
|
-
store<i32>(this.dataStart + (<usize>index << alignof<i32>()), value);
|
|
755
|
-
}
|
|
756
|
-
|
|
757
|
-
at(index: i32): i32 {
|
|
758
|
-
let len = this.byteLength >>> alignof<i32>();
|
|
759
|
-
index += select(0, len, index >= 0);
|
|
760
|
-
if (<u32>index >= <u32>len) throw new RangeError(E_INDEXOUTOFRANGE);
|
|
761
|
-
return load<i32>(this.dataStart + (<usize>index << alignof<i32>()));
|
|
762
|
-
}
|
|
763
|
-
|
|
764
|
-
includes(searchElement: i32, fromIndex: i32 = 0): bool {
|
|
765
|
-
return INCLUDES<Int32Array, i32>(this, searchElement, fromIndex);
|
|
766
|
-
}
|
|
767
|
-
|
|
768
|
-
indexOf(searchElement: i32, fromIndex: i32 = 0): i32 {
|
|
769
|
-
return INDEX_OF<Int32Array, i32>(this, searchElement, fromIndex);
|
|
770
|
-
}
|
|
771
|
-
|
|
772
|
-
lastIndexOf(searchElement: i32, fromIndex: i32 = this.length): i32 {
|
|
773
|
-
return LAST_INDEX_OF<Int32Array, i32>(this, searchElement, fromIndex);
|
|
774
|
-
}
|
|
775
|
-
|
|
776
|
-
fill(value: i32, start: i32 = 0, end: i32 = i32.MAX_VALUE): Int32Array {
|
|
777
|
-
FILL<u32>(this.dataStart, this.length, u32(value), start, end);
|
|
778
|
-
return this;
|
|
779
|
-
}
|
|
780
|
-
|
|
781
|
-
sort(comparator: (a: i32, b: i32) => i32 = COMPARATOR<i32>()): Int32Array {
|
|
782
|
-
SORT<i32>(this.dataStart, this.length, comparator);
|
|
783
|
-
return this;
|
|
784
|
-
}
|
|
785
|
-
|
|
786
|
-
slice(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Int32Array {
|
|
787
|
-
return SLICE<Int32Array, i32>(this, begin, end);
|
|
788
|
-
}
|
|
789
|
-
|
|
790
|
-
subarray(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Int32Array {
|
|
791
|
-
return SUBARRAY<Int32Array, i32>(this, begin, end);
|
|
792
|
-
}
|
|
793
|
-
|
|
794
|
-
copyWithin(target: i32, start: i32, end: i32 = i32.MAX_VALUE): Int32Array {
|
|
795
|
-
return COPY_WITHIN<Int32Array, i32>(this, target, start, end);
|
|
796
|
-
}
|
|
797
|
-
|
|
798
|
-
reduce<T extends number>(
|
|
799
|
-
fn: (accumulator: T, value: i32, index: i32, array: Int32Array) => T,
|
|
800
|
-
initialValue: T,
|
|
801
|
-
): T {
|
|
802
|
-
return REDUCE<Int32Array, i32, T>(this, fn, initialValue);
|
|
803
|
-
}
|
|
804
|
-
|
|
805
|
-
reduceRight<T extends number>(
|
|
806
|
-
fn: (accumulator: T, value: i32, index: i32, array: Int32Array) => T,
|
|
807
|
-
initialValue: T,
|
|
808
|
-
): T {
|
|
809
|
-
return REDUCE_RIGHT<Int32Array, i32, T>(this, fn, initialValue);
|
|
810
|
-
}
|
|
811
|
-
|
|
812
|
-
map(fn: (value: i32, index: i32, self: Int32Array) => i32): Int32Array {
|
|
813
|
-
return MAP<Int32Array, i32>(this, fn);
|
|
814
|
-
}
|
|
815
|
-
|
|
816
|
-
filter(fn: (value: i32, index: i32, self: Int32Array) => bool): Int32Array {
|
|
817
|
-
return FILTER<Int32Array, i32>(this, fn);
|
|
818
|
-
}
|
|
819
|
-
|
|
820
|
-
findIndex(fn: (value: i32, index: i32, self: Int32Array) => bool): i32 {
|
|
821
|
-
return FIND_INDEX<Int32Array, i32>(this, fn);
|
|
822
|
-
}
|
|
823
|
-
|
|
824
|
-
findLastIndex(fn: (value: i32, index: i32, self: Int32Array) => bool): i32 {
|
|
825
|
-
return FIND_LAST_INDEX<Int32Array, i32>(this, fn);
|
|
826
|
-
}
|
|
827
|
-
|
|
828
|
-
some(fn: (value: i32, index: i32, self: Int32Array) => bool): bool {
|
|
829
|
-
return SOME<Int32Array, i32>(this, fn);
|
|
830
|
-
}
|
|
831
|
-
|
|
832
|
-
every(fn: (value: i32, index: i32, self: Int32Array) => bool): bool {
|
|
833
|
-
return EVERY<Int32Array, i32>(this, fn);
|
|
834
|
-
}
|
|
835
|
-
|
|
836
|
-
forEach(fn: (value: i32, index: i32, self: Int32Array) => void): void {
|
|
837
|
-
FOREACH<Int32Array, i32>(this, fn);
|
|
838
|
-
}
|
|
839
|
-
|
|
840
|
-
reverse(): Int32Array {
|
|
841
|
-
REVERSE<u32>(this.dataStart, this.length);
|
|
842
|
-
return this;
|
|
843
|
-
}
|
|
844
|
-
|
|
845
|
-
join(separator: string = ","): string {
|
|
846
|
-
return joinIntegerArray<i32>(this.dataStart, this.length, separator);
|
|
847
|
-
}
|
|
848
|
-
|
|
849
|
-
set<U extends ArrayLike<number>>(source: U, offset: i32 = 0): void {
|
|
850
|
-
SET(this, source, offset);
|
|
851
|
-
}
|
|
852
|
-
|
|
853
|
-
toString(): string {
|
|
854
|
-
return this.join();
|
|
855
|
-
}
|
|
856
|
-
|
|
857
|
-
static wrap(buffer: ArrayBuffer, byteOffset: i32 = 0, length: i32 = -1): Int32Array {
|
|
858
|
-
return WRAP<Int32Array, i32>(buffer, byteOffset, length);
|
|
859
|
-
}
|
|
860
|
-
}
|
|
861
|
-
|
|
862
|
-
export class Uint32Array extends ArrayBufferView {
|
|
863
|
-
[key: number]: u32;
|
|
864
|
-
|
|
865
|
-
// @ts-ignore: decorator
|
|
866
|
-
@lazy
|
|
867
|
-
static readonly BYTES_PER_ELEMENT: i32 = sizeof<u32>();
|
|
868
|
-
|
|
869
|
-
constructor(length: i32) {
|
|
870
|
-
super(length, alignof<u32>());
|
|
871
|
-
}
|
|
872
|
-
|
|
873
|
-
get length(): i32 {
|
|
874
|
-
return this.byteLength >>> alignof<u32>();
|
|
875
|
-
}
|
|
876
|
-
|
|
877
|
-
@operator("[]")
|
|
878
|
-
private __get(index: i32): u32 {
|
|
879
|
-
if (<u32>index >= <u32>this.byteLength >>> alignof<u32>()) throw new RangeError(E_INDEXOUTOFRANGE);
|
|
880
|
-
return load<u32>(this.dataStart + (<usize>index << alignof<u32>()));
|
|
881
|
-
}
|
|
882
|
-
|
|
883
|
-
@unsafe @operator("{}")
|
|
884
|
-
private __uget(index: i32): u32 {
|
|
885
|
-
return load<u32>(this.dataStart + (<usize>index << alignof<u32>()));
|
|
886
|
-
}
|
|
887
|
-
|
|
888
|
-
@operator("[]=")
|
|
889
|
-
private __set(index: i32, value: u32): void {
|
|
890
|
-
if (<u32>index >= <u32>this.byteLength >>> alignof<u32>()) throw new RangeError(E_INDEXOUTOFRANGE);
|
|
891
|
-
store<u32>(this.dataStart + (<usize>index << alignof<u32>()), value);
|
|
892
|
-
}
|
|
893
|
-
|
|
894
|
-
@unsafe @operator("{}=")
|
|
895
|
-
private __uset(index: i32, value: u32): void {
|
|
896
|
-
store<u32>(this.dataStart + (<usize>index << alignof<u32>()), value);
|
|
897
|
-
}
|
|
898
|
-
|
|
899
|
-
at(index: i32): u32 {
|
|
900
|
-
let len = this.byteLength >>> alignof<u32>();
|
|
901
|
-
index += select(0, len, index >= 0);
|
|
902
|
-
if (<u32>index >= <u32>len) throw new RangeError(E_INDEXOUTOFRANGE);
|
|
903
|
-
return load<u32>(this.dataStart + (<usize>index << alignof<u32>()));
|
|
904
|
-
}
|
|
905
|
-
|
|
906
|
-
includes(searchElement: u32, fromIndex: i32 = 0): bool {
|
|
907
|
-
return INCLUDES<Uint32Array, u32>(this, searchElement, fromIndex);
|
|
908
|
-
}
|
|
909
|
-
|
|
910
|
-
indexOf(searchElement: u32, fromIndex: i32 = 0): i32 {
|
|
911
|
-
return INDEX_OF<Uint32Array, u32>(this, searchElement, fromIndex);
|
|
912
|
-
}
|
|
913
|
-
|
|
914
|
-
lastIndexOf(searchElement: u32, fromIndex: i32 = this.length): i32 {
|
|
915
|
-
return LAST_INDEX_OF<Uint32Array, u32>(this, searchElement, fromIndex);
|
|
916
|
-
}
|
|
917
|
-
|
|
918
|
-
fill(value: u32, start: i32 = 0, end: i32 = i32.MAX_VALUE): Uint32Array {
|
|
919
|
-
FILL<u32>(this.dataStart, this.length, value, start, end);
|
|
920
|
-
return this;
|
|
921
|
-
}
|
|
922
|
-
|
|
923
|
-
sort(comparator: (a: u32, b: u32) => i32 = COMPARATOR<u32>()): Uint32Array {
|
|
924
|
-
SORT<u32>(this.dataStart, this.length, comparator);
|
|
925
|
-
return this;
|
|
926
|
-
}
|
|
927
|
-
|
|
928
|
-
slice(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Uint32Array {
|
|
929
|
-
return SLICE<Uint32Array, u32>(this, begin, end);
|
|
930
|
-
}
|
|
931
|
-
|
|
932
|
-
subarray(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Uint32Array {
|
|
933
|
-
return SUBARRAY<Uint32Array, u32>(this, begin, end);
|
|
934
|
-
}
|
|
935
|
-
|
|
936
|
-
copyWithin(target: i32, start: i32, end: i32 = i32.MAX_VALUE): Uint32Array {
|
|
937
|
-
return COPY_WITHIN<Uint32Array, u32>(this, target, start, end);
|
|
938
|
-
}
|
|
939
|
-
|
|
940
|
-
reduce<T extends number>(
|
|
941
|
-
fn: (accumulator: T, value: u32, index: i32, array: Uint32Array) => T,
|
|
942
|
-
initialValue: T,
|
|
943
|
-
): T {
|
|
944
|
-
return REDUCE<Uint32Array, u32, T>(this, fn, initialValue);
|
|
945
|
-
}
|
|
946
|
-
|
|
947
|
-
reduceRight<T extends number>(
|
|
948
|
-
fn: (accumulator: T, value: u32, index: i32, array: Uint32Array) => T,
|
|
949
|
-
initialValue: T,
|
|
950
|
-
): T {
|
|
951
|
-
return REDUCE_RIGHT<Uint32Array, u32, T>(this, fn, initialValue);
|
|
952
|
-
}
|
|
953
|
-
|
|
954
|
-
map(fn: (value: u32, index: i32, self: Uint32Array) => u32): Uint32Array {
|
|
955
|
-
return MAP<Uint32Array, u32>(this, fn);
|
|
956
|
-
}
|
|
957
|
-
|
|
958
|
-
filter(fn: (value: u32, index: i32, self: Uint32Array) => bool): Uint32Array {
|
|
959
|
-
return FILTER<Uint32Array, u32>(this, fn);
|
|
960
|
-
}
|
|
961
|
-
|
|
962
|
-
findIndex(fn: (value: u32, index: i32, self: Uint32Array) => bool): i32 {
|
|
963
|
-
return FIND_INDEX<Uint32Array, u32>(this, fn);
|
|
964
|
-
}
|
|
965
|
-
|
|
966
|
-
findLastIndex(fn: (value: u32, index: i32, self: Uint32Array) => bool): i32 {
|
|
967
|
-
return FIND_LAST_INDEX<Uint32Array, u32>(this, fn);
|
|
968
|
-
}
|
|
969
|
-
|
|
970
|
-
some(fn: (value: u32, index: i32, self: Uint32Array) => bool): bool {
|
|
971
|
-
return SOME<Uint32Array, u32>(this, fn);
|
|
972
|
-
}
|
|
973
|
-
|
|
974
|
-
every(fn: (value: u32, index: i32, self: Uint32Array) => bool): bool {
|
|
975
|
-
return EVERY<Uint32Array, u32>(this, fn);
|
|
976
|
-
}
|
|
977
|
-
|
|
978
|
-
forEach(fn: (value: u32, index: i32, self: Uint32Array) => void): void {
|
|
979
|
-
FOREACH<Uint32Array, u32>(this, fn);
|
|
980
|
-
}
|
|
981
|
-
|
|
982
|
-
reverse(): Uint32Array {
|
|
983
|
-
REVERSE<u32>(this.dataStart, this.length);
|
|
984
|
-
return this;
|
|
985
|
-
}
|
|
986
|
-
|
|
987
|
-
join(separator: string = ","): string {
|
|
988
|
-
return joinIntegerArray<u32>(this.dataStart, this.length, separator);
|
|
989
|
-
}
|
|
990
|
-
|
|
991
|
-
set<U extends ArrayLike<number>>(source: U, offset: i32 = 0): void {
|
|
992
|
-
SET(this, source, offset);
|
|
993
|
-
}
|
|
994
|
-
|
|
995
|
-
toString(): string {
|
|
996
|
-
return this.join();
|
|
997
|
-
}
|
|
998
|
-
|
|
999
|
-
static wrap(buffer: ArrayBuffer, byteOffset: i32 = 0, length: i32 = -1): Uint32Array {
|
|
1000
|
-
return WRAP<Uint32Array, u32>(buffer, byteOffset, length);
|
|
1001
|
-
}
|
|
1002
|
-
}
|
|
1003
|
-
|
|
1004
|
-
export class Int64Array extends ArrayBufferView {
|
|
1005
|
-
[key: number]: i64;
|
|
1006
|
-
|
|
1007
|
-
// @ts-ignore: decorator
|
|
1008
|
-
@lazy
|
|
1009
|
-
static readonly BYTES_PER_ELEMENT: i32 = sizeof<i64>();
|
|
1010
|
-
|
|
1011
|
-
constructor(length: i32) {
|
|
1012
|
-
super(length, alignof<i64>());
|
|
1013
|
-
}
|
|
1014
|
-
|
|
1015
|
-
get length(): i32 {
|
|
1016
|
-
return this.byteLength >>> alignof<i64>();
|
|
1017
|
-
}
|
|
1018
|
-
|
|
1019
|
-
@operator("[]")
|
|
1020
|
-
private __get(index: i32): i64 {
|
|
1021
|
-
if (<u32>index >= <u32>this.byteLength >>> alignof<i64>()) throw new RangeError(E_INDEXOUTOFRANGE);
|
|
1022
|
-
return load<i64>(this.dataStart + (<usize>index << alignof<i64>()));
|
|
1023
|
-
}
|
|
1024
|
-
|
|
1025
|
-
@unsafe @operator("{}")
|
|
1026
|
-
private __uget(index: i32): i64 {
|
|
1027
|
-
return load<i64>(this.dataStart + (<usize>index << alignof<i64>()));
|
|
1028
|
-
}
|
|
1029
|
-
|
|
1030
|
-
@operator("[]=")
|
|
1031
|
-
private __set(index: i32, value: i64): void {
|
|
1032
|
-
if (<u32>index >= <u32>this.byteLength >>> alignof<i64>()) throw new RangeError(E_INDEXOUTOFRANGE);
|
|
1033
|
-
store<i64>(this.dataStart + (<usize>index << alignof<i64>()), value);
|
|
1034
|
-
}
|
|
1035
|
-
|
|
1036
|
-
@unsafe @operator("{}=")
|
|
1037
|
-
private __uset(index: i32, value: i64): void {
|
|
1038
|
-
store<i64>(this.dataStart + (<usize>index << alignof<i64>()), value);
|
|
1039
|
-
}
|
|
1040
|
-
|
|
1041
|
-
at(index: i32): i64 {
|
|
1042
|
-
let len = this.byteLength >>> alignof<i64>();
|
|
1043
|
-
index += select(0, len, index >= 0);
|
|
1044
|
-
if (<u32>index >= <u32>len) throw new RangeError(E_INDEXOUTOFRANGE);
|
|
1045
|
-
return load<i64>(this.dataStart + (<usize>index << alignof<i64>()));
|
|
1046
|
-
}
|
|
1047
|
-
|
|
1048
|
-
includes(searchElement: i64, fromIndex: i32 = 0): bool {
|
|
1049
|
-
return INCLUDES<Int64Array, i64>(this, searchElement, fromIndex);
|
|
1050
|
-
}
|
|
1051
|
-
|
|
1052
|
-
indexOf(searchElement: i64, fromIndex: i32 = 0): i32 {
|
|
1053
|
-
return INDEX_OF<Int64Array, i64>(this, searchElement, fromIndex);
|
|
1054
|
-
}
|
|
1055
|
-
|
|
1056
|
-
lastIndexOf(searchElement: i64, fromIndex: i32 = this.length): i32 {
|
|
1057
|
-
return LAST_INDEX_OF<Int64Array, i64>(this, searchElement, fromIndex);
|
|
1058
|
-
}
|
|
1059
|
-
|
|
1060
|
-
fill(value: i64, start: i32 = 0, end: i32 = i32.MAX_VALUE): Int64Array {
|
|
1061
|
-
FILL<u64>(this.dataStart, this.length, u64(value), start, end);
|
|
1062
|
-
return this;
|
|
1063
|
-
}
|
|
1064
|
-
|
|
1065
|
-
sort(comparator: (a: i64, b: i64) => i32 = COMPARATOR<i64>()): Int64Array {
|
|
1066
|
-
SORT<i64>(this.dataStart, this.length, comparator);
|
|
1067
|
-
return this;
|
|
1068
|
-
}
|
|
1069
|
-
|
|
1070
|
-
slice(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Int64Array {
|
|
1071
|
-
return SLICE<Int64Array, i64>(this, begin, end);
|
|
1072
|
-
}
|
|
1073
|
-
|
|
1074
|
-
subarray(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Int64Array {
|
|
1075
|
-
return SUBARRAY<Int64Array, i64>(this, begin, end);
|
|
1076
|
-
}
|
|
1077
|
-
|
|
1078
|
-
copyWithin(target: i32, start: i32, end: i32 = i32.MAX_VALUE): Int64Array {
|
|
1079
|
-
return COPY_WITHIN<Int64Array, i64>(this, target, start, end);
|
|
1080
|
-
}
|
|
1081
|
-
|
|
1082
|
-
reduce<T extends number>(
|
|
1083
|
-
fn: (accumulator: T, value: i64, index: i32, array: Int64Array) => T,
|
|
1084
|
-
initialValue: T,
|
|
1085
|
-
): T {
|
|
1086
|
-
return REDUCE<Int64Array, i64, T>(this, fn, initialValue);
|
|
1087
|
-
}
|
|
1088
|
-
|
|
1089
|
-
reduceRight<T extends number>(
|
|
1090
|
-
fn: (accumulator: T, value: i64, index: i32, array: Int64Array) => T,
|
|
1091
|
-
initialValue: T,
|
|
1092
|
-
): T {
|
|
1093
|
-
return REDUCE_RIGHT<Int64Array, i64, T>(this, fn, initialValue);
|
|
1094
|
-
}
|
|
1095
|
-
|
|
1096
|
-
map(fn: (value: i64, index: i32, self: Int64Array) => i64): Int64Array {
|
|
1097
|
-
return MAP<Int64Array, i64>(this, fn);
|
|
1098
|
-
}
|
|
1099
|
-
|
|
1100
|
-
filter(fn: (value: i64, index: i32, self: Int64Array) => bool): Int64Array {
|
|
1101
|
-
return FILTER<Int64Array, i64>(this, fn);
|
|
1102
|
-
}
|
|
1103
|
-
|
|
1104
|
-
findIndex(fn: (value: i64, index: i32, self: Int64Array) => bool): i32 {
|
|
1105
|
-
return FIND_INDEX<Int64Array, i64>(this, fn);
|
|
1106
|
-
}
|
|
1107
|
-
|
|
1108
|
-
findLastIndex(fn: (value: i64, index: i32, self: Int64Array) => bool): i32 {
|
|
1109
|
-
return FIND_LAST_INDEX<Int64Array, i64>(this, fn);
|
|
1110
|
-
}
|
|
1111
|
-
|
|
1112
|
-
some(fn: (value: i64, index: i32, self: Int64Array) => bool): bool {
|
|
1113
|
-
return SOME<Int64Array, i64>(this, fn);
|
|
1114
|
-
}
|
|
1115
|
-
|
|
1116
|
-
every(fn: (value: i64, index: i32, self: Int64Array) => bool): bool {
|
|
1117
|
-
return EVERY<Int64Array, i64>(this, fn);
|
|
1118
|
-
}
|
|
1119
|
-
|
|
1120
|
-
forEach(fn: (value: i64, index: i32, self: Int64Array) => void): void {
|
|
1121
|
-
FOREACH<Int64Array, i64>(this, fn);
|
|
1122
|
-
}
|
|
1123
|
-
|
|
1124
|
-
reverse(): Int64Array {
|
|
1125
|
-
REVERSE<u64>(this.dataStart, this.length);
|
|
1126
|
-
return this;
|
|
1127
|
-
}
|
|
1128
|
-
|
|
1129
|
-
join(separator: string = ","): string {
|
|
1130
|
-
return joinIntegerArray<i64>(this.dataStart, this.length, separator);
|
|
1131
|
-
}
|
|
1132
|
-
|
|
1133
|
-
set<U extends ArrayLike<number>>(source: U, offset: i32 = 0): void {
|
|
1134
|
-
SET(this, source, offset);
|
|
1135
|
-
}
|
|
1136
|
-
|
|
1137
|
-
toString(): string {
|
|
1138
|
-
return this.join();
|
|
1139
|
-
}
|
|
1140
|
-
|
|
1141
|
-
static wrap(buffer: ArrayBuffer, byteOffset: i32 = 0, length: i32 = -1): Int64Array {
|
|
1142
|
-
return WRAP<Int64Array, i64>(buffer, byteOffset, length);
|
|
1143
|
-
}
|
|
1144
|
-
}
|
|
1145
|
-
|
|
1146
|
-
export class Uint64Array extends ArrayBufferView {
|
|
1147
|
-
[key: number]: u64;
|
|
1148
|
-
|
|
1149
|
-
// @ts-ignore: decorator
|
|
1150
|
-
@lazy
|
|
1151
|
-
static readonly BYTES_PER_ELEMENT: i32 = sizeof<u64>();
|
|
1152
|
-
|
|
1153
|
-
constructor(length: i32) {
|
|
1154
|
-
super(length, alignof<u64>());
|
|
1155
|
-
}
|
|
1156
|
-
|
|
1157
|
-
get length(): i32 {
|
|
1158
|
-
return this.byteLength >>> alignof<u64>();
|
|
1159
|
-
}
|
|
1160
|
-
|
|
1161
|
-
@operator("[]")
|
|
1162
|
-
private __get(index: i32): u64 {
|
|
1163
|
-
if (<u32>index >= <u32>this.byteLength >>> alignof<u64>()) throw new RangeError(E_INDEXOUTOFRANGE);
|
|
1164
|
-
return load<u64>(this.dataStart + (<usize>index << alignof<u64>()));
|
|
1165
|
-
}
|
|
1166
|
-
|
|
1167
|
-
@unsafe @operator("{}")
|
|
1168
|
-
private __uget(index: i32): u64 {
|
|
1169
|
-
return load<u64>(this.dataStart + (<usize>index << alignof<u64>()));
|
|
1170
|
-
}
|
|
1171
|
-
|
|
1172
|
-
@operator("[]=")
|
|
1173
|
-
private __set(index: i32, value: u64): void {
|
|
1174
|
-
if (<u32>index >= <u32>this.byteLength >>> alignof<u64>()) throw new RangeError(E_INDEXOUTOFRANGE);
|
|
1175
|
-
store<u64>(this.dataStart + (<usize>index << alignof<u64>()), value);
|
|
1176
|
-
}
|
|
1177
|
-
|
|
1178
|
-
@unsafe @operator("{}=")
|
|
1179
|
-
private __uset(index: i32, value: u64): void {
|
|
1180
|
-
store<u64>(this.dataStart + (<usize>index << alignof<u64>()), value);
|
|
1181
|
-
}
|
|
1182
|
-
|
|
1183
|
-
at(index: i32): u64 {
|
|
1184
|
-
let len = this.byteLength >>> alignof<u64>();
|
|
1185
|
-
index += select(0, len, index >= 0);
|
|
1186
|
-
if (<u32>index >= <u32>len) throw new RangeError(E_INDEXOUTOFRANGE);
|
|
1187
|
-
return load<u64>(this.dataStart + (<usize>index << alignof<u64>()));
|
|
1188
|
-
}
|
|
1189
|
-
|
|
1190
|
-
includes(searchElement: u64, fromIndex: i32 = 0): bool {
|
|
1191
|
-
return INCLUDES<Uint64Array, u64>(this, searchElement, fromIndex);
|
|
1192
|
-
}
|
|
1193
|
-
|
|
1194
|
-
indexOf(searchElement: u64, fromIndex: i32 = 0): i32 {
|
|
1195
|
-
return INDEX_OF<Uint64Array, u64>(this, searchElement, fromIndex);
|
|
1196
|
-
}
|
|
1197
|
-
|
|
1198
|
-
lastIndexOf(searchElement: u64, fromIndex: i32 = this.length): i32 {
|
|
1199
|
-
return LAST_INDEX_OF<Uint64Array, u64>(this, searchElement, fromIndex);
|
|
1200
|
-
}
|
|
1201
|
-
|
|
1202
|
-
fill(value: u64, start: i32 = 0, end: i32 = i32.MAX_VALUE): Uint64Array {
|
|
1203
|
-
FILL<u64>(this.dataStart, this.length, value, start, end);
|
|
1204
|
-
return this;
|
|
1205
|
-
}
|
|
1206
|
-
|
|
1207
|
-
sort(comparator: (a: u64, b: u64) => i32 = COMPARATOR<u64>()): Uint64Array {
|
|
1208
|
-
SORT<u64>(this.dataStart, this.length, comparator);
|
|
1209
|
-
return this;
|
|
1210
|
-
}
|
|
1211
|
-
|
|
1212
|
-
slice(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Uint64Array {
|
|
1213
|
-
return SLICE<Uint64Array, u64>(this, begin, end);
|
|
1214
|
-
}
|
|
1215
|
-
|
|
1216
|
-
subarray(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Uint64Array {
|
|
1217
|
-
return SUBARRAY<Uint64Array, u64>(this, begin, end);
|
|
1218
|
-
}
|
|
1219
|
-
|
|
1220
|
-
copyWithin(target: i32, start: i32, end: i32 = i32.MAX_VALUE): Uint64Array {
|
|
1221
|
-
return COPY_WITHIN<Uint64Array, u64>(this, target, start, end);
|
|
1222
|
-
}
|
|
1223
|
-
|
|
1224
|
-
reduce<T extends number>(
|
|
1225
|
-
fn: (accumulator: T, value: u64, index: i32, array: Uint64Array) => T,
|
|
1226
|
-
initialValue: T,
|
|
1227
|
-
): T {
|
|
1228
|
-
return REDUCE<Uint64Array, u64, T>(this, fn, initialValue);
|
|
1229
|
-
}
|
|
1230
|
-
|
|
1231
|
-
reduceRight<T extends number>(
|
|
1232
|
-
fn: (accumulator: T, value: u64, index: i32, array: Uint64Array) => T,
|
|
1233
|
-
initialValue: T,
|
|
1234
|
-
): T {
|
|
1235
|
-
return REDUCE_RIGHT<Uint64Array, u64, T>(this, fn, initialValue);
|
|
1236
|
-
}
|
|
1237
|
-
|
|
1238
|
-
map(fn: (value: u64, index: i32, self: Uint64Array) => u64): Uint64Array {
|
|
1239
|
-
return MAP<Uint64Array, u64>(this, fn);
|
|
1240
|
-
}
|
|
1241
|
-
|
|
1242
|
-
filter(fn: (value: u64, index: i32, self: Uint64Array) => bool): Uint64Array {
|
|
1243
|
-
return FILTER<Uint64Array, u64>(this, fn);
|
|
1244
|
-
}
|
|
1245
|
-
|
|
1246
|
-
findIndex(fn: (value: u64, index: i32, self: Uint64Array) => bool): i32 {
|
|
1247
|
-
return FIND_INDEX<Uint64Array, u64>(this, fn);
|
|
1248
|
-
}
|
|
1249
|
-
|
|
1250
|
-
findLastIndex(fn: (value: u64, index: i32, self: Uint64Array) => bool): i32 {
|
|
1251
|
-
return FIND_LAST_INDEX<Uint64Array, u64>(this, fn);
|
|
1252
|
-
}
|
|
1253
|
-
|
|
1254
|
-
some(fn: (value: u64, index: i32, self: Uint64Array) => bool): bool {
|
|
1255
|
-
return SOME<Uint64Array, u64>(this, fn);
|
|
1256
|
-
}
|
|
1257
|
-
|
|
1258
|
-
every(fn: (value: u64, index: i32, self: Uint64Array) => bool): bool {
|
|
1259
|
-
return EVERY<Uint64Array, u64>(this, fn);
|
|
1260
|
-
}
|
|
1261
|
-
|
|
1262
|
-
forEach(fn: (value: u64, index: i32, self: Uint64Array) => void): void {
|
|
1263
|
-
FOREACH<Uint64Array, u64>(this, fn);
|
|
1264
|
-
}
|
|
1265
|
-
|
|
1266
|
-
reverse(): Uint64Array {
|
|
1267
|
-
REVERSE<u64>(this.dataStart, this.length);
|
|
1268
|
-
return this;
|
|
1269
|
-
}
|
|
1270
|
-
|
|
1271
|
-
join(separator: string = ","): string {
|
|
1272
|
-
return joinIntegerArray<u64>(this.dataStart, this.length, separator);
|
|
1273
|
-
}
|
|
1274
|
-
|
|
1275
|
-
set<U extends ArrayLike<number>>(source: U, offset: i32 = 0): void {
|
|
1276
|
-
SET(this, source, offset);
|
|
1277
|
-
}
|
|
1278
|
-
|
|
1279
|
-
toString(): string {
|
|
1280
|
-
return this.join();
|
|
1281
|
-
}
|
|
1282
|
-
|
|
1283
|
-
static wrap(buffer: ArrayBuffer, byteOffset: i32 = 0, length: i32 = -1): Uint64Array {
|
|
1284
|
-
return WRAP<Uint64Array, u64>(buffer, byteOffset, length);
|
|
1285
|
-
}
|
|
1286
|
-
}
|
|
1287
|
-
|
|
1288
|
-
export class Float32Array extends ArrayBufferView {
|
|
1289
|
-
[key: number]: f32;
|
|
1290
|
-
|
|
1291
|
-
// @ts-ignore: decorator
|
|
1292
|
-
@lazy
|
|
1293
|
-
static readonly BYTES_PER_ELEMENT: i32 = sizeof<f32>();
|
|
1294
|
-
|
|
1295
|
-
constructor(length: i32) {
|
|
1296
|
-
super(length, alignof<f32>());
|
|
1297
|
-
}
|
|
1298
|
-
|
|
1299
|
-
get length(): i32 {
|
|
1300
|
-
return this.byteLength >>> alignof<f32>();
|
|
1301
|
-
}
|
|
1302
|
-
|
|
1303
|
-
@operator("[]")
|
|
1304
|
-
private __get(index: i32): f32 {
|
|
1305
|
-
if (<u32>index >= <u32>this.byteLength >>> alignof<f32>()) throw new RangeError(E_INDEXOUTOFRANGE);
|
|
1306
|
-
return load<f32>(this.dataStart + (<usize>index << alignof<f32>()));
|
|
1307
|
-
}
|
|
1308
|
-
|
|
1309
|
-
@unsafe @operator("{}")
|
|
1310
|
-
private __uget(index: i32): f32 {
|
|
1311
|
-
return load<f32>(this.dataStart + (<usize>index << alignof<f32>()));
|
|
1312
|
-
}
|
|
1313
|
-
|
|
1314
|
-
@operator("[]=")
|
|
1315
|
-
private __set(index: i32, value: f32): void {
|
|
1316
|
-
if (<u32>index >= <u32>this.byteLength >>> alignof<f32>()) throw new RangeError(E_INDEXOUTOFRANGE);
|
|
1317
|
-
store<f32>(this.dataStart + (<usize>index << alignof<f32>()), value);
|
|
1318
|
-
}
|
|
1319
|
-
|
|
1320
|
-
@unsafe @operator("{}=")
|
|
1321
|
-
private __uset(index: i32, value: f32): void {
|
|
1322
|
-
store<f32>(this.dataStart + (<usize>index << alignof<f32>()), value);
|
|
1323
|
-
}
|
|
1324
|
-
|
|
1325
|
-
at(index: i32): f32 {
|
|
1326
|
-
let len = this.byteLength >>> alignof<f32>();
|
|
1327
|
-
index += select(0, len, index >= 0);
|
|
1328
|
-
if (<u32>index >= <u32>len) throw new RangeError(E_INDEXOUTOFRANGE);
|
|
1329
|
-
return load<f32>(this.dataStart + (<usize>index << alignof<f32>()));
|
|
1330
|
-
}
|
|
1331
|
-
|
|
1332
|
-
includes(searchElement: f32, fromIndex: i32 = 0): bool {
|
|
1333
|
-
return INCLUDES<Float32Array, f32>(this, searchElement, fromIndex);
|
|
1334
|
-
}
|
|
1335
|
-
|
|
1336
|
-
indexOf(searchElement: f32, fromIndex: i32 = 0): i32 {
|
|
1337
|
-
return INDEX_OF<Float32Array, f32>(this, searchElement, fromIndex);
|
|
1338
|
-
}
|
|
1339
|
-
|
|
1340
|
-
lastIndexOf(searchElement: f32, fromIndex: i32 = this.length): i32 {
|
|
1341
|
-
return LAST_INDEX_OF<Float32Array, f32>(this, searchElement, fromIndex);
|
|
1342
|
-
}
|
|
1343
|
-
|
|
1344
|
-
fill(value: f32, start: i32 = 0, end: i32 = i32.MAX_VALUE): Float32Array {
|
|
1345
|
-
FILL<f32>(this.dataStart, this.length, value, start, end);
|
|
1346
|
-
return this;
|
|
1347
|
-
}
|
|
1348
|
-
|
|
1349
|
-
sort(comparator: (a: f32, b: f32) => i32 = COMPARATOR<f32>()): Float32Array {
|
|
1350
|
-
SORT<f32>(this.dataStart, this.length, comparator);
|
|
1351
|
-
return this;
|
|
1352
|
-
}
|
|
1353
|
-
|
|
1354
|
-
slice(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Float32Array {
|
|
1355
|
-
return SLICE<Float32Array, f32>(this, begin, end);
|
|
1356
|
-
}
|
|
1357
|
-
|
|
1358
|
-
subarray(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Float32Array {
|
|
1359
|
-
return SUBARRAY<Float32Array, f32>(this, begin, end);
|
|
1360
|
-
}
|
|
1361
|
-
|
|
1362
|
-
copyWithin(target: i32, start: i32, end: i32 = i32.MAX_VALUE): Float32Array {
|
|
1363
|
-
return COPY_WITHIN<Float32Array, f32>(this, target, start, end);
|
|
1364
|
-
}
|
|
1365
|
-
|
|
1366
|
-
reduce<T extends number>(
|
|
1367
|
-
fn: (accumulator: T, value: f32, index: i32, array: Float32Array) => T,
|
|
1368
|
-
initialValue: T,
|
|
1369
|
-
): T {
|
|
1370
|
-
return REDUCE<Float32Array, f32, T>(this, fn, initialValue);
|
|
1371
|
-
}
|
|
1372
|
-
|
|
1373
|
-
reduceRight<T extends number>(
|
|
1374
|
-
fn: (accumulator: T, value: f32, index: i32, array: Float32Array) => T,
|
|
1375
|
-
initialValue: T,
|
|
1376
|
-
): T {
|
|
1377
|
-
return REDUCE_RIGHT<Float32Array, f32, T>(this, fn, initialValue);
|
|
1378
|
-
}
|
|
1379
|
-
|
|
1380
|
-
map(fn: (value: f32, index: i32, self: Float32Array) => f32): Float32Array {
|
|
1381
|
-
return MAP<Float32Array, f32>(this, fn);
|
|
1382
|
-
}
|
|
1383
|
-
|
|
1384
|
-
filter(fn: (value: f32, index: i32, self: Float32Array) => bool): Float32Array {
|
|
1385
|
-
return FILTER<Float32Array, f32>(this, fn);
|
|
1386
|
-
}
|
|
1387
|
-
|
|
1388
|
-
findIndex(fn: (value: f32, index: i32, self: Float32Array) => bool): i32 {
|
|
1389
|
-
return FIND_INDEX<Float32Array, f32>(this, fn);
|
|
1390
|
-
}
|
|
1391
|
-
|
|
1392
|
-
findLastIndex(fn: (value: f32, index: i32, self: Float32Array) => bool): i32 {
|
|
1393
|
-
return FIND_LAST_INDEX<Float32Array, f32>(this, fn);
|
|
1394
|
-
}
|
|
1395
|
-
|
|
1396
|
-
some(fn: (value: f32, index: i32, self: Float32Array) => bool): bool {
|
|
1397
|
-
return SOME<Float32Array, f32>(this, fn);
|
|
1398
|
-
}
|
|
1399
|
-
|
|
1400
|
-
every(fn: (value: f32, index: i32, self: Float32Array) => bool): bool {
|
|
1401
|
-
return EVERY<Float32Array, f32>(this, fn);
|
|
1402
|
-
}
|
|
1403
|
-
|
|
1404
|
-
forEach(fn: (value: f32, index: i32, self: Float32Array) => void): void {
|
|
1405
|
-
FOREACH<Float32Array, f32>(this, fn);
|
|
1406
|
-
}
|
|
1407
|
-
|
|
1408
|
-
reverse(): Float32Array {
|
|
1409
|
-
REVERSE<f32>(this.dataStart, this.length);
|
|
1410
|
-
return this;
|
|
1411
|
-
}
|
|
1412
|
-
|
|
1413
|
-
join(separator: string = ","): string {
|
|
1414
|
-
return joinFloatArray<f32>(this.dataStart, this.length, separator);
|
|
1415
|
-
}
|
|
1416
|
-
|
|
1417
|
-
set<U extends ArrayLike<number>>(source: U, offset: i32 = 0): void {
|
|
1418
|
-
SET(this, source, offset);
|
|
1419
|
-
}
|
|
1420
|
-
|
|
1421
|
-
toString(): string {
|
|
1422
|
-
return this.join();
|
|
1423
|
-
}
|
|
1424
|
-
|
|
1425
|
-
static wrap(buffer: ArrayBuffer, byteOffset: i32 = 0, length: i32 = -1): Float32Array {
|
|
1426
|
-
return WRAP<Float32Array, f32>(buffer, byteOffset, length);
|
|
1427
|
-
}
|
|
1428
|
-
}
|
|
1429
|
-
|
|
1430
|
-
export class Float64Array extends ArrayBufferView {
|
|
1431
|
-
[key: number]: f64;
|
|
1432
|
-
|
|
1433
|
-
// @ts-ignore: decorator
|
|
1434
|
-
@lazy
|
|
1435
|
-
static readonly BYTES_PER_ELEMENT: i32 = sizeof<f64>();
|
|
1436
|
-
|
|
1437
|
-
constructor(length: i32) {
|
|
1438
|
-
super(length, alignof<f64>());
|
|
1439
|
-
}
|
|
1440
|
-
|
|
1441
|
-
get length(): i32 {
|
|
1442
|
-
return this.byteLength >>> alignof<f64>();
|
|
1443
|
-
}
|
|
1444
|
-
|
|
1445
|
-
@operator("[]")
|
|
1446
|
-
private __get(index: i32): f64 {
|
|
1447
|
-
if (<u32>index >= <u32>this.byteLength >>> alignof<f64>()) throw new RangeError(E_INDEXOUTOFRANGE);
|
|
1448
|
-
return load<f64>(this.dataStart + (<usize>index << alignof<f64>()));
|
|
1449
|
-
}
|
|
1450
|
-
|
|
1451
|
-
@unsafe @operator("{}")
|
|
1452
|
-
private __uget(index: i32): f64 {
|
|
1453
|
-
return load<f64>(this.dataStart + (<usize>index << alignof<f64>()));
|
|
1454
|
-
}
|
|
1455
|
-
|
|
1456
|
-
@operator("[]=")
|
|
1457
|
-
private __set(index: i32, value: f64): void {
|
|
1458
|
-
if (<u32>index >= <u32>this.byteLength >>> alignof<f64>()) throw new RangeError(E_INDEXOUTOFRANGE);
|
|
1459
|
-
store<f64>(this.dataStart + (<usize>index << alignof<f64>()), value);
|
|
1460
|
-
}
|
|
1461
|
-
|
|
1462
|
-
@unsafe @operator("{}=")
|
|
1463
|
-
private __uset(index: i32, value: f64): void {
|
|
1464
|
-
store<f64>(this.dataStart + (<usize>index << alignof<f64>()), value);
|
|
1465
|
-
}
|
|
1466
|
-
|
|
1467
|
-
at(index: i32): f64 {
|
|
1468
|
-
let len = this.byteLength >>> alignof<f64>();
|
|
1469
|
-
index += select(0, len, index >= 0);
|
|
1470
|
-
if (<u32>index >= <u32>len) throw new RangeError(E_INDEXOUTOFRANGE);
|
|
1471
|
-
return load<f64>(this.dataStart + (<usize>index << alignof<f64>()));
|
|
1472
|
-
}
|
|
1473
|
-
|
|
1474
|
-
includes(searchElement: f64, fromIndex: i32 = 0): bool {
|
|
1475
|
-
return INCLUDES<Float64Array, f64>(this, searchElement, fromIndex);
|
|
1476
|
-
}
|
|
1477
|
-
|
|
1478
|
-
indexOf(searchElement: f64, fromIndex: i32 = 0): i32 {
|
|
1479
|
-
return INDEX_OF<Float64Array, f64>(this, searchElement, fromIndex);
|
|
1480
|
-
}
|
|
1481
|
-
|
|
1482
|
-
lastIndexOf(searchElement: f64, fromIndex: i32 = this.length): i32 {
|
|
1483
|
-
return LAST_INDEX_OF<Float64Array, f64>(this, searchElement, fromIndex);
|
|
1484
|
-
}
|
|
1485
|
-
|
|
1486
|
-
fill(value: f64, start: i32 = 0, end: i32 = i32.MAX_VALUE): Float64Array {
|
|
1487
|
-
FILL<f64>(this.dataStart, this.length, value, start, end);
|
|
1488
|
-
return this;
|
|
1489
|
-
}
|
|
1490
|
-
|
|
1491
|
-
sort(comparator: (a: f64, b: f64) => i32 = COMPARATOR<f64>()): Float64Array {
|
|
1492
|
-
SORT<f64>(this.dataStart, this.length, comparator);
|
|
1493
|
-
return this;
|
|
1494
|
-
}
|
|
1495
|
-
|
|
1496
|
-
slice(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Float64Array {
|
|
1497
|
-
return SLICE<Float64Array, f64>(this, begin, end);
|
|
1498
|
-
}
|
|
1499
|
-
|
|
1500
|
-
subarray(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Float64Array {
|
|
1501
|
-
return SUBARRAY<Float64Array, f64>(this, begin, end);
|
|
1502
|
-
}
|
|
1503
|
-
|
|
1504
|
-
copyWithin(target: i32, start: i32, end: i32 = i32.MAX_VALUE): Float64Array {
|
|
1505
|
-
return COPY_WITHIN<Float64Array, f64>(this, target, start, end);
|
|
1506
|
-
}
|
|
1507
|
-
|
|
1508
|
-
reduce<T extends number>(
|
|
1509
|
-
fn: (accumulator: T, value: f64, index: i32, array: Float64Array) => T,
|
|
1510
|
-
initialValue: T,
|
|
1511
|
-
): T {
|
|
1512
|
-
return REDUCE<Float64Array, f64, T>(this, fn, initialValue);
|
|
1513
|
-
}
|
|
1514
|
-
|
|
1515
|
-
reduceRight<T extends number>(
|
|
1516
|
-
fn: (accumulator: T, value: f64, index: i32, array: Float64Array) => T,
|
|
1517
|
-
initialValue: T,
|
|
1518
|
-
): T {
|
|
1519
|
-
return REDUCE_RIGHT<Float64Array, f64, T>(this, fn, initialValue);
|
|
1520
|
-
}
|
|
1521
|
-
|
|
1522
|
-
map(fn: (value: f64, index: i32, self: Float64Array) => f64): Float64Array {
|
|
1523
|
-
return MAP<Float64Array, f64>(this, fn);
|
|
1524
|
-
}
|
|
1525
|
-
|
|
1526
|
-
filter(fn: (value: f64, index: i32, self: Float64Array) => bool): Float64Array {
|
|
1527
|
-
return FILTER<Float64Array, f64>(this, fn);
|
|
1528
|
-
}
|
|
1529
|
-
|
|
1530
|
-
findIndex(fn: (value: f64, index: i32, self: Float64Array) => bool): i32 {
|
|
1531
|
-
return FIND_INDEX<Float64Array, f64>(this, fn);
|
|
1532
|
-
}
|
|
1533
|
-
|
|
1534
|
-
findLastIndex(fn: (value: f64, index: i32, self: Float64Array) => bool): i32 {
|
|
1535
|
-
return FIND_LAST_INDEX<Float64Array, f64>(this, fn);
|
|
1536
|
-
}
|
|
1537
|
-
|
|
1538
|
-
some(fn: (value: f64, index: i32, self: Float64Array) => bool): bool {
|
|
1539
|
-
return SOME<Float64Array, f64>(this, fn);
|
|
1540
|
-
}
|
|
1541
|
-
|
|
1542
|
-
every(fn: (value: f64, index: i32, self: Float64Array) => bool): bool {
|
|
1543
|
-
return EVERY<Float64Array, f64>(this, fn);
|
|
1544
|
-
}
|
|
1545
|
-
|
|
1546
|
-
forEach(fn: (value: f64, index: i32, self: Float64Array) => void): void {
|
|
1547
|
-
FOREACH<Float64Array, f64>(this, fn);
|
|
1548
|
-
}
|
|
1549
|
-
|
|
1550
|
-
reverse(): Float64Array {
|
|
1551
|
-
REVERSE<f64>(this.dataStart, this.length);
|
|
1552
|
-
return this;
|
|
1553
|
-
}
|
|
1554
|
-
|
|
1555
|
-
join(separator: string = ","): string {
|
|
1556
|
-
return joinFloatArray<f64>(this.dataStart, this.length, separator);
|
|
1557
|
-
}
|
|
1558
|
-
|
|
1559
|
-
set<U extends ArrayLike<number>>(source: U, offset: i32 = 0): void {
|
|
1560
|
-
SET(this, source, offset);
|
|
1561
|
-
}
|
|
1562
|
-
|
|
1563
|
-
toString(): string {
|
|
1564
|
-
return this.join();
|
|
1565
|
-
}
|
|
1566
|
-
|
|
1567
|
-
static wrap(buffer: ArrayBuffer, byteOffset: i32 = 0, length: i32 = -1): Float64Array {
|
|
1568
|
-
return WRAP<Float64Array, f64>(buffer, byteOffset, length);
|
|
1569
|
-
}
|
|
1570
|
-
}
|
|
1571
|
-
|
|
1572
|
-
// @ts-ignore: decorator
|
|
1573
|
-
@inline
|
|
1574
|
-
function SLICE<TArray extends ArrayBufferView, T extends number>(
|
|
1575
|
-
array: TArray,
|
|
1576
|
-
start: i32,
|
|
1577
|
-
end: i32
|
|
1578
|
-
): TArray {
|
|
1579
|
-
let len = array.length;
|
|
1580
|
-
start = start < 0 ? max(start + len, 0) : min(start, len);
|
|
1581
|
-
end = end < 0 ? max(end + len, 0) : min(end , len);
|
|
1582
|
-
len = max(end - start, 0);
|
|
1583
|
-
let slice = instantiate<TArray>(len);
|
|
1584
|
-
memory.copy(
|
|
1585
|
-
slice.dataStart,
|
|
1586
|
-
array.dataStart + (<usize>start << alignof<T>()),
|
|
1587
|
-
<usize>len << alignof<T>()
|
|
1588
|
-
);
|
|
1589
|
-
return slice;
|
|
1590
|
-
}
|
|
1591
|
-
|
|
1592
|
-
// @ts-ignore: decorator
|
|
1593
|
-
@inline
|
|
1594
|
-
function SUBARRAY<TArray extends ArrayBufferView, T extends number>(
|
|
1595
|
-
array: TArray,
|
|
1596
|
-
begin: i32,
|
|
1597
|
-
end: i32
|
|
1598
|
-
): TArray {
|
|
1599
|
-
let len = array.length;
|
|
1600
|
-
begin = begin < 0 ? max(len + begin, 0) : min(begin, len);
|
|
1601
|
-
end = end < 0 ? max(len + end, 0) : min(end, len);
|
|
1602
|
-
end = max(end, begin);
|
|
1603
|
-
|
|
1604
|
-
let out = changetype<TArray>(__new(offsetof<TArray>(), idof<TArray>()));
|
|
1605
|
-
let buf = changetype<usize>(array.buffer);
|
|
1606
|
-
store<usize>(changetype<usize>(out), buf, offsetof<TArray>("buffer"));
|
|
1607
|
-
if (ASC_RUNTIME != Runtime.Memory) {
|
|
1608
|
-
__link(changetype<usize>(out), buf, false);
|
|
1609
|
-
}
|
|
1610
|
-
store<usize>(changetype<usize>(out), array.dataStart + (<usize>begin << alignof<T>()), offsetof<TArray>("dataStart"));
|
|
1611
|
-
store<u32>(changetype<usize>(out), (end - begin) << alignof<T>(), offsetof<TArray>("byteLength"));
|
|
1612
|
-
return out;
|
|
1613
|
-
}
|
|
1614
|
-
|
|
1615
|
-
// @ts-ignore: decorator
|
|
1616
|
-
@inline
|
|
1617
|
-
function COPY_WITHIN<TArray extends ArrayBufferView, T extends number>(
|
|
1618
|
-
array: TArray,
|
|
1619
|
-
target: i32,
|
|
1620
|
-
start: i32,
|
|
1621
|
-
end: i32
|
|
1622
|
-
): TArray {
|
|
1623
|
-
let len = array.length;
|
|
1624
|
-
let ptr = array.dataStart;
|
|
1625
|
-
|
|
1626
|
-
end = min<i32>(end, len);
|
|
1627
|
-
let to = target < 0 ? max(len + target, 0) : min(target, len);
|
|
1628
|
-
let from = start < 0 ? max(len + start, 0) : min(start, len);
|
|
1629
|
-
let last = end < 0 ? max(len + end, 0) : min(end, len);
|
|
1630
|
-
let count = min(last - from, len - to);
|
|
1631
|
-
|
|
1632
|
-
memory.copy(
|
|
1633
|
-
ptr + (<usize>to << alignof<T>()),
|
|
1634
|
-
ptr + (<usize>from << alignof<T>()),
|
|
1635
|
-
<usize>count << alignof<T>()
|
|
1636
|
-
);
|
|
1637
|
-
return array;
|
|
1638
|
-
}
|
|
1639
|
-
|
|
1640
|
-
// @ts-ignore: decorator
|
|
1641
|
-
@inline
|
|
1642
|
-
function REDUCE<TArray extends ArrayBufferView, T extends number, TRet extends number>(
|
|
1643
|
-
array: TArray,
|
|
1644
|
-
fn: (accumulator: TRet, value: T, index: i32, array: TArray) => TRet,
|
|
1645
|
-
initialValue: TRet
|
|
1646
|
-
): TRet {
|
|
1647
|
-
let ptr = array.dataStart;
|
|
1648
|
-
for (let i = 0, k = array.length; i < k; i++) {
|
|
1649
|
-
initialValue = fn(initialValue, load<T>(ptr + (<usize>i << alignof<T>())), i, array);
|
|
1650
|
-
}
|
|
1651
|
-
return initialValue;
|
|
1652
|
-
}
|
|
1653
|
-
|
|
1654
|
-
// @ts-ignore: decorator
|
|
1655
|
-
@inline
|
|
1656
|
-
function REDUCE_RIGHT<TArray extends ArrayBufferView, T extends number, TRet extends number>(
|
|
1657
|
-
array: TArray,
|
|
1658
|
-
fn: (accumulator: TRet, value: T, index: i32, array: TArray) => TRet,
|
|
1659
|
-
initialValue: TRet
|
|
1660
|
-
): TRet {
|
|
1661
|
-
let ptr = array.dataStart;
|
|
1662
|
-
for (let i = array.length - 1; i >= 0; i--) {
|
|
1663
|
-
initialValue = fn(initialValue, load<T>(ptr + (<usize>i << alignof<T>())), i, array);
|
|
1664
|
-
}
|
|
1665
|
-
return initialValue;
|
|
1666
|
-
}
|
|
1667
|
-
|
|
1668
|
-
// @ts-ignore: decorator
|
|
1669
|
-
@inline
|
|
1670
|
-
function MAP<TArray extends ArrayBufferView, T extends number>(
|
|
1671
|
-
array: TArray,
|
|
1672
|
-
fn: (value: T, index: i32, self: TArray) => T,
|
|
1673
|
-
): TArray {
|
|
1674
|
-
let len = array.length;
|
|
1675
|
-
let ptr = array.dataStart;
|
|
1676
|
-
|
|
1677
|
-
let byteLength = len << alignof<T>();
|
|
1678
|
-
let out = changetype<TArray>(__new(offsetof<TArray>(), idof<TArray>()));
|
|
1679
|
-
let buf = changetype<ArrayBuffer>(__new(byteLength, idof<ArrayBuffer>()));
|
|
1680
|
-
for (let i = 0; i < len; i++) {
|
|
1681
|
-
store<T>(
|
|
1682
|
-
changetype<usize>(buf) + (<usize>i << alignof<T>()),
|
|
1683
|
-
fn(load<T>(ptr + (<usize>i << alignof<T>())), i, array)
|
|
1684
|
-
);
|
|
1685
|
-
}
|
|
1686
|
-
store<usize>(changetype<usize>(out), changetype<usize>(buf), offsetof<TArray>("buffer"));
|
|
1687
|
-
if (ASC_RUNTIME != Runtime.Memory) {
|
|
1688
|
-
__link(changetype<usize>(out), changetype<usize>(buf), false);
|
|
1689
|
-
}
|
|
1690
|
-
store<usize>(changetype<usize>(out), changetype<usize>(buf), offsetof<TArray>("dataStart"));
|
|
1691
|
-
store<u32>(changetype<usize>(out), byteLength, offsetof<TArray>("byteLength"));
|
|
1692
|
-
return out;
|
|
1693
|
-
}
|
|
1694
|
-
|
|
1695
|
-
// @ts-ignore: decorator
|
|
1696
|
-
@inline
|
|
1697
|
-
function FILTER<TArray extends ArrayBufferView, T extends number>(
|
|
1698
|
-
array: TArray,
|
|
1699
|
-
fn: (value: T, index: i32, self: TArray) => bool,
|
|
1700
|
-
): TArray {
|
|
1701
|
-
let len = array.length;
|
|
1702
|
-
let out = changetype<TArray>(__new(offsetof<TArray>(), idof<TArray>()));
|
|
1703
|
-
let buf = changetype<ArrayBuffer>(__new(len << alignof<T>(), idof<ArrayBuffer>()));
|
|
1704
|
-
let dataStart = array.dataStart;
|
|
1705
|
-
let j: usize = 0;
|
|
1706
|
-
for (let i = 0; i < len; i++) {
|
|
1707
|
-
let value = load<T>(dataStart + (<usize>i << alignof<T>()));
|
|
1708
|
-
if (fn(value, i, array)) {
|
|
1709
|
-
store<T>(
|
|
1710
|
-
changetype<usize>(buf) + (j++ << alignof<T>()),
|
|
1711
|
-
value
|
|
1712
|
-
);
|
|
1713
|
-
}
|
|
1714
|
-
}
|
|
1715
|
-
// shrink output buffer
|
|
1716
|
-
let byteLength = j << alignof<T>();
|
|
1717
|
-
let data = __renew(changetype<usize>(buf), byteLength);
|
|
1718
|
-
store<usize>(changetype<usize>(out), data, offsetof<TArray>("buffer"));
|
|
1719
|
-
if (ASC_RUNTIME != Runtime.Memory) {
|
|
1720
|
-
__link(changetype<usize>(out), data, false);
|
|
1721
|
-
}
|
|
1722
|
-
store<u32>(changetype<usize>(out), byteLength, offsetof<TArray>("byteLength"));
|
|
1723
|
-
store<usize>(changetype<usize>(out), data, offsetof<TArray>("dataStart"));
|
|
1724
|
-
return out;
|
|
1725
|
-
}
|
|
1726
|
-
|
|
1727
|
-
// @ts-ignore: decorator
|
|
1728
|
-
@inline
|
|
1729
|
-
function FIND_INDEX<TArray extends ArrayBufferView, T extends number>(
|
|
1730
|
-
array: TArray,
|
|
1731
|
-
fn: (value: T, index: i32, array: TArray) => bool,
|
|
1732
|
-
): i32 {
|
|
1733
|
-
let ptr = array.dataStart;
|
|
1734
|
-
for (let i = 0, k = array.length; i < k; i++) {
|
|
1735
|
-
if (fn(load<T>(ptr + (<usize>i << alignof<T>())), i, array)) return i;
|
|
1736
|
-
}
|
|
1737
|
-
return -1;
|
|
1738
|
-
}
|
|
1739
|
-
|
|
1740
|
-
// @ts-ignore: decorator
|
|
1741
|
-
@inline
|
|
1742
|
-
function FIND_LAST_INDEX<TArray extends ArrayBufferView, T extends number>(
|
|
1743
|
-
array: TArray,
|
|
1744
|
-
fn: (value: T, index: i32, array: TArray) => bool,
|
|
1745
|
-
): i32 {
|
|
1746
|
-
let ptr = array.dataStart;
|
|
1747
|
-
for (let i = array.length - 1; i >= 0; --i) {
|
|
1748
|
-
if (fn(load<T>(ptr + (<usize>i << alignof<T>())), i, array)) return i;
|
|
1749
|
-
}
|
|
1750
|
-
return -1;
|
|
1751
|
-
}
|
|
1752
|
-
|
|
1753
|
-
// @ts-ignore: decorator
|
|
1754
|
-
@inline
|
|
1755
|
-
function INCLUDES<TArray extends ArrayBufferView, T extends number>(
|
|
1756
|
-
array: TArray,
|
|
1757
|
-
searchElement: T,
|
|
1758
|
-
fromIndex: i32,
|
|
1759
|
-
): bool {
|
|
1760
|
-
if (isFloat<T>()) {
|
|
1761
|
-
let index: isize = fromIndex;
|
|
1762
|
-
let len: isize = array.length;
|
|
1763
|
-
if (len == 0 || index >= len) return false;
|
|
1764
|
-
if (index < 0) index = max(len + index, 0);
|
|
1765
|
-
let dataStart = array.dataStart;
|
|
1766
|
-
while (index < len) {
|
|
1767
|
-
let elem = load<T>(dataStart + (index << alignof<T>()));
|
|
1768
|
-
// @ts-ignore
|
|
1769
|
-
if (elem == searchElement || isNaN(elem) & isNaN(searchElement)) return true;
|
|
1770
|
-
++index;
|
|
1771
|
-
}
|
|
1772
|
-
return false;
|
|
1773
|
-
} else {
|
|
1774
|
-
return INDEX_OF<TArray, T>(array, searchElement, fromIndex) >= 0;
|
|
1775
|
-
}
|
|
1776
|
-
}
|
|
1777
|
-
|
|
1778
|
-
// @ts-ignore: decorator
|
|
1779
|
-
@inline
|
|
1780
|
-
function INDEX_OF<TArray extends ArrayBufferView, T extends number>(
|
|
1781
|
-
array: TArray,
|
|
1782
|
-
searchElement: T,
|
|
1783
|
-
fromIndex: i32,
|
|
1784
|
-
): i32 {
|
|
1785
|
-
let index: isize = fromIndex;
|
|
1786
|
-
let len: isize = array.length;
|
|
1787
|
-
if (len == 0 || index >= len) return -1;
|
|
1788
|
-
if (index < 0) index = max(len + index, 0);
|
|
1789
|
-
let dataStart = array.dataStart;
|
|
1790
|
-
while (index < len) {
|
|
1791
|
-
if (load<T>(dataStart + (index << alignof<T>())) == searchElement) return <i32>index;
|
|
1792
|
-
++index;
|
|
1793
|
-
}
|
|
1794
|
-
return -1;
|
|
1795
|
-
}
|
|
1796
|
-
|
|
1797
|
-
// @ts-ignore: decorator
|
|
1798
|
-
@inline
|
|
1799
|
-
function LAST_INDEX_OF<TArray extends ArrayBufferView, T extends number>(
|
|
1800
|
-
array: TArray,
|
|
1801
|
-
searchElement: T,
|
|
1802
|
-
fromIndex: i32,
|
|
1803
|
-
): i32 {
|
|
1804
|
-
let index: isize = fromIndex;
|
|
1805
|
-
let len: isize = array.length;
|
|
1806
|
-
if (len == 0) return -1;
|
|
1807
|
-
if (index < 0) index = len + index; // no need to clamp
|
|
1808
|
-
else if (index >= len) index = len - 1;
|
|
1809
|
-
let dataStart = array.dataStart;
|
|
1810
|
-
while (index >= 0) {
|
|
1811
|
-
if (load<T>(dataStart + (index << alignof<T>())) == searchElement) return <i32>index;
|
|
1812
|
-
--index;
|
|
1813
|
-
}
|
|
1814
|
-
return -1;
|
|
1815
|
-
}
|
|
1816
|
-
|
|
1817
|
-
// @ts-ignore: decorator
|
|
1818
|
-
@inline
|
|
1819
|
-
function SOME<TArray extends ArrayBufferView, T extends number>(
|
|
1820
|
-
array: TArray,
|
|
1821
|
-
fn: (value: T, index: i32, array: TArray) => bool,
|
|
1822
|
-
): bool {
|
|
1823
|
-
let ptr = array.dataStart;
|
|
1824
|
-
for (let i = 0, k = array.length; i < k; i++) {
|
|
1825
|
-
if (fn(load<T>(ptr + (<usize>i << alignof<T>())), i, array)) return true;
|
|
1826
|
-
}
|
|
1827
|
-
return false;
|
|
1828
|
-
}
|
|
1829
|
-
|
|
1830
|
-
// @ts-ignore: decorator
|
|
1831
|
-
@inline
|
|
1832
|
-
function EVERY<TArray extends ArrayBufferView, T extends number>(
|
|
1833
|
-
array: TArray,
|
|
1834
|
-
fn: (value: T, index: i32, array: TArray) => bool,
|
|
1835
|
-
): bool {
|
|
1836
|
-
let ptr = array.dataStart;
|
|
1837
|
-
for (let i = 0, k = array.length; i < k; i++) {
|
|
1838
|
-
if (fn(load<T>(ptr + (<usize>i << alignof<T>())), i, array)) continue;
|
|
1839
|
-
return false;
|
|
1840
|
-
}
|
|
1841
|
-
return true;
|
|
1842
|
-
}
|
|
1843
|
-
|
|
1844
|
-
// @ts-ignore: decorator
|
|
1845
|
-
@inline
|
|
1846
|
-
function FOREACH<TArray extends ArrayBufferView, T extends number>(
|
|
1847
|
-
array: TArray,
|
|
1848
|
-
fn: (value: T, index: i32, array: TArray) => void,
|
|
1849
|
-
): void {
|
|
1850
|
-
let ptr = array.dataStart;
|
|
1851
|
-
for (let i = 0, k = array.length; i < k; i++) {
|
|
1852
|
-
fn(load<T>(ptr + (<usize>i << alignof<T>())), i, array);
|
|
1853
|
-
}
|
|
1854
|
-
}
|
|
1855
|
-
|
|
1856
|
-
// @ts-ignore: decorator
|
|
1857
|
-
@inline
|
|
1858
|
-
function WRAP<TArray extends ArrayBufferView, T>(
|
|
1859
|
-
buffer: ArrayBuffer,
|
|
1860
|
-
byteOffset: i32 = 0,
|
|
1861
|
-
len: i32 = -1
|
|
1862
|
-
): TArray {
|
|
1863
|
-
let byteLength: i32;
|
|
1864
|
-
let bufferByteLength = buffer.byteLength;
|
|
1865
|
-
const mask: u32 = sizeof<T>() - 1;
|
|
1866
|
-
if (i32(<u32>byteOffset > <u32>bufferByteLength) | (byteOffset & mask)) {
|
|
1867
|
-
throw new RangeError(E_INDEXOUTOFRANGE);
|
|
1868
|
-
}
|
|
1869
|
-
if (len < 0) {
|
|
1870
|
-
if (len == -1) {
|
|
1871
|
-
if (bufferByteLength & mask) {
|
|
1872
|
-
throw new RangeError(E_INVALIDLENGTH);
|
|
1873
|
-
}
|
|
1874
|
-
byteLength = bufferByteLength - byteOffset;
|
|
1875
|
-
} else {
|
|
1876
|
-
throw new RangeError(E_INVALIDLENGTH);
|
|
1877
|
-
}
|
|
1878
|
-
} else {
|
|
1879
|
-
byteLength = len << alignof<T>();
|
|
1880
|
-
if (byteOffset + byteLength > bufferByteLength) {
|
|
1881
|
-
throw new RangeError(E_INVALIDLENGTH);
|
|
1882
|
-
}
|
|
1883
|
-
}
|
|
1884
|
-
let out = changetype<TArray>(__new(offsetof<TArray>(), idof<TArray>()));
|
|
1885
|
-
store<usize>(changetype<usize>(out), changetype<usize>(buffer), offsetof<TArray>("buffer"));
|
|
1886
|
-
if (ASC_RUNTIME != Runtime.Memory) {
|
|
1887
|
-
__link(changetype<usize>(out), changetype<usize>(buffer), false);
|
|
1888
|
-
}
|
|
1889
|
-
store<u32>(changetype<usize>(out), byteLength, offsetof<TArray>("byteLength"));
|
|
1890
|
-
store<usize>(changetype<usize>(out), changetype<usize>(buffer) + <usize>byteOffset, offsetof<TArray>("dataStart"));
|
|
1891
|
-
return out;
|
|
1892
|
-
}
|
|
1893
|
-
|
|
1894
|
-
// @ts-ignore: decorator
|
|
1895
|
-
@inline
|
|
1896
|
-
function SET<
|
|
1897
|
-
TArray extends ArrayLike<number>,
|
|
1898
|
-
UArray extends ArrayLike<number>
|
|
1899
|
-
>(
|
|
1900
|
-
target: TArray,
|
|
1901
|
-
source: UArray,
|
|
1902
|
-
offset: i32 = 0
|
|
1903
|
-
): void {
|
|
1904
|
-
// need to assert at compile time that U is not a reference or a function
|
|
1905
|
-
if (isReference<valueof<UArray>>()) {
|
|
1906
|
-
ERROR(E_NOTIMPLEMENTED);
|
|
1907
|
-
}
|
|
1908
|
-
let sourceLen = source.length;
|
|
1909
|
-
if (offset < 0 || sourceLen + offset > target.length) {
|
|
1910
|
-
// offset is out of bounds
|
|
1911
|
-
throw new RangeError(E_INDEXOUTOFRANGE);
|
|
1912
|
-
}
|
|
1913
|
-
// @ts-ignore: dataStart
|
|
1914
|
-
let targetStart = target.dataStart + (<usize>offset << (alignof<valueof<TArray>>()));
|
|
1915
|
-
// @ts-ignore: dataStart
|
|
1916
|
-
let sourceStart = source.dataStart;
|
|
1917
|
-
// if the types align and match, use memory.copy() instead of manual loop
|
|
1918
|
-
if (
|
|
1919
|
-
isInteger<valueof<TArray>>() == isInteger<valueof<UArray>>() &&
|
|
1920
|
-
alignof<valueof<TArray>>() == alignof<valueof<UArray>>() &&
|
|
1921
|
-
!(isSigned<valueof<UArray>>() && target instanceof Uint8ClampedArray)
|
|
1922
|
-
) {
|
|
1923
|
-
memory.copy(targetStart, sourceStart, <usize>sourceLen << (alignof<valueof<UArray>>()));
|
|
1924
|
-
} else {
|
|
1925
|
-
for (let i = 0; i < sourceLen; i++) {
|
|
1926
|
-
let ptr = targetStart + (<usize>i << (alignof<valueof<TArray>>()));
|
|
1927
|
-
let value = load<valueof<UArray>>(sourceStart + (<usize>i << (alignof<valueof<UArray>>())));
|
|
1928
|
-
// if TArray is Uint8ClampedArray, then values must be clamped
|
|
1929
|
-
if (target instanceof Uint8ClampedArray) {
|
|
1930
|
-
if (isFloat<valueof<UArray>>()) {
|
|
1931
|
-
store<valueof<TArray>>(ptr,
|
|
1932
|
-
isFinite<valueof<UArray>>(value)
|
|
1933
|
-
? <valueof<TArray>>max<valueof<UArray>>(0, min<valueof<UArray>>(255, value))
|
|
1934
|
-
: 0
|
|
1935
|
-
);
|
|
1936
|
-
} else {
|
|
1937
|
-
if (!isSigned<valueof<UArray>>()) {
|
|
1938
|
-
store<valueof<TArray>>(ptr, min<valueof<UArray>>(255, value));
|
|
1939
|
-
} else if (sizeof<valueof<TArray>>() <= 4) {
|
|
1940
|
-
store<valueof<TArray>>(ptr, ~(<i32>value >> 31) & (((255 - <i32>value) >> 31) | value));
|
|
1941
|
-
} else {
|
|
1942
|
-
store<valueof<TArray>>(ptr, ~(<i64>value >> 63) & (((255 - <i64>value) >> 63) | value));
|
|
1943
|
-
}
|
|
1944
|
-
}
|
|
1945
|
-
} else {
|
|
1946
|
-
if (isFloat<valueof<UArray>>() && !isFloat<valueof<TArray>>()) {
|
|
1947
|
-
store<valueof<TArray>>(ptr, isFinite<valueof<UArray>>(value) ? <valueof<TArray>>value : 0);
|
|
1948
|
-
} else {
|
|
1949
|
-
store<valueof<TArray>>(ptr, <valueof<TArray>>value);
|
|
1950
|
-
}
|
|
1951
|
-
}
|
|
1952
|
-
}
|
|
1953
|
-
}
|
|
1954
|
-
}
|
|
1
|
+
import { COMPARATOR, SORT } from "./util/sort";
|
|
2
|
+
import { E_INDEXOUTOFRANGE, E_INVALIDLENGTH, E_NOTIMPLEMENTED } from "./util/error";
|
|
3
|
+
import { joinIntegerArray, joinFloatArray } from "./util/string";
|
|
4
|
+
import { Runtime } from "shared/runtime";
|
|
5
|
+
import { REVERSE, FILL } from "./util/bytes";
|
|
6
|
+
import { idof } from "./builtins";
|
|
7
|
+
import { ArrayBufferView } from "./arraybuffer";
|
|
8
|
+
|
|
9
|
+
export class Int8Array extends ArrayBufferView {
|
|
10
|
+
[key: number]: i8;
|
|
11
|
+
|
|
12
|
+
// @ts-ignore: decorator
|
|
13
|
+
@lazy
|
|
14
|
+
static readonly BYTES_PER_ELEMENT: i32 = sizeof<i8>();
|
|
15
|
+
|
|
16
|
+
constructor(length: i32) {
|
|
17
|
+
super(length, alignof<i8>());
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
get length(): i32 {
|
|
21
|
+
return this.byteLength;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@operator("[]")
|
|
25
|
+
private __get(index: i32): i8 {
|
|
26
|
+
if (<u32>index >= <u32>this.byteLength) throw new RangeError(E_INDEXOUTOFRANGE);
|
|
27
|
+
return load<i8>(this.dataStart + <usize>index);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@unsafe @operator("{}")
|
|
31
|
+
private __uget(index: i32): i8 {
|
|
32
|
+
return load<i8>(this.dataStart + <usize>index);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@operator("[]=")
|
|
36
|
+
private __set(index: i32, value: native<i8>): void {
|
|
37
|
+
if (<u32>index >= <u32>this.byteLength) throw new RangeError(E_INDEXOUTOFRANGE);
|
|
38
|
+
store<i8>(this.dataStart + <usize>index, value);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@unsafe @operator("{}=")
|
|
42
|
+
private __uset(index: i32, value: native<i8>): void {
|
|
43
|
+
store<i8>(this.dataStart + <usize>index, value);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
at(index: i32): i8 {
|
|
47
|
+
let len = this.byteLength;
|
|
48
|
+
index += select(0, len, index >= 0);
|
|
49
|
+
if (<u32>index >= <u32>len) throw new RangeError(E_INDEXOUTOFRANGE);
|
|
50
|
+
return load<i8>(this.dataStart + <usize>index);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
includes(searchElement: i8, fromIndex: i32 = 0): bool {
|
|
54
|
+
return INCLUDES<Int8Array, i8>(this, searchElement, fromIndex);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
indexOf(searchElement: i8, fromIndex: i32 = 0): i32 {
|
|
58
|
+
return INDEX_OF<Int8Array, i8>(this, searchElement, fromIndex);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
lastIndexOf(searchElement: i8, fromIndex: i32 = this.length): i32 {
|
|
62
|
+
return LAST_INDEX_OF<Int8Array, i8>(this, searchElement, fromIndex);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
fill(value: i32, start: i32 = 0, end: i32 = i32.MAX_VALUE): Int8Array {
|
|
66
|
+
FILL<u8>(this.dataStart, this.length, u8(value), start, end);
|
|
67
|
+
return this;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
sort(comparator: (a: i8, b: i8) => i32 = COMPARATOR<i8>()): Int8Array {
|
|
71
|
+
SORT<i8>(this.dataStart, this.length, comparator);
|
|
72
|
+
return this;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
slice(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Int8Array {
|
|
76
|
+
return SLICE<Int8Array, i8>(this, begin, end);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
subarray(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Int8Array {
|
|
80
|
+
return SUBARRAY<Int8Array, i8>(this, begin, end);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
copyWithin(target: i32, start: i32, end: i32 = i32.MAX_VALUE): Int8Array {
|
|
84
|
+
return COPY_WITHIN<Int8Array, i8>(this, target, start, end);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
reduce<T extends number>(
|
|
88
|
+
fn: (accumulator: T, value: i8, index: i32, array: Int8Array) => T,
|
|
89
|
+
initialValue: T,
|
|
90
|
+
): T {
|
|
91
|
+
return REDUCE<Int8Array, i8, T>(this, fn, initialValue);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
reduceRight<T extends number>(
|
|
95
|
+
fn: (accumulator: T, value: i8, index: i32, array: Int8Array) => T,
|
|
96
|
+
initialValue: T,
|
|
97
|
+
): T {
|
|
98
|
+
return REDUCE_RIGHT<Int8Array, i8, T>(this, fn, initialValue);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
map(fn: (value: i8, index: i32, self: Int8Array) => i8): Int8Array {
|
|
102
|
+
return MAP<Int8Array, i8>(this, fn);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
filter(fn: (value: i8, index: i32, self: Int8Array) => bool): Int8Array {
|
|
106
|
+
return FILTER<Int8Array, i8>(this, fn);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
findIndex(fn: (value: i8, index: i32, self: Int8Array) => bool): i32 {
|
|
110
|
+
return FIND_INDEX<Int8Array, i8>(this, fn);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
findLastIndex(fn: (value: i8, index: i32, self: Int8Array) => bool): i32 {
|
|
114
|
+
return FIND_LAST_INDEX<Int8Array, i8>(this, fn);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
some(fn: (value: i8, index: i32, self: Int8Array) => bool): bool {
|
|
118
|
+
return SOME<Int8Array, i8>(this, fn);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
every(fn: (value: i8, index: i32, self: Int8Array) => bool): bool {
|
|
122
|
+
return EVERY<Int8Array, i8>(this, fn);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
forEach(fn: (value: i8, index: i32, self: Int8Array) => void): void {
|
|
126
|
+
FOREACH<Int8Array, i8>(this, fn);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
reverse(): Int8Array {
|
|
130
|
+
REVERSE<u8>(this.dataStart, this.length);
|
|
131
|
+
return this;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
join(separator: string = ","): string {
|
|
135
|
+
return joinIntegerArray<i8>(this.dataStart, this.length, separator);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
toString(): string {
|
|
139
|
+
return this.join();
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
set<U extends ArrayLike<number>>(source: U, offset: i32 = 0): void {
|
|
143
|
+
SET(this, source, offset);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
static wrap(buffer: ArrayBuffer, byteOffset: i32 = 0, length: i32 = -1): Int8Array {
|
|
147
|
+
return WRAP<Int8Array, i8>(buffer, byteOffset, length);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export class Uint8Array extends ArrayBufferView {
|
|
152
|
+
[key: number]: u8;
|
|
153
|
+
|
|
154
|
+
// @ts-ignore: decorator
|
|
155
|
+
@lazy
|
|
156
|
+
static readonly BYTES_PER_ELEMENT: i32 = sizeof<u8>();
|
|
157
|
+
|
|
158
|
+
constructor(length: i32) {
|
|
159
|
+
super(length, alignof<u8>());
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
get length(): i32 {
|
|
163
|
+
return this.byteLength;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
@operator("[]")
|
|
167
|
+
private __get(index: i32): u8 {
|
|
168
|
+
if (<u32>index >= <u32>this.byteLength) throw new RangeError(E_INDEXOUTOFRANGE);
|
|
169
|
+
return load<u8>(this.dataStart + <usize>index);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
@unsafe @operator("{}")
|
|
173
|
+
private __uget(index: i32): u8 {
|
|
174
|
+
return load<u8>(this.dataStart + <usize>index);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
@operator("[]=")
|
|
178
|
+
private __set(index: i32, value: native<u8>): void {
|
|
179
|
+
if (<u32>index >= <u32>this.byteLength) throw new RangeError(E_INDEXOUTOFRANGE);
|
|
180
|
+
store<u8>(this.dataStart + <usize>index, value);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
@unsafe @operator("{}=")
|
|
184
|
+
private __uset(index: i32, value: native<u8>): void {
|
|
185
|
+
store<u8>(this.dataStart + <usize>index, value);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
at(index: i32): u8 {
|
|
189
|
+
let len = this.byteLength;
|
|
190
|
+
index += select(0, len, index >= 0);
|
|
191
|
+
if (<u32>index >= <u32>len) throw new RangeError(E_INDEXOUTOFRANGE);
|
|
192
|
+
return load<u8>(this.dataStart + <usize>index);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
includes(searchElement: u8, fromIndex: i32 = 0): bool {
|
|
196
|
+
return INCLUDES<Uint8Array, u8>(this, searchElement, fromIndex);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
indexOf(searchElement: u8, fromIndex: i32 = 0): i32 {
|
|
200
|
+
return INDEX_OF<Uint8Array, u8>(this, searchElement, fromIndex);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
lastIndexOf(searchElement: u8, fromIndex: i32 = this.length): i32 {
|
|
204
|
+
return LAST_INDEX_OF<Uint8Array, u8>(this, searchElement, fromIndex);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
fill(value: u32, start: i32 = 0, end: i32 = i32.MAX_VALUE): Uint8Array {
|
|
208
|
+
FILL<u8>(this.dataStart, this.length, u8(value), start, end);
|
|
209
|
+
return this;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
sort(comparator: (a: u8, b: u8) => i32 = COMPARATOR<u8>()): Uint8Array {
|
|
213
|
+
SORT<u8>(this.dataStart, this.length, comparator);
|
|
214
|
+
return this;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
slice(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Uint8Array {
|
|
218
|
+
return SLICE<Uint8Array, u8>(this, begin, end);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
subarray(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Uint8Array {
|
|
222
|
+
return SUBARRAY<Uint8Array, u8>(this, begin, end);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
copyWithin(target: i32, start: i32, end: i32 = i32.MAX_VALUE): Uint8Array {
|
|
226
|
+
return COPY_WITHIN<Uint8Array, u8>(this, target, start, end);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
reduce<T extends number>(
|
|
230
|
+
fn: (accumulator: T, value: u8, index: i32, array: Uint8Array) => T,
|
|
231
|
+
initialValue: T,
|
|
232
|
+
): T {
|
|
233
|
+
return REDUCE<Uint8Array, u8, T>(this, fn, initialValue);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
reduceRight<T extends number>(
|
|
237
|
+
fn: (accumulator: T, value: u8, index: i32, array: Uint8Array) => T,
|
|
238
|
+
initialValue: T,
|
|
239
|
+
): T {
|
|
240
|
+
return REDUCE_RIGHT<Uint8Array, u8, T>(this, fn, initialValue);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
map(fn: (value: u8, index: i32, self: Uint8Array) => u8): Uint8Array {
|
|
244
|
+
return MAP<Uint8Array, u8>(this, fn);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
filter(fn: (value: u8, index: i32, self: Uint8Array) => bool): Uint8Array {
|
|
248
|
+
return FILTER<Uint8Array, u8>(this, fn);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
findIndex(fn: (value: u8, index: i32, self: Uint8Array) => bool): i32 {
|
|
252
|
+
return FIND_INDEX<Uint8Array, u8>(this, fn);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
findLastIndex(fn: (value: u8, index: i32, self: Uint8Array) => bool): i32 {
|
|
256
|
+
return FIND_LAST_INDEX<Uint8Array, u8>(this, fn);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
some(fn: (value: u8, index: i32, self: Uint8Array) => bool): bool {
|
|
260
|
+
return SOME<Uint8Array, u8>(this, fn);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
every(fn: (value: u8, index: i32, self: Uint8Array) => bool): bool {
|
|
264
|
+
return EVERY<Uint8Array, u8>(this, fn);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
forEach(fn: (value: u8, index: i32, self: Uint8Array) => void): void {
|
|
268
|
+
FOREACH<Uint8Array, u8>(this, fn);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
reverse(): Uint8Array {
|
|
272
|
+
REVERSE<u8>(this.dataStart, this.length);
|
|
273
|
+
return this;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
join(separator: string = ","): string {
|
|
277
|
+
return joinIntegerArray<u8>(this.dataStart, this.length, separator);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
set<U extends ArrayLike<number>>(source: U, offset: i32 = 0): void {
|
|
281
|
+
SET(this, source, offset);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
toString(): string {
|
|
285
|
+
return this.join();
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
static wrap(buffer: ArrayBuffer, byteOffset: i32 = 0, length: i32 = -1): Uint8Array {
|
|
289
|
+
return WRAP<Uint8Array, u8>(buffer, byteOffset, length);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
export class Uint8ClampedArray extends ArrayBufferView {
|
|
294
|
+
[key: number]: u8;
|
|
295
|
+
|
|
296
|
+
// @ts-ignore: decorator
|
|
297
|
+
@lazy
|
|
298
|
+
static readonly BYTES_PER_ELEMENT: i32 = sizeof<u8>();
|
|
299
|
+
|
|
300
|
+
constructor(length: i32) {
|
|
301
|
+
super(length, alignof<u8>());
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
get length(): i32 {
|
|
305
|
+
return this.byteLength;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
@operator("[]")
|
|
309
|
+
private __get(index: i32): u8 {
|
|
310
|
+
if (<u32>index >= <u32>this.byteLength) throw new RangeError(E_INDEXOUTOFRANGE);
|
|
311
|
+
return load<u8>(this.dataStart + <usize>index);
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
@unsafe @operator("{}")
|
|
315
|
+
private __uget(index: i32): u8 {
|
|
316
|
+
return load<u8>(this.dataStart + <usize>index);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
@operator("[]=")
|
|
320
|
+
private __set(index: i32, value: native<u8>): void {
|
|
321
|
+
if (<u32>index >= <u32>this.byteLength) throw new RangeError(E_INDEXOUTOFRANGE);
|
|
322
|
+
store<u8>(this.dataStart + <usize>index, ~(<i32>value >> 31) & (((255 - value) >> 31) | value));
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
@unsafe @operator("{}=")
|
|
326
|
+
private __uset(index: i32, value: native<u8>): void {
|
|
327
|
+
store<u8>(this.dataStart + <usize>index, ~(<i32>value >> 31) & (((255 - value) >> 31) | value));
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
at(index: i32): u8 {
|
|
331
|
+
let len = this.byteLength;
|
|
332
|
+
index += select(0, len, index >= 0);
|
|
333
|
+
if (<u32>index >= <u32>len) throw new RangeError(E_INDEXOUTOFRANGE);
|
|
334
|
+
return load<u8>(this.dataStart + <usize>index);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
includes(searchElement: u8, fromIndex: i32 = 0): bool {
|
|
338
|
+
return INCLUDES<Uint8ClampedArray, u8>(this, searchElement, fromIndex);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
indexOf(searchElement: u8, fromIndex: i32 = 0): i32 {
|
|
342
|
+
return INDEX_OF<Uint8ClampedArray, u8>(this, searchElement, fromIndex);
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
lastIndexOf(searchElement: u8, fromIndex: i32 = this.length): i32 {
|
|
346
|
+
return LAST_INDEX_OF<Uint8ClampedArray, u8>(this, searchElement, fromIndex);
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
fill(value: i32, start: i32 = 0, end: i32 = i32.MAX_VALUE): Uint8ClampedArray {
|
|
350
|
+
value = ~(value >> 31) & (((255 - value) >> 31) | value);
|
|
351
|
+
FILL<u8>(this.dataStart, this.length, u8(value), start, end);
|
|
352
|
+
return this;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
sort(comparator: (a: u8, b: u8) => i32 = COMPARATOR<u8>()): Uint8ClampedArray {
|
|
356
|
+
SORT<u8>(this.dataStart, this.length, comparator);
|
|
357
|
+
return this;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
slice(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Uint8ClampedArray {
|
|
361
|
+
return SLICE<Uint8ClampedArray, u8>(this, begin, end);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
subarray(start: i32 = 0, end: i32 = i32.MAX_VALUE): Uint8ClampedArray {
|
|
365
|
+
return SUBARRAY<Uint8ClampedArray, u8>(this, start, end);
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
copyWithin(target: i32, start: i32, end: i32 = i32.MAX_VALUE): Uint8ClampedArray {
|
|
369
|
+
return COPY_WITHIN<Uint8ClampedArray, u8>(this, target, start, end);
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
reduce<T extends number>(
|
|
373
|
+
fn: (accumulator: T, value: u8, index: i32, array: Uint8ClampedArray) => T,
|
|
374
|
+
initialValue: T,
|
|
375
|
+
): T {
|
|
376
|
+
return REDUCE<Uint8ClampedArray, u8, T>(this, fn, initialValue);
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
reduceRight<T extends number>(
|
|
380
|
+
fn: (accumulator: T, value: u8, index: i32, array: Uint8ClampedArray) => T,
|
|
381
|
+
initialValue: T,
|
|
382
|
+
): T {
|
|
383
|
+
return REDUCE_RIGHT<Uint8ClampedArray, u8, T>(this, fn, initialValue);
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
map(fn: (value: u8, index: i32, self: Uint8ClampedArray) => u8): Uint8ClampedArray {
|
|
387
|
+
return MAP<Uint8ClampedArray, u8>(this, fn);
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
filter(fn: (value: u8, index: i32, self: Uint8ClampedArray) => bool): Uint8ClampedArray {
|
|
391
|
+
return FILTER<Uint8ClampedArray, u8>(this, fn);
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
findIndex(fn: (value: u8, index: i32, self: Uint8ClampedArray) => bool): i32 {
|
|
395
|
+
return FIND_INDEX<Uint8ClampedArray, u8>(this, fn);
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
findLastIndex(fn: (value: u8, index: i32, self: Uint8ClampedArray) => bool): i32 {
|
|
399
|
+
return FIND_LAST_INDEX<Uint8ClampedArray, u8>(this, fn);
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
some(fn: (value: u8, index: i32, self: Uint8ClampedArray) => bool): bool {
|
|
403
|
+
return SOME<Uint8ClampedArray, u8>(this, fn);
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
every(fn: (value: u8, index: i32, self: Uint8ClampedArray) => bool): bool {
|
|
407
|
+
return EVERY<Uint8ClampedArray, u8>(this, fn);
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
forEach(fn: (value: u8, index: i32, self: Uint8ClampedArray) => void): void {
|
|
411
|
+
FOREACH<Uint8ClampedArray, u8>(this, fn);
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
reverse(): Uint8ClampedArray {
|
|
415
|
+
REVERSE<u8>(this.dataStart, this.length);
|
|
416
|
+
return this;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
join(separator: string = ","): string {
|
|
420
|
+
return joinIntegerArray<u8>(this.dataStart, this.length, separator);
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
set<U extends ArrayLike<number>>(source: U, offset: i32 = 0): void {
|
|
424
|
+
SET(this, source, offset);
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
toString(): string {
|
|
428
|
+
return this.join();
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
static wrap(buffer: ArrayBuffer, byteOffset: i32 = 0, length: i32 = -1): Uint8ClampedArray {
|
|
432
|
+
return WRAP<Uint8ClampedArray, u8>(buffer, byteOffset, length);
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
export class Int16Array extends ArrayBufferView {
|
|
437
|
+
[key: number]: i16;
|
|
438
|
+
|
|
439
|
+
// @ts-ignore: decorator
|
|
440
|
+
@lazy
|
|
441
|
+
static readonly BYTES_PER_ELEMENT: i32 = sizeof<i16>();
|
|
442
|
+
|
|
443
|
+
constructor(length: i32) {
|
|
444
|
+
super(length, alignof<i16>());
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
get length(): i32 {
|
|
448
|
+
return this.byteLength >>> alignof<i16>();
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
@operator("[]")
|
|
452
|
+
private __get(index: i32): i16 {
|
|
453
|
+
if (<u32>index >= <u32>this.byteLength >>> alignof<i16>()) throw new RangeError(E_INDEXOUTOFRANGE);
|
|
454
|
+
return load<i16>(this.dataStart + (<usize>index << alignof<i16>()));
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
@unsafe @operator("{}")
|
|
458
|
+
private __uget(index: i32): i16 {
|
|
459
|
+
return load<i16>(this.dataStart + (<usize>index << alignof<i16>()));
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
@operator("[]=")
|
|
463
|
+
private __set(index: i32, value: native<i16>): void {
|
|
464
|
+
if (<u32>index >= <u32>this.byteLength >>> alignof<i16>()) throw new RangeError(E_INDEXOUTOFRANGE);
|
|
465
|
+
store<i16>(this.dataStart + (<usize>index << alignof<i16>()), value);
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
@unsafe @operator("{}=")
|
|
469
|
+
private __uset(index: i32, value: native<i16>): void {
|
|
470
|
+
store<i16>(this.dataStart + (<usize>index << alignof<i16>()), value);
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
at(index: i32): i16 {
|
|
474
|
+
let len = this.byteLength >>> alignof<i16>();
|
|
475
|
+
index += select(0, len, index >= 0);
|
|
476
|
+
if (<u32>index >= <u32>len) throw new RangeError(E_INDEXOUTOFRANGE);
|
|
477
|
+
return load<i16>(this.dataStart + (<usize>index << alignof<i16>()));
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
includes(searchElement: i16, fromIndex: i32 = 0): bool {
|
|
481
|
+
return INCLUDES<Int16Array, i16>(this, searchElement, fromIndex);
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
indexOf(searchElement: i16, fromIndex: i32 = 0): i32 {
|
|
485
|
+
return INDEX_OF<Int16Array, i16>(this, searchElement, fromIndex);
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
lastIndexOf(searchElement: i16, fromIndex: i32 = this.length): i32 {
|
|
489
|
+
return LAST_INDEX_OF<Int16Array, i16>(this, searchElement, fromIndex);
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
fill(value: i32, start: i32 = 0, end: i32 = i32.MAX_VALUE): Int16Array {
|
|
493
|
+
FILL<u16>(this.dataStart, this.length, u16(value), start, end);
|
|
494
|
+
return this;
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
sort(comparator: (a: i16, b: i16) => i32 = COMPARATOR<i16>()): Int16Array {
|
|
498
|
+
SORT<i16>(this.dataStart, this.length, comparator);
|
|
499
|
+
return this;
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
slice(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Int16Array {
|
|
503
|
+
return SLICE<Int16Array, i16>(this, begin, end);
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
subarray(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Int16Array {
|
|
507
|
+
return SUBARRAY<Int16Array, i16>(this, begin, end);
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
copyWithin(target: i32, start: i32, end: i32 = i32.MAX_VALUE): Int16Array {
|
|
511
|
+
return COPY_WITHIN<Int16Array, i16>(this, target, start, end);
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
reduce<T extends number>(
|
|
515
|
+
fn: (accumulator: T, value: i16, index: i32, array: Int16Array) => T,
|
|
516
|
+
initialValue: T,
|
|
517
|
+
): T {
|
|
518
|
+
return REDUCE<Int16Array, i16, T>(this, fn, initialValue);
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
reduceRight<T extends number>(
|
|
522
|
+
fn: (accumulator: T, value: i16, index: i32, array: Int16Array) => T,
|
|
523
|
+
initialValue: T,
|
|
524
|
+
): T {
|
|
525
|
+
return REDUCE_RIGHT<Int16Array, i16, T>(this, fn, initialValue);
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
map(fn: (value: i16, index: i32, self: Int16Array) => i16): Int16Array {
|
|
529
|
+
return MAP<Int16Array, i16>(this, fn);
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
filter(fn: (value: i16, index: i32, self: Int16Array) => bool): Int16Array {
|
|
533
|
+
return FILTER<Int16Array, i16>(this, fn);
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
findIndex(fn: (value: i16, index: i32, self: Int16Array) => bool): i32 {
|
|
537
|
+
return FIND_INDEX<Int16Array, i16>(this, fn);
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
findLastIndex(fn: (value: i16, index: i32, self: Int16Array) => bool): i32 {
|
|
541
|
+
return FIND_LAST_INDEX<Int16Array, i16>(this, fn);
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
some(fn: (value: i16, index: i32, self: Int16Array) => bool): bool {
|
|
545
|
+
return SOME<Int16Array, i16>(this, fn);
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
every(fn: (value: i16, index: i32, self: Int16Array) => bool): bool {
|
|
549
|
+
return EVERY<Int16Array, i16>(this, fn);
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
forEach(fn: (value: i16, index: i32, self: Int16Array) => void): void {
|
|
553
|
+
FOREACH<Int16Array, i16>(this, fn);
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
reverse(): Int16Array {
|
|
557
|
+
REVERSE<u16>(this.dataStart, this.length);
|
|
558
|
+
return this;
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
join(separator: string = ","): string {
|
|
562
|
+
return joinIntegerArray<i16>(this.dataStart, this.length, separator);
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
set<U extends ArrayLike<number>>(source: U, offset: i32 = 0): void {
|
|
566
|
+
SET(this, source, offset);
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
toString(): string {
|
|
570
|
+
return this.join();
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
static wrap(buffer: ArrayBuffer, byteOffset: i32 = 0, length: i32 = -1): Int16Array {
|
|
574
|
+
return WRAP<Int16Array, i16>(buffer, byteOffset, length);
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
export class Uint16Array extends ArrayBufferView {
|
|
579
|
+
[key: number]: u16;
|
|
580
|
+
|
|
581
|
+
// @ts-ignore: decorator
|
|
582
|
+
@lazy
|
|
583
|
+
static readonly BYTES_PER_ELEMENT: i32 = sizeof<u16>();
|
|
584
|
+
|
|
585
|
+
constructor(length: i32) {
|
|
586
|
+
super(length, alignof<u16>());
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
get length(): i32 {
|
|
590
|
+
return this.byteLength >>> alignof<u16>();
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
@operator("[]")
|
|
594
|
+
private __get(index: i32): u16 {
|
|
595
|
+
if (<u32>index >= <u32>this.byteLength >>> alignof<u16>()) throw new RangeError(E_INDEXOUTOFRANGE);
|
|
596
|
+
return load<u16>(this.dataStart + (<usize>index << alignof<u16>()));
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
@unsafe @operator("{}")
|
|
600
|
+
private __uget(index: i32): u16 {
|
|
601
|
+
return load<u16>(this.dataStart + (<usize>index << alignof<u16>()));
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
@operator("[]=")
|
|
605
|
+
private __set(index: i32, value: native<u16>): void {
|
|
606
|
+
if (<u32>index >= <u32>this.byteLength >>> alignof<u16>()) throw new RangeError(E_INDEXOUTOFRANGE);
|
|
607
|
+
store<u16>(this.dataStart + (<usize>index << alignof<u16>()), value);
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
@unsafe @operator("{}=")
|
|
611
|
+
private __uset(index: i32, value: native<u16>): void {
|
|
612
|
+
store<u16>(this.dataStart + (<usize>index << alignof<u16>()), value);
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
at(index: i32): u16 {
|
|
616
|
+
let len = this.byteLength >>> alignof<u16>();
|
|
617
|
+
index += select(0, len, index >= 0);
|
|
618
|
+
if (<u32>index >= <u32>len) throw new RangeError(E_INDEXOUTOFRANGE);
|
|
619
|
+
return load<u16>(this.dataStart + (<usize>index << alignof<u16>()));
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
includes(searchElement: u16, fromIndex: i32 = 0): bool {
|
|
623
|
+
return INCLUDES<Uint16Array, u16>(this, searchElement, fromIndex);
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
indexOf(searchElement: u16, fromIndex: i32 = 0): i32 {
|
|
627
|
+
return INDEX_OF<Uint16Array, u16>(this, searchElement, fromIndex);
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
lastIndexOf(searchElement: u16, fromIndex: i32 = this.length): i32 {
|
|
631
|
+
return LAST_INDEX_OF<Uint16Array, u16>(this, searchElement, fromIndex);
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
fill(value: u32, start: i32 = 0, end: i32 = i32.MAX_VALUE): Uint16Array {
|
|
635
|
+
FILL<u16>(this.dataStart, this.length, u16(value), start, end);
|
|
636
|
+
return this;
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
sort(comparator: (a: u16, b: u16) => i32 = COMPARATOR<u16>()): Uint16Array {
|
|
640
|
+
SORT<u16>(this.dataStart, this.length, comparator);
|
|
641
|
+
return this;
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
slice(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Uint16Array {
|
|
645
|
+
return SLICE<Uint16Array, u16>(this, begin, end);
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
subarray(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Uint16Array {
|
|
649
|
+
return SUBARRAY<Uint16Array, u16>(this, begin, end);
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
copyWithin(target: i32, start: i32, end: i32 = i32.MAX_VALUE): Uint16Array {
|
|
653
|
+
return COPY_WITHIN<Uint16Array, u16>(this, target, start, end);
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
reduce<T extends number>(
|
|
657
|
+
fn: (accumulator: T, value: u16, index: i32, array: Uint16Array) => T,
|
|
658
|
+
initialValue: T,
|
|
659
|
+
): T {
|
|
660
|
+
return REDUCE<Uint16Array, u16, T>(this, fn, initialValue);
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
reduceRight<T extends number>(
|
|
664
|
+
fn: (accumulator: T, value: u16, index: i32, array: Uint16Array) => T,
|
|
665
|
+
initialValue: T,
|
|
666
|
+
): T {
|
|
667
|
+
return REDUCE_RIGHT<Uint16Array, u16, T>(this, fn, initialValue);
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
map(fn: (value: u16, index: i32, self: Uint16Array) => u16): Uint16Array {
|
|
671
|
+
return MAP<Uint16Array, u16>(this, fn);
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
filter(fn: (value: u16, index: i32, self: Uint16Array) => bool): Uint16Array {
|
|
675
|
+
return FILTER<Uint16Array, u16>(this, fn);
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
findIndex(fn: (value: u16, index: i32, self: Uint16Array) => bool): i32 {
|
|
679
|
+
return FIND_INDEX<Uint16Array, u16>(this, fn);
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
findLastIndex(fn: (value: u16, index: i32, self: Uint16Array) => bool): i32 {
|
|
683
|
+
return FIND_LAST_INDEX<Uint16Array, u16>(this, fn);
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
some(fn: (value: u16, index: i32, self: Uint16Array) => bool): bool {
|
|
687
|
+
return SOME<Uint16Array, u16>(this, fn);
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
every(fn: (value: u16, index: i32, self: Uint16Array) => bool): bool {
|
|
691
|
+
return EVERY<Uint16Array, u16>(this, fn);
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
forEach(fn: (value: u16, index: i32, self: Uint16Array) => void): void {
|
|
695
|
+
FOREACH<Uint16Array, u16>(this, fn);
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
reverse(): Uint16Array {
|
|
699
|
+
REVERSE<u16>(this.dataStart, this.length);
|
|
700
|
+
return this;
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
join(separator: string = ","): string {
|
|
704
|
+
return joinIntegerArray<u16>(this.dataStart, this.length, separator);
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
set<U extends ArrayLike<number>>(source: U, offset: i32 = 0): void {
|
|
708
|
+
SET(this, source, offset);
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
toString(): string {
|
|
712
|
+
return this.join();
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
static wrap(buffer: ArrayBuffer, byteOffset: i32 = 0, length: i32 = -1): Uint16Array {
|
|
716
|
+
return WRAP<Uint16Array, u16>(buffer, byteOffset, length);
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
export class Int32Array extends ArrayBufferView {
|
|
721
|
+
[key: number]: i32;
|
|
722
|
+
|
|
723
|
+
// @ts-ignore: decorator
|
|
724
|
+
@lazy
|
|
725
|
+
static readonly BYTES_PER_ELEMENT: i32 = sizeof<i32>();
|
|
726
|
+
|
|
727
|
+
constructor(length: i32) {
|
|
728
|
+
super(length, alignof<i32>());
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
get length(): i32 {
|
|
732
|
+
return this.byteLength >>> alignof<i32>();
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
@operator("[]")
|
|
736
|
+
private __get(index: i32): i32 {
|
|
737
|
+
if (<u32>index >= <u32>this.byteLength >>> alignof<i32>()) throw new RangeError(E_INDEXOUTOFRANGE);
|
|
738
|
+
return load<i32>(this.dataStart + (<usize>index << alignof<i32>()));
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
@unsafe @operator("{}")
|
|
742
|
+
private __uget(index: i32): i32 {
|
|
743
|
+
return load<i32>(this.dataStart + (<usize>index << alignof<i32>()));
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
@operator("[]=")
|
|
747
|
+
private __set(index: i32, value: i32): void {
|
|
748
|
+
if (<u32>index >= <u32>this.byteLength >>> alignof<i32>()) throw new RangeError(E_INDEXOUTOFRANGE);
|
|
749
|
+
store<i32>(this.dataStart + (<usize>index << alignof<i32>()), value);
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
@unsafe @operator("{}=")
|
|
753
|
+
private __uset(index: i32, value: i32): void {
|
|
754
|
+
store<i32>(this.dataStart + (<usize>index << alignof<i32>()), value);
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
at(index: i32): i32 {
|
|
758
|
+
let len = this.byteLength >>> alignof<i32>();
|
|
759
|
+
index += select(0, len, index >= 0);
|
|
760
|
+
if (<u32>index >= <u32>len) throw new RangeError(E_INDEXOUTOFRANGE);
|
|
761
|
+
return load<i32>(this.dataStart + (<usize>index << alignof<i32>()));
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
includes(searchElement: i32, fromIndex: i32 = 0): bool {
|
|
765
|
+
return INCLUDES<Int32Array, i32>(this, searchElement, fromIndex);
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
indexOf(searchElement: i32, fromIndex: i32 = 0): i32 {
|
|
769
|
+
return INDEX_OF<Int32Array, i32>(this, searchElement, fromIndex);
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
lastIndexOf(searchElement: i32, fromIndex: i32 = this.length): i32 {
|
|
773
|
+
return LAST_INDEX_OF<Int32Array, i32>(this, searchElement, fromIndex);
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
fill(value: i32, start: i32 = 0, end: i32 = i32.MAX_VALUE): Int32Array {
|
|
777
|
+
FILL<u32>(this.dataStart, this.length, u32(value), start, end);
|
|
778
|
+
return this;
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
sort(comparator: (a: i32, b: i32) => i32 = COMPARATOR<i32>()): Int32Array {
|
|
782
|
+
SORT<i32>(this.dataStart, this.length, comparator);
|
|
783
|
+
return this;
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
slice(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Int32Array {
|
|
787
|
+
return SLICE<Int32Array, i32>(this, begin, end);
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
subarray(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Int32Array {
|
|
791
|
+
return SUBARRAY<Int32Array, i32>(this, begin, end);
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
copyWithin(target: i32, start: i32, end: i32 = i32.MAX_VALUE): Int32Array {
|
|
795
|
+
return COPY_WITHIN<Int32Array, i32>(this, target, start, end);
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
reduce<T extends number>(
|
|
799
|
+
fn: (accumulator: T, value: i32, index: i32, array: Int32Array) => T,
|
|
800
|
+
initialValue: T,
|
|
801
|
+
): T {
|
|
802
|
+
return REDUCE<Int32Array, i32, T>(this, fn, initialValue);
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
reduceRight<T extends number>(
|
|
806
|
+
fn: (accumulator: T, value: i32, index: i32, array: Int32Array) => T,
|
|
807
|
+
initialValue: T,
|
|
808
|
+
): T {
|
|
809
|
+
return REDUCE_RIGHT<Int32Array, i32, T>(this, fn, initialValue);
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
map(fn: (value: i32, index: i32, self: Int32Array) => i32): Int32Array {
|
|
813
|
+
return MAP<Int32Array, i32>(this, fn);
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
filter(fn: (value: i32, index: i32, self: Int32Array) => bool): Int32Array {
|
|
817
|
+
return FILTER<Int32Array, i32>(this, fn);
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
findIndex(fn: (value: i32, index: i32, self: Int32Array) => bool): i32 {
|
|
821
|
+
return FIND_INDEX<Int32Array, i32>(this, fn);
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
findLastIndex(fn: (value: i32, index: i32, self: Int32Array) => bool): i32 {
|
|
825
|
+
return FIND_LAST_INDEX<Int32Array, i32>(this, fn);
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
some(fn: (value: i32, index: i32, self: Int32Array) => bool): bool {
|
|
829
|
+
return SOME<Int32Array, i32>(this, fn);
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
every(fn: (value: i32, index: i32, self: Int32Array) => bool): bool {
|
|
833
|
+
return EVERY<Int32Array, i32>(this, fn);
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
forEach(fn: (value: i32, index: i32, self: Int32Array) => void): void {
|
|
837
|
+
FOREACH<Int32Array, i32>(this, fn);
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
reverse(): Int32Array {
|
|
841
|
+
REVERSE<u32>(this.dataStart, this.length);
|
|
842
|
+
return this;
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
join(separator: string = ","): string {
|
|
846
|
+
return joinIntegerArray<i32>(this.dataStart, this.length, separator);
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
set<U extends ArrayLike<number>>(source: U, offset: i32 = 0): void {
|
|
850
|
+
SET(this, source, offset);
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
toString(): string {
|
|
854
|
+
return this.join();
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
static wrap(buffer: ArrayBuffer, byteOffset: i32 = 0, length: i32 = -1): Int32Array {
|
|
858
|
+
return WRAP<Int32Array, i32>(buffer, byteOffset, length);
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
export class Uint32Array extends ArrayBufferView {
|
|
863
|
+
[key: number]: u32;
|
|
864
|
+
|
|
865
|
+
// @ts-ignore: decorator
|
|
866
|
+
@lazy
|
|
867
|
+
static readonly BYTES_PER_ELEMENT: i32 = sizeof<u32>();
|
|
868
|
+
|
|
869
|
+
constructor(length: i32) {
|
|
870
|
+
super(length, alignof<u32>());
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
get length(): i32 {
|
|
874
|
+
return this.byteLength >>> alignof<u32>();
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
@operator("[]")
|
|
878
|
+
private __get(index: i32): u32 {
|
|
879
|
+
if (<u32>index >= <u32>this.byteLength >>> alignof<u32>()) throw new RangeError(E_INDEXOUTOFRANGE);
|
|
880
|
+
return load<u32>(this.dataStart + (<usize>index << alignof<u32>()));
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
@unsafe @operator("{}")
|
|
884
|
+
private __uget(index: i32): u32 {
|
|
885
|
+
return load<u32>(this.dataStart + (<usize>index << alignof<u32>()));
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
@operator("[]=")
|
|
889
|
+
private __set(index: i32, value: u32): void {
|
|
890
|
+
if (<u32>index >= <u32>this.byteLength >>> alignof<u32>()) throw new RangeError(E_INDEXOUTOFRANGE);
|
|
891
|
+
store<u32>(this.dataStart + (<usize>index << alignof<u32>()), value);
|
|
892
|
+
}
|
|
893
|
+
|
|
894
|
+
@unsafe @operator("{}=")
|
|
895
|
+
private __uset(index: i32, value: u32): void {
|
|
896
|
+
store<u32>(this.dataStart + (<usize>index << alignof<u32>()), value);
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
at(index: i32): u32 {
|
|
900
|
+
let len = this.byteLength >>> alignof<u32>();
|
|
901
|
+
index += select(0, len, index >= 0);
|
|
902
|
+
if (<u32>index >= <u32>len) throw new RangeError(E_INDEXOUTOFRANGE);
|
|
903
|
+
return load<u32>(this.dataStart + (<usize>index << alignof<u32>()));
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
includes(searchElement: u32, fromIndex: i32 = 0): bool {
|
|
907
|
+
return INCLUDES<Uint32Array, u32>(this, searchElement, fromIndex);
|
|
908
|
+
}
|
|
909
|
+
|
|
910
|
+
indexOf(searchElement: u32, fromIndex: i32 = 0): i32 {
|
|
911
|
+
return INDEX_OF<Uint32Array, u32>(this, searchElement, fromIndex);
|
|
912
|
+
}
|
|
913
|
+
|
|
914
|
+
lastIndexOf(searchElement: u32, fromIndex: i32 = this.length): i32 {
|
|
915
|
+
return LAST_INDEX_OF<Uint32Array, u32>(this, searchElement, fromIndex);
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
fill(value: u32, start: i32 = 0, end: i32 = i32.MAX_VALUE): Uint32Array {
|
|
919
|
+
FILL<u32>(this.dataStart, this.length, value, start, end);
|
|
920
|
+
return this;
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
sort(comparator: (a: u32, b: u32) => i32 = COMPARATOR<u32>()): Uint32Array {
|
|
924
|
+
SORT<u32>(this.dataStart, this.length, comparator);
|
|
925
|
+
return this;
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
slice(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Uint32Array {
|
|
929
|
+
return SLICE<Uint32Array, u32>(this, begin, end);
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
subarray(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Uint32Array {
|
|
933
|
+
return SUBARRAY<Uint32Array, u32>(this, begin, end);
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
copyWithin(target: i32, start: i32, end: i32 = i32.MAX_VALUE): Uint32Array {
|
|
937
|
+
return COPY_WITHIN<Uint32Array, u32>(this, target, start, end);
|
|
938
|
+
}
|
|
939
|
+
|
|
940
|
+
reduce<T extends number>(
|
|
941
|
+
fn: (accumulator: T, value: u32, index: i32, array: Uint32Array) => T,
|
|
942
|
+
initialValue: T,
|
|
943
|
+
): T {
|
|
944
|
+
return REDUCE<Uint32Array, u32, T>(this, fn, initialValue);
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
reduceRight<T extends number>(
|
|
948
|
+
fn: (accumulator: T, value: u32, index: i32, array: Uint32Array) => T,
|
|
949
|
+
initialValue: T,
|
|
950
|
+
): T {
|
|
951
|
+
return REDUCE_RIGHT<Uint32Array, u32, T>(this, fn, initialValue);
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
map(fn: (value: u32, index: i32, self: Uint32Array) => u32): Uint32Array {
|
|
955
|
+
return MAP<Uint32Array, u32>(this, fn);
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
filter(fn: (value: u32, index: i32, self: Uint32Array) => bool): Uint32Array {
|
|
959
|
+
return FILTER<Uint32Array, u32>(this, fn);
|
|
960
|
+
}
|
|
961
|
+
|
|
962
|
+
findIndex(fn: (value: u32, index: i32, self: Uint32Array) => bool): i32 {
|
|
963
|
+
return FIND_INDEX<Uint32Array, u32>(this, fn);
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
findLastIndex(fn: (value: u32, index: i32, self: Uint32Array) => bool): i32 {
|
|
967
|
+
return FIND_LAST_INDEX<Uint32Array, u32>(this, fn);
|
|
968
|
+
}
|
|
969
|
+
|
|
970
|
+
some(fn: (value: u32, index: i32, self: Uint32Array) => bool): bool {
|
|
971
|
+
return SOME<Uint32Array, u32>(this, fn);
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
every(fn: (value: u32, index: i32, self: Uint32Array) => bool): bool {
|
|
975
|
+
return EVERY<Uint32Array, u32>(this, fn);
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
forEach(fn: (value: u32, index: i32, self: Uint32Array) => void): void {
|
|
979
|
+
FOREACH<Uint32Array, u32>(this, fn);
|
|
980
|
+
}
|
|
981
|
+
|
|
982
|
+
reverse(): Uint32Array {
|
|
983
|
+
REVERSE<u32>(this.dataStart, this.length);
|
|
984
|
+
return this;
|
|
985
|
+
}
|
|
986
|
+
|
|
987
|
+
join(separator: string = ","): string {
|
|
988
|
+
return joinIntegerArray<u32>(this.dataStart, this.length, separator);
|
|
989
|
+
}
|
|
990
|
+
|
|
991
|
+
set<U extends ArrayLike<number>>(source: U, offset: i32 = 0): void {
|
|
992
|
+
SET(this, source, offset);
|
|
993
|
+
}
|
|
994
|
+
|
|
995
|
+
toString(): string {
|
|
996
|
+
return this.join();
|
|
997
|
+
}
|
|
998
|
+
|
|
999
|
+
static wrap(buffer: ArrayBuffer, byteOffset: i32 = 0, length: i32 = -1): Uint32Array {
|
|
1000
|
+
return WRAP<Uint32Array, u32>(buffer, byteOffset, length);
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
|
|
1004
|
+
export class Int64Array extends ArrayBufferView {
|
|
1005
|
+
[key: number]: i64;
|
|
1006
|
+
|
|
1007
|
+
// @ts-ignore: decorator
|
|
1008
|
+
@lazy
|
|
1009
|
+
static readonly BYTES_PER_ELEMENT: i32 = sizeof<i64>();
|
|
1010
|
+
|
|
1011
|
+
constructor(length: i32) {
|
|
1012
|
+
super(length, alignof<i64>());
|
|
1013
|
+
}
|
|
1014
|
+
|
|
1015
|
+
get length(): i32 {
|
|
1016
|
+
return this.byteLength >>> alignof<i64>();
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
@operator("[]")
|
|
1020
|
+
private __get(index: i32): i64 {
|
|
1021
|
+
if (<u32>index >= <u32>this.byteLength >>> alignof<i64>()) throw new RangeError(E_INDEXOUTOFRANGE);
|
|
1022
|
+
return load<i64>(this.dataStart + (<usize>index << alignof<i64>()));
|
|
1023
|
+
}
|
|
1024
|
+
|
|
1025
|
+
@unsafe @operator("{}")
|
|
1026
|
+
private __uget(index: i32): i64 {
|
|
1027
|
+
return load<i64>(this.dataStart + (<usize>index << alignof<i64>()));
|
|
1028
|
+
}
|
|
1029
|
+
|
|
1030
|
+
@operator("[]=")
|
|
1031
|
+
private __set(index: i32, value: i64): void {
|
|
1032
|
+
if (<u32>index >= <u32>this.byteLength >>> alignof<i64>()) throw new RangeError(E_INDEXOUTOFRANGE);
|
|
1033
|
+
store<i64>(this.dataStart + (<usize>index << alignof<i64>()), value);
|
|
1034
|
+
}
|
|
1035
|
+
|
|
1036
|
+
@unsafe @operator("{}=")
|
|
1037
|
+
private __uset(index: i32, value: i64): void {
|
|
1038
|
+
store<i64>(this.dataStart + (<usize>index << alignof<i64>()), value);
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1041
|
+
at(index: i32): i64 {
|
|
1042
|
+
let len = this.byteLength >>> alignof<i64>();
|
|
1043
|
+
index += select(0, len, index >= 0);
|
|
1044
|
+
if (<u32>index >= <u32>len) throw new RangeError(E_INDEXOUTOFRANGE);
|
|
1045
|
+
return load<i64>(this.dataStart + (<usize>index << alignof<i64>()));
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
includes(searchElement: i64, fromIndex: i32 = 0): bool {
|
|
1049
|
+
return INCLUDES<Int64Array, i64>(this, searchElement, fromIndex);
|
|
1050
|
+
}
|
|
1051
|
+
|
|
1052
|
+
indexOf(searchElement: i64, fromIndex: i32 = 0): i32 {
|
|
1053
|
+
return INDEX_OF<Int64Array, i64>(this, searchElement, fromIndex);
|
|
1054
|
+
}
|
|
1055
|
+
|
|
1056
|
+
lastIndexOf(searchElement: i64, fromIndex: i32 = this.length): i32 {
|
|
1057
|
+
return LAST_INDEX_OF<Int64Array, i64>(this, searchElement, fromIndex);
|
|
1058
|
+
}
|
|
1059
|
+
|
|
1060
|
+
fill(value: i64, start: i32 = 0, end: i32 = i32.MAX_VALUE): Int64Array {
|
|
1061
|
+
FILL<u64>(this.dataStart, this.length, u64(value), start, end);
|
|
1062
|
+
return this;
|
|
1063
|
+
}
|
|
1064
|
+
|
|
1065
|
+
sort(comparator: (a: i64, b: i64) => i32 = COMPARATOR<i64>()): Int64Array {
|
|
1066
|
+
SORT<i64>(this.dataStart, this.length, comparator);
|
|
1067
|
+
return this;
|
|
1068
|
+
}
|
|
1069
|
+
|
|
1070
|
+
slice(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Int64Array {
|
|
1071
|
+
return SLICE<Int64Array, i64>(this, begin, end);
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1074
|
+
subarray(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Int64Array {
|
|
1075
|
+
return SUBARRAY<Int64Array, i64>(this, begin, end);
|
|
1076
|
+
}
|
|
1077
|
+
|
|
1078
|
+
copyWithin(target: i32, start: i32, end: i32 = i32.MAX_VALUE): Int64Array {
|
|
1079
|
+
return COPY_WITHIN<Int64Array, i64>(this, target, start, end);
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1082
|
+
reduce<T extends number>(
|
|
1083
|
+
fn: (accumulator: T, value: i64, index: i32, array: Int64Array) => T,
|
|
1084
|
+
initialValue: T,
|
|
1085
|
+
): T {
|
|
1086
|
+
return REDUCE<Int64Array, i64, T>(this, fn, initialValue);
|
|
1087
|
+
}
|
|
1088
|
+
|
|
1089
|
+
reduceRight<T extends number>(
|
|
1090
|
+
fn: (accumulator: T, value: i64, index: i32, array: Int64Array) => T,
|
|
1091
|
+
initialValue: T,
|
|
1092
|
+
): T {
|
|
1093
|
+
return REDUCE_RIGHT<Int64Array, i64, T>(this, fn, initialValue);
|
|
1094
|
+
}
|
|
1095
|
+
|
|
1096
|
+
map(fn: (value: i64, index: i32, self: Int64Array) => i64): Int64Array {
|
|
1097
|
+
return MAP<Int64Array, i64>(this, fn);
|
|
1098
|
+
}
|
|
1099
|
+
|
|
1100
|
+
filter(fn: (value: i64, index: i32, self: Int64Array) => bool): Int64Array {
|
|
1101
|
+
return FILTER<Int64Array, i64>(this, fn);
|
|
1102
|
+
}
|
|
1103
|
+
|
|
1104
|
+
findIndex(fn: (value: i64, index: i32, self: Int64Array) => bool): i32 {
|
|
1105
|
+
return FIND_INDEX<Int64Array, i64>(this, fn);
|
|
1106
|
+
}
|
|
1107
|
+
|
|
1108
|
+
findLastIndex(fn: (value: i64, index: i32, self: Int64Array) => bool): i32 {
|
|
1109
|
+
return FIND_LAST_INDEX<Int64Array, i64>(this, fn);
|
|
1110
|
+
}
|
|
1111
|
+
|
|
1112
|
+
some(fn: (value: i64, index: i32, self: Int64Array) => bool): bool {
|
|
1113
|
+
return SOME<Int64Array, i64>(this, fn);
|
|
1114
|
+
}
|
|
1115
|
+
|
|
1116
|
+
every(fn: (value: i64, index: i32, self: Int64Array) => bool): bool {
|
|
1117
|
+
return EVERY<Int64Array, i64>(this, fn);
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1120
|
+
forEach(fn: (value: i64, index: i32, self: Int64Array) => void): void {
|
|
1121
|
+
FOREACH<Int64Array, i64>(this, fn);
|
|
1122
|
+
}
|
|
1123
|
+
|
|
1124
|
+
reverse(): Int64Array {
|
|
1125
|
+
REVERSE<u64>(this.dataStart, this.length);
|
|
1126
|
+
return this;
|
|
1127
|
+
}
|
|
1128
|
+
|
|
1129
|
+
join(separator: string = ","): string {
|
|
1130
|
+
return joinIntegerArray<i64>(this.dataStart, this.length, separator);
|
|
1131
|
+
}
|
|
1132
|
+
|
|
1133
|
+
set<U extends ArrayLike<number>>(source: U, offset: i32 = 0): void {
|
|
1134
|
+
SET(this, source, offset);
|
|
1135
|
+
}
|
|
1136
|
+
|
|
1137
|
+
toString(): string {
|
|
1138
|
+
return this.join();
|
|
1139
|
+
}
|
|
1140
|
+
|
|
1141
|
+
static wrap(buffer: ArrayBuffer, byteOffset: i32 = 0, length: i32 = -1): Int64Array {
|
|
1142
|
+
return WRAP<Int64Array, i64>(buffer, byteOffset, length);
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
1145
|
+
|
|
1146
|
+
export class Uint64Array extends ArrayBufferView {
|
|
1147
|
+
[key: number]: u64;
|
|
1148
|
+
|
|
1149
|
+
// @ts-ignore: decorator
|
|
1150
|
+
@lazy
|
|
1151
|
+
static readonly BYTES_PER_ELEMENT: i32 = sizeof<u64>();
|
|
1152
|
+
|
|
1153
|
+
constructor(length: i32) {
|
|
1154
|
+
super(length, alignof<u64>());
|
|
1155
|
+
}
|
|
1156
|
+
|
|
1157
|
+
get length(): i32 {
|
|
1158
|
+
return this.byteLength >>> alignof<u64>();
|
|
1159
|
+
}
|
|
1160
|
+
|
|
1161
|
+
@operator("[]")
|
|
1162
|
+
private __get(index: i32): u64 {
|
|
1163
|
+
if (<u32>index >= <u32>this.byteLength >>> alignof<u64>()) throw new RangeError(E_INDEXOUTOFRANGE);
|
|
1164
|
+
return load<u64>(this.dataStart + (<usize>index << alignof<u64>()));
|
|
1165
|
+
}
|
|
1166
|
+
|
|
1167
|
+
@unsafe @operator("{}")
|
|
1168
|
+
private __uget(index: i32): u64 {
|
|
1169
|
+
return load<u64>(this.dataStart + (<usize>index << alignof<u64>()));
|
|
1170
|
+
}
|
|
1171
|
+
|
|
1172
|
+
@operator("[]=")
|
|
1173
|
+
private __set(index: i32, value: u64): void {
|
|
1174
|
+
if (<u32>index >= <u32>this.byteLength >>> alignof<u64>()) throw new RangeError(E_INDEXOUTOFRANGE);
|
|
1175
|
+
store<u64>(this.dataStart + (<usize>index << alignof<u64>()), value);
|
|
1176
|
+
}
|
|
1177
|
+
|
|
1178
|
+
@unsafe @operator("{}=")
|
|
1179
|
+
private __uset(index: i32, value: u64): void {
|
|
1180
|
+
store<u64>(this.dataStart + (<usize>index << alignof<u64>()), value);
|
|
1181
|
+
}
|
|
1182
|
+
|
|
1183
|
+
at(index: i32): u64 {
|
|
1184
|
+
let len = this.byteLength >>> alignof<u64>();
|
|
1185
|
+
index += select(0, len, index >= 0);
|
|
1186
|
+
if (<u32>index >= <u32>len) throw new RangeError(E_INDEXOUTOFRANGE);
|
|
1187
|
+
return load<u64>(this.dataStart + (<usize>index << alignof<u64>()));
|
|
1188
|
+
}
|
|
1189
|
+
|
|
1190
|
+
includes(searchElement: u64, fromIndex: i32 = 0): bool {
|
|
1191
|
+
return INCLUDES<Uint64Array, u64>(this, searchElement, fromIndex);
|
|
1192
|
+
}
|
|
1193
|
+
|
|
1194
|
+
indexOf(searchElement: u64, fromIndex: i32 = 0): i32 {
|
|
1195
|
+
return INDEX_OF<Uint64Array, u64>(this, searchElement, fromIndex);
|
|
1196
|
+
}
|
|
1197
|
+
|
|
1198
|
+
lastIndexOf(searchElement: u64, fromIndex: i32 = this.length): i32 {
|
|
1199
|
+
return LAST_INDEX_OF<Uint64Array, u64>(this, searchElement, fromIndex);
|
|
1200
|
+
}
|
|
1201
|
+
|
|
1202
|
+
fill(value: u64, start: i32 = 0, end: i32 = i32.MAX_VALUE): Uint64Array {
|
|
1203
|
+
FILL<u64>(this.dataStart, this.length, value, start, end);
|
|
1204
|
+
return this;
|
|
1205
|
+
}
|
|
1206
|
+
|
|
1207
|
+
sort(comparator: (a: u64, b: u64) => i32 = COMPARATOR<u64>()): Uint64Array {
|
|
1208
|
+
SORT<u64>(this.dataStart, this.length, comparator);
|
|
1209
|
+
return this;
|
|
1210
|
+
}
|
|
1211
|
+
|
|
1212
|
+
slice(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Uint64Array {
|
|
1213
|
+
return SLICE<Uint64Array, u64>(this, begin, end);
|
|
1214
|
+
}
|
|
1215
|
+
|
|
1216
|
+
subarray(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Uint64Array {
|
|
1217
|
+
return SUBARRAY<Uint64Array, u64>(this, begin, end);
|
|
1218
|
+
}
|
|
1219
|
+
|
|
1220
|
+
copyWithin(target: i32, start: i32, end: i32 = i32.MAX_VALUE): Uint64Array {
|
|
1221
|
+
return COPY_WITHIN<Uint64Array, u64>(this, target, start, end);
|
|
1222
|
+
}
|
|
1223
|
+
|
|
1224
|
+
reduce<T extends number>(
|
|
1225
|
+
fn: (accumulator: T, value: u64, index: i32, array: Uint64Array) => T,
|
|
1226
|
+
initialValue: T,
|
|
1227
|
+
): T {
|
|
1228
|
+
return REDUCE<Uint64Array, u64, T>(this, fn, initialValue);
|
|
1229
|
+
}
|
|
1230
|
+
|
|
1231
|
+
reduceRight<T extends number>(
|
|
1232
|
+
fn: (accumulator: T, value: u64, index: i32, array: Uint64Array) => T,
|
|
1233
|
+
initialValue: T,
|
|
1234
|
+
): T {
|
|
1235
|
+
return REDUCE_RIGHT<Uint64Array, u64, T>(this, fn, initialValue);
|
|
1236
|
+
}
|
|
1237
|
+
|
|
1238
|
+
map(fn: (value: u64, index: i32, self: Uint64Array) => u64): Uint64Array {
|
|
1239
|
+
return MAP<Uint64Array, u64>(this, fn);
|
|
1240
|
+
}
|
|
1241
|
+
|
|
1242
|
+
filter(fn: (value: u64, index: i32, self: Uint64Array) => bool): Uint64Array {
|
|
1243
|
+
return FILTER<Uint64Array, u64>(this, fn);
|
|
1244
|
+
}
|
|
1245
|
+
|
|
1246
|
+
findIndex(fn: (value: u64, index: i32, self: Uint64Array) => bool): i32 {
|
|
1247
|
+
return FIND_INDEX<Uint64Array, u64>(this, fn);
|
|
1248
|
+
}
|
|
1249
|
+
|
|
1250
|
+
findLastIndex(fn: (value: u64, index: i32, self: Uint64Array) => bool): i32 {
|
|
1251
|
+
return FIND_LAST_INDEX<Uint64Array, u64>(this, fn);
|
|
1252
|
+
}
|
|
1253
|
+
|
|
1254
|
+
some(fn: (value: u64, index: i32, self: Uint64Array) => bool): bool {
|
|
1255
|
+
return SOME<Uint64Array, u64>(this, fn);
|
|
1256
|
+
}
|
|
1257
|
+
|
|
1258
|
+
every(fn: (value: u64, index: i32, self: Uint64Array) => bool): bool {
|
|
1259
|
+
return EVERY<Uint64Array, u64>(this, fn);
|
|
1260
|
+
}
|
|
1261
|
+
|
|
1262
|
+
forEach(fn: (value: u64, index: i32, self: Uint64Array) => void): void {
|
|
1263
|
+
FOREACH<Uint64Array, u64>(this, fn);
|
|
1264
|
+
}
|
|
1265
|
+
|
|
1266
|
+
reverse(): Uint64Array {
|
|
1267
|
+
REVERSE<u64>(this.dataStart, this.length);
|
|
1268
|
+
return this;
|
|
1269
|
+
}
|
|
1270
|
+
|
|
1271
|
+
join(separator: string = ","): string {
|
|
1272
|
+
return joinIntegerArray<u64>(this.dataStart, this.length, separator);
|
|
1273
|
+
}
|
|
1274
|
+
|
|
1275
|
+
set<U extends ArrayLike<number>>(source: U, offset: i32 = 0): void {
|
|
1276
|
+
SET(this, source, offset);
|
|
1277
|
+
}
|
|
1278
|
+
|
|
1279
|
+
toString(): string {
|
|
1280
|
+
return this.join();
|
|
1281
|
+
}
|
|
1282
|
+
|
|
1283
|
+
static wrap(buffer: ArrayBuffer, byteOffset: i32 = 0, length: i32 = -1): Uint64Array {
|
|
1284
|
+
return WRAP<Uint64Array, u64>(buffer, byteOffset, length);
|
|
1285
|
+
}
|
|
1286
|
+
}
|
|
1287
|
+
|
|
1288
|
+
export class Float32Array extends ArrayBufferView {
|
|
1289
|
+
[key: number]: f32;
|
|
1290
|
+
|
|
1291
|
+
// @ts-ignore: decorator
|
|
1292
|
+
@lazy
|
|
1293
|
+
static readonly BYTES_PER_ELEMENT: i32 = sizeof<f32>();
|
|
1294
|
+
|
|
1295
|
+
constructor(length: i32) {
|
|
1296
|
+
super(length, alignof<f32>());
|
|
1297
|
+
}
|
|
1298
|
+
|
|
1299
|
+
get length(): i32 {
|
|
1300
|
+
return this.byteLength >>> alignof<f32>();
|
|
1301
|
+
}
|
|
1302
|
+
|
|
1303
|
+
@operator("[]")
|
|
1304
|
+
private __get(index: i32): f32 {
|
|
1305
|
+
if (<u32>index >= <u32>this.byteLength >>> alignof<f32>()) throw new RangeError(E_INDEXOUTOFRANGE);
|
|
1306
|
+
return load<f32>(this.dataStart + (<usize>index << alignof<f32>()));
|
|
1307
|
+
}
|
|
1308
|
+
|
|
1309
|
+
@unsafe @operator("{}")
|
|
1310
|
+
private __uget(index: i32): f32 {
|
|
1311
|
+
return load<f32>(this.dataStart + (<usize>index << alignof<f32>()));
|
|
1312
|
+
}
|
|
1313
|
+
|
|
1314
|
+
@operator("[]=")
|
|
1315
|
+
private __set(index: i32, value: f32): void {
|
|
1316
|
+
if (<u32>index >= <u32>this.byteLength >>> alignof<f32>()) throw new RangeError(E_INDEXOUTOFRANGE);
|
|
1317
|
+
store<f32>(this.dataStart + (<usize>index << alignof<f32>()), value);
|
|
1318
|
+
}
|
|
1319
|
+
|
|
1320
|
+
@unsafe @operator("{}=")
|
|
1321
|
+
private __uset(index: i32, value: f32): void {
|
|
1322
|
+
store<f32>(this.dataStart + (<usize>index << alignof<f32>()), value);
|
|
1323
|
+
}
|
|
1324
|
+
|
|
1325
|
+
at(index: i32): f32 {
|
|
1326
|
+
let len = this.byteLength >>> alignof<f32>();
|
|
1327
|
+
index += select(0, len, index >= 0);
|
|
1328
|
+
if (<u32>index >= <u32>len) throw new RangeError(E_INDEXOUTOFRANGE);
|
|
1329
|
+
return load<f32>(this.dataStart + (<usize>index << alignof<f32>()));
|
|
1330
|
+
}
|
|
1331
|
+
|
|
1332
|
+
includes(searchElement: f32, fromIndex: i32 = 0): bool {
|
|
1333
|
+
return INCLUDES<Float32Array, f32>(this, searchElement, fromIndex);
|
|
1334
|
+
}
|
|
1335
|
+
|
|
1336
|
+
indexOf(searchElement: f32, fromIndex: i32 = 0): i32 {
|
|
1337
|
+
return INDEX_OF<Float32Array, f32>(this, searchElement, fromIndex);
|
|
1338
|
+
}
|
|
1339
|
+
|
|
1340
|
+
lastIndexOf(searchElement: f32, fromIndex: i32 = this.length): i32 {
|
|
1341
|
+
return LAST_INDEX_OF<Float32Array, f32>(this, searchElement, fromIndex);
|
|
1342
|
+
}
|
|
1343
|
+
|
|
1344
|
+
fill(value: f32, start: i32 = 0, end: i32 = i32.MAX_VALUE): Float32Array {
|
|
1345
|
+
FILL<f32>(this.dataStart, this.length, value, start, end);
|
|
1346
|
+
return this;
|
|
1347
|
+
}
|
|
1348
|
+
|
|
1349
|
+
sort(comparator: (a: f32, b: f32) => i32 = COMPARATOR<f32>()): Float32Array {
|
|
1350
|
+
SORT<f32>(this.dataStart, this.length, comparator);
|
|
1351
|
+
return this;
|
|
1352
|
+
}
|
|
1353
|
+
|
|
1354
|
+
slice(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Float32Array {
|
|
1355
|
+
return SLICE<Float32Array, f32>(this, begin, end);
|
|
1356
|
+
}
|
|
1357
|
+
|
|
1358
|
+
subarray(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Float32Array {
|
|
1359
|
+
return SUBARRAY<Float32Array, f32>(this, begin, end);
|
|
1360
|
+
}
|
|
1361
|
+
|
|
1362
|
+
copyWithin(target: i32, start: i32, end: i32 = i32.MAX_VALUE): Float32Array {
|
|
1363
|
+
return COPY_WITHIN<Float32Array, f32>(this, target, start, end);
|
|
1364
|
+
}
|
|
1365
|
+
|
|
1366
|
+
reduce<T extends number>(
|
|
1367
|
+
fn: (accumulator: T, value: f32, index: i32, array: Float32Array) => T,
|
|
1368
|
+
initialValue: T,
|
|
1369
|
+
): T {
|
|
1370
|
+
return REDUCE<Float32Array, f32, T>(this, fn, initialValue);
|
|
1371
|
+
}
|
|
1372
|
+
|
|
1373
|
+
reduceRight<T extends number>(
|
|
1374
|
+
fn: (accumulator: T, value: f32, index: i32, array: Float32Array) => T,
|
|
1375
|
+
initialValue: T,
|
|
1376
|
+
): T {
|
|
1377
|
+
return REDUCE_RIGHT<Float32Array, f32, T>(this, fn, initialValue);
|
|
1378
|
+
}
|
|
1379
|
+
|
|
1380
|
+
map(fn: (value: f32, index: i32, self: Float32Array) => f32): Float32Array {
|
|
1381
|
+
return MAP<Float32Array, f32>(this, fn);
|
|
1382
|
+
}
|
|
1383
|
+
|
|
1384
|
+
filter(fn: (value: f32, index: i32, self: Float32Array) => bool): Float32Array {
|
|
1385
|
+
return FILTER<Float32Array, f32>(this, fn);
|
|
1386
|
+
}
|
|
1387
|
+
|
|
1388
|
+
findIndex(fn: (value: f32, index: i32, self: Float32Array) => bool): i32 {
|
|
1389
|
+
return FIND_INDEX<Float32Array, f32>(this, fn);
|
|
1390
|
+
}
|
|
1391
|
+
|
|
1392
|
+
findLastIndex(fn: (value: f32, index: i32, self: Float32Array) => bool): i32 {
|
|
1393
|
+
return FIND_LAST_INDEX<Float32Array, f32>(this, fn);
|
|
1394
|
+
}
|
|
1395
|
+
|
|
1396
|
+
some(fn: (value: f32, index: i32, self: Float32Array) => bool): bool {
|
|
1397
|
+
return SOME<Float32Array, f32>(this, fn);
|
|
1398
|
+
}
|
|
1399
|
+
|
|
1400
|
+
every(fn: (value: f32, index: i32, self: Float32Array) => bool): bool {
|
|
1401
|
+
return EVERY<Float32Array, f32>(this, fn);
|
|
1402
|
+
}
|
|
1403
|
+
|
|
1404
|
+
forEach(fn: (value: f32, index: i32, self: Float32Array) => void): void {
|
|
1405
|
+
FOREACH<Float32Array, f32>(this, fn);
|
|
1406
|
+
}
|
|
1407
|
+
|
|
1408
|
+
reverse(): Float32Array {
|
|
1409
|
+
REVERSE<f32>(this.dataStart, this.length);
|
|
1410
|
+
return this;
|
|
1411
|
+
}
|
|
1412
|
+
|
|
1413
|
+
join(separator: string = ","): string {
|
|
1414
|
+
return joinFloatArray<f32>(this.dataStart, this.length, separator);
|
|
1415
|
+
}
|
|
1416
|
+
|
|
1417
|
+
set<U extends ArrayLike<number>>(source: U, offset: i32 = 0): void {
|
|
1418
|
+
SET(this, source, offset);
|
|
1419
|
+
}
|
|
1420
|
+
|
|
1421
|
+
toString(): string {
|
|
1422
|
+
return this.join();
|
|
1423
|
+
}
|
|
1424
|
+
|
|
1425
|
+
static wrap(buffer: ArrayBuffer, byteOffset: i32 = 0, length: i32 = -1): Float32Array {
|
|
1426
|
+
return WRAP<Float32Array, f32>(buffer, byteOffset, length);
|
|
1427
|
+
}
|
|
1428
|
+
}
|
|
1429
|
+
|
|
1430
|
+
export class Float64Array extends ArrayBufferView {
|
|
1431
|
+
[key: number]: f64;
|
|
1432
|
+
|
|
1433
|
+
// @ts-ignore: decorator
|
|
1434
|
+
@lazy
|
|
1435
|
+
static readonly BYTES_PER_ELEMENT: i32 = sizeof<f64>();
|
|
1436
|
+
|
|
1437
|
+
constructor(length: i32) {
|
|
1438
|
+
super(length, alignof<f64>());
|
|
1439
|
+
}
|
|
1440
|
+
|
|
1441
|
+
get length(): i32 {
|
|
1442
|
+
return this.byteLength >>> alignof<f64>();
|
|
1443
|
+
}
|
|
1444
|
+
|
|
1445
|
+
@operator("[]")
|
|
1446
|
+
private __get(index: i32): f64 {
|
|
1447
|
+
if (<u32>index >= <u32>this.byteLength >>> alignof<f64>()) throw new RangeError(E_INDEXOUTOFRANGE);
|
|
1448
|
+
return load<f64>(this.dataStart + (<usize>index << alignof<f64>()));
|
|
1449
|
+
}
|
|
1450
|
+
|
|
1451
|
+
@unsafe @operator("{}")
|
|
1452
|
+
private __uget(index: i32): f64 {
|
|
1453
|
+
return load<f64>(this.dataStart + (<usize>index << alignof<f64>()));
|
|
1454
|
+
}
|
|
1455
|
+
|
|
1456
|
+
@operator("[]=")
|
|
1457
|
+
private __set(index: i32, value: f64): void {
|
|
1458
|
+
if (<u32>index >= <u32>this.byteLength >>> alignof<f64>()) throw new RangeError(E_INDEXOUTOFRANGE);
|
|
1459
|
+
store<f64>(this.dataStart + (<usize>index << alignof<f64>()), value);
|
|
1460
|
+
}
|
|
1461
|
+
|
|
1462
|
+
@unsafe @operator("{}=")
|
|
1463
|
+
private __uset(index: i32, value: f64): void {
|
|
1464
|
+
store<f64>(this.dataStart + (<usize>index << alignof<f64>()), value);
|
|
1465
|
+
}
|
|
1466
|
+
|
|
1467
|
+
at(index: i32): f64 {
|
|
1468
|
+
let len = this.byteLength >>> alignof<f64>();
|
|
1469
|
+
index += select(0, len, index >= 0);
|
|
1470
|
+
if (<u32>index >= <u32>len) throw new RangeError(E_INDEXOUTOFRANGE);
|
|
1471
|
+
return load<f64>(this.dataStart + (<usize>index << alignof<f64>()));
|
|
1472
|
+
}
|
|
1473
|
+
|
|
1474
|
+
includes(searchElement: f64, fromIndex: i32 = 0): bool {
|
|
1475
|
+
return INCLUDES<Float64Array, f64>(this, searchElement, fromIndex);
|
|
1476
|
+
}
|
|
1477
|
+
|
|
1478
|
+
indexOf(searchElement: f64, fromIndex: i32 = 0): i32 {
|
|
1479
|
+
return INDEX_OF<Float64Array, f64>(this, searchElement, fromIndex);
|
|
1480
|
+
}
|
|
1481
|
+
|
|
1482
|
+
lastIndexOf(searchElement: f64, fromIndex: i32 = this.length): i32 {
|
|
1483
|
+
return LAST_INDEX_OF<Float64Array, f64>(this, searchElement, fromIndex);
|
|
1484
|
+
}
|
|
1485
|
+
|
|
1486
|
+
fill(value: f64, start: i32 = 0, end: i32 = i32.MAX_VALUE): Float64Array {
|
|
1487
|
+
FILL<f64>(this.dataStart, this.length, value, start, end);
|
|
1488
|
+
return this;
|
|
1489
|
+
}
|
|
1490
|
+
|
|
1491
|
+
sort(comparator: (a: f64, b: f64) => i32 = COMPARATOR<f64>()): Float64Array {
|
|
1492
|
+
SORT<f64>(this.dataStart, this.length, comparator);
|
|
1493
|
+
return this;
|
|
1494
|
+
}
|
|
1495
|
+
|
|
1496
|
+
slice(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Float64Array {
|
|
1497
|
+
return SLICE<Float64Array, f64>(this, begin, end);
|
|
1498
|
+
}
|
|
1499
|
+
|
|
1500
|
+
subarray(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Float64Array {
|
|
1501
|
+
return SUBARRAY<Float64Array, f64>(this, begin, end);
|
|
1502
|
+
}
|
|
1503
|
+
|
|
1504
|
+
copyWithin(target: i32, start: i32, end: i32 = i32.MAX_VALUE): Float64Array {
|
|
1505
|
+
return COPY_WITHIN<Float64Array, f64>(this, target, start, end);
|
|
1506
|
+
}
|
|
1507
|
+
|
|
1508
|
+
reduce<T extends number>(
|
|
1509
|
+
fn: (accumulator: T, value: f64, index: i32, array: Float64Array) => T,
|
|
1510
|
+
initialValue: T,
|
|
1511
|
+
): T {
|
|
1512
|
+
return REDUCE<Float64Array, f64, T>(this, fn, initialValue);
|
|
1513
|
+
}
|
|
1514
|
+
|
|
1515
|
+
reduceRight<T extends number>(
|
|
1516
|
+
fn: (accumulator: T, value: f64, index: i32, array: Float64Array) => T,
|
|
1517
|
+
initialValue: T,
|
|
1518
|
+
): T {
|
|
1519
|
+
return REDUCE_RIGHT<Float64Array, f64, T>(this, fn, initialValue);
|
|
1520
|
+
}
|
|
1521
|
+
|
|
1522
|
+
map(fn: (value: f64, index: i32, self: Float64Array) => f64): Float64Array {
|
|
1523
|
+
return MAP<Float64Array, f64>(this, fn);
|
|
1524
|
+
}
|
|
1525
|
+
|
|
1526
|
+
filter(fn: (value: f64, index: i32, self: Float64Array) => bool): Float64Array {
|
|
1527
|
+
return FILTER<Float64Array, f64>(this, fn);
|
|
1528
|
+
}
|
|
1529
|
+
|
|
1530
|
+
findIndex(fn: (value: f64, index: i32, self: Float64Array) => bool): i32 {
|
|
1531
|
+
return FIND_INDEX<Float64Array, f64>(this, fn);
|
|
1532
|
+
}
|
|
1533
|
+
|
|
1534
|
+
findLastIndex(fn: (value: f64, index: i32, self: Float64Array) => bool): i32 {
|
|
1535
|
+
return FIND_LAST_INDEX<Float64Array, f64>(this, fn);
|
|
1536
|
+
}
|
|
1537
|
+
|
|
1538
|
+
some(fn: (value: f64, index: i32, self: Float64Array) => bool): bool {
|
|
1539
|
+
return SOME<Float64Array, f64>(this, fn);
|
|
1540
|
+
}
|
|
1541
|
+
|
|
1542
|
+
every(fn: (value: f64, index: i32, self: Float64Array) => bool): bool {
|
|
1543
|
+
return EVERY<Float64Array, f64>(this, fn);
|
|
1544
|
+
}
|
|
1545
|
+
|
|
1546
|
+
forEach(fn: (value: f64, index: i32, self: Float64Array) => void): void {
|
|
1547
|
+
FOREACH<Float64Array, f64>(this, fn);
|
|
1548
|
+
}
|
|
1549
|
+
|
|
1550
|
+
reverse(): Float64Array {
|
|
1551
|
+
REVERSE<f64>(this.dataStart, this.length);
|
|
1552
|
+
return this;
|
|
1553
|
+
}
|
|
1554
|
+
|
|
1555
|
+
join(separator: string = ","): string {
|
|
1556
|
+
return joinFloatArray<f64>(this.dataStart, this.length, separator);
|
|
1557
|
+
}
|
|
1558
|
+
|
|
1559
|
+
set<U extends ArrayLike<number>>(source: U, offset: i32 = 0): void {
|
|
1560
|
+
SET(this, source, offset);
|
|
1561
|
+
}
|
|
1562
|
+
|
|
1563
|
+
toString(): string {
|
|
1564
|
+
return this.join();
|
|
1565
|
+
}
|
|
1566
|
+
|
|
1567
|
+
static wrap(buffer: ArrayBuffer, byteOffset: i32 = 0, length: i32 = -1): Float64Array {
|
|
1568
|
+
return WRAP<Float64Array, f64>(buffer, byteOffset, length);
|
|
1569
|
+
}
|
|
1570
|
+
}
|
|
1571
|
+
|
|
1572
|
+
// @ts-ignore: decorator
|
|
1573
|
+
@inline
|
|
1574
|
+
function SLICE<TArray extends ArrayBufferView, T extends number>(
|
|
1575
|
+
array: TArray,
|
|
1576
|
+
start: i32,
|
|
1577
|
+
end: i32
|
|
1578
|
+
): TArray {
|
|
1579
|
+
let len = array.length;
|
|
1580
|
+
start = start < 0 ? max(start + len, 0) : min(start, len);
|
|
1581
|
+
end = end < 0 ? max(end + len, 0) : min(end , len);
|
|
1582
|
+
len = max(end - start, 0);
|
|
1583
|
+
let slice = instantiate<TArray>(len);
|
|
1584
|
+
memory.copy(
|
|
1585
|
+
slice.dataStart,
|
|
1586
|
+
array.dataStart + (<usize>start << alignof<T>()),
|
|
1587
|
+
<usize>len << alignof<T>()
|
|
1588
|
+
);
|
|
1589
|
+
return slice;
|
|
1590
|
+
}
|
|
1591
|
+
|
|
1592
|
+
// @ts-ignore: decorator
|
|
1593
|
+
@inline
|
|
1594
|
+
function SUBARRAY<TArray extends ArrayBufferView, T extends number>(
|
|
1595
|
+
array: TArray,
|
|
1596
|
+
begin: i32,
|
|
1597
|
+
end: i32
|
|
1598
|
+
): TArray {
|
|
1599
|
+
let len = array.length;
|
|
1600
|
+
begin = begin < 0 ? max(len + begin, 0) : min(begin, len);
|
|
1601
|
+
end = end < 0 ? max(len + end, 0) : min(end, len);
|
|
1602
|
+
end = max(end, begin);
|
|
1603
|
+
|
|
1604
|
+
let out = changetype<TArray>(__new(offsetof<TArray>(), idof<TArray>()));
|
|
1605
|
+
let buf = changetype<usize>(array.buffer);
|
|
1606
|
+
store<usize>(changetype<usize>(out), buf, offsetof<TArray>("buffer"));
|
|
1607
|
+
if (ASC_RUNTIME != Runtime.Memory) {
|
|
1608
|
+
__link(changetype<usize>(out), buf, false);
|
|
1609
|
+
}
|
|
1610
|
+
store<usize>(changetype<usize>(out), array.dataStart + (<usize>begin << alignof<T>()), offsetof<TArray>("dataStart"));
|
|
1611
|
+
store<u32>(changetype<usize>(out), (end - begin) << alignof<T>(), offsetof<TArray>("byteLength"));
|
|
1612
|
+
return out;
|
|
1613
|
+
}
|
|
1614
|
+
|
|
1615
|
+
// @ts-ignore: decorator
|
|
1616
|
+
@inline
|
|
1617
|
+
function COPY_WITHIN<TArray extends ArrayBufferView, T extends number>(
|
|
1618
|
+
array: TArray,
|
|
1619
|
+
target: i32,
|
|
1620
|
+
start: i32,
|
|
1621
|
+
end: i32
|
|
1622
|
+
): TArray {
|
|
1623
|
+
let len = array.length;
|
|
1624
|
+
let ptr = array.dataStart;
|
|
1625
|
+
|
|
1626
|
+
end = min<i32>(end, len);
|
|
1627
|
+
let to = target < 0 ? max(len + target, 0) : min(target, len);
|
|
1628
|
+
let from = start < 0 ? max(len + start, 0) : min(start, len);
|
|
1629
|
+
let last = end < 0 ? max(len + end, 0) : min(end, len);
|
|
1630
|
+
let count = min(last - from, len - to);
|
|
1631
|
+
|
|
1632
|
+
memory.copy(
|
|
1633
|
+
ptr + (<usize>to << alignof<T>()),
|
|
1634
|
+
ptr + (<usize>from << alignof<T>()),
|
|
1635
|
+
<usize>count << alignof<T>()
|
|
1636
|
+
);
|
|
1637
|
+
return array;
|
|
1638
|
+
}
|
|
1639
|
+
|
|
1640
|
+
// @ts-ignore: decorator
|
|
1641
|
+
@inline
|
|
1642
|
+
function REDUCE<TArray extends ArrayBufferView, T extends number, TRet extends number>(
|
|
1643
|
+
array: TArray,
|
|
1644
|
+
fn: (accumulator: TRet, value: T, index: i32, array: TArray) => TRet,
|
|
1645
|
+
initialValue: TRet
|
|
1646
|
+
): TRet {
|
|
1647
|
+
let ptr = array.dataStart;
|
|
1648
|
+
for (let i = 0, k = array.length; i < k; i++) {
|
|
1649
|
+
initialValue = fn(initialValue, load<T>(ptr + (<usize>i << alignof<T>())), i, array);
|
|
1650
|
+
}
|
|
1651
|
+
return initialValue;
|
|
1652
|
+
}
|
|
1653
|
+
|
|
1654
|
+
// @ts-ignore: decorator
|
|
1655
|
+
@inline
|
|
1656
|
+
function REDUCE_RIGHT<TArray extends ArrayBufferView, T extends number, TRet extends number>(
|
|
1657
|
+
array: TArray,
|
|
1658
|
+
fn: (accumulator: TRet, value: T, index: i32, array: TArray) => TRet,
|
|
1659
|
+
initialValue: TRet
|
|
1660
|
+
): TRet {
|
|
1661
|
+
let ptr = array.dataStart;
|
|
1662
|
+
for (let i = array.length - 1; i >= 0; i--) {
|
|
1663
|
+
initialValue = fn(initialValue, load<T>(ptr + (<usize>i << alignof<T>())), i, array);
|
|
1664
|
+
}
|
|
1665
|
+
return initialValue;
|
|
1666
|
+
}
|
|
1667
|
+
|
|
1668
|
+
// @ts-ignore: decorator
|
|
1669
|
+
@inline
|
|
1670
|
+
function MAP<TArray extends ArrayBufferView, T extends number>(
|
|
1671
|
+
array: TArray,
|
|
1672
|
+
fn: (value: T, index: i32, self: TArray) => T,
|
|
1673
|
+
): TArray {
|
|
1674
|
+
let len = array.length;
|
|
1675
|
+
let ptr = array.dataStart;
|
|
1676
|
+
|
|
1677
|
+
let byteLength = len << alignof<T>();
|
|
1678
|
+
let out = changetype<TArray>(__new(offsetof<TArray>(), idof<TArray>()));
|
|
1679
|
+
let buf = changetype<ArrayBuffer>(__new(byteLength, idof<ArrayBuffer>()));
|
|
1680
|
+
for (let i = 0; i < len; i++) {
|
|
1681
|
+
store<T>(
|
|
1682
|
+
changetype<usize>(buf) + (<usize>i << alignof<T>()),
|
|
1683
|
+
fn(load<T>(ptr + (<usize>i << alignof<T>())), i, array)
|
|
1684
|
+
);
|
|
1685
|
+
}
|
|
1686
|
+
store<usize>(changetype<usize>(out), changetype<usize>(buf), offsetof<TArray>("buffer"));
|
|
1687
|
+
if (ASC_RUNTIME != Runtime.Memory) {
|
|
1688
|
+
__link(changetype<usize>(out), changetype<usize>(buf), false);
|
|
1689
|
+
}
|
|
1690
|
+
store<usize>(changetype<usize>(out), changetype<usize>(buf), offsetof<TArray>("dataStart"));
|
|
1691
|
+
store<u32>(changetype<usize>(out), byteLength, offsetof<TArray>("byteLength"));
|
|
1692
|
+
return out;
|
|
1693
|
+
}
|
|
1694
|
+
|
|
1695
|
+
// @ts-ignore: decorator
|
|
1696
|
+
@inline
|
|
1697
|
+
function FILTER<TArray extends ArrayBufferView, T extends number>(
|
|
1698
|
+
array: TArray,
|
|
1699
|
+
fn: (value: T, index: i32, self: TArray) => bool,
|
|
1700
|
+
): TArray {
|
|
1701
|
+
let len = array.length;
|
|
1702
|
+
let out = changetype<TArray>(__new(offsetof<TArray>(), idof<TArray>()));
|
|
1703
|
+
let buf = changetype<ArrayBuffer>(__new(len << alignof<T>(), idof<ArrayBuffer>()));
|
|
1704
|
+
let dataStart = array.dataStart;
|
|
1705
|
+
let j: usize = 0;
|
|
1706
|
+
for (let i = 0; i < len; i++) {
|
|
1707
|
+
let value = load<T>(dataStart + (<usize>i << alignof<T>()));
|
|
1708
|
+
if (fn(value, i, array)) {
|
|
1709
|
+
store<T>(
|
|
1710
|
+
changetype<usize>(buf) + (j++ << alignof<T>()),
|
|
1711
|
+
value
|
|
1712
|
+
);
|
|
1713
|
+
}
|
|
1714
|
+
}
|
|
1715
|
+
// shrink output buffer
|
|
1716
|
+
let byteLength = j << alignof<T>();
|
|
1717
|
+
let data = __renew(changetype<usize>(buf), byteLength);
|
|
1718
|
+
store<usize>(changetype<usize>(out), data, offsetof<TArray>("buffer"));
|
|
1719
|
+
if (ASC_RUNTIME != Runtime.Memory) {
|
|
1720
|
+
__link(changetype<usize>(out), data, false);
|
|
1721
|
+
}
|
|
1722
|
+
store<u32>(changetype<usize>(out), byteLength, offsetof<TArray>("byteLength"));
|
|
1723
|
+
store<usize>(changetype<usize>(out), data, offsetof<TArray>("dataStart"));
|
|
1724
|
+
return out;
|
|
1725
|
+
}
|
|
1726
|
+
|
|
1727
|
+
// @ts-ignore: decorator
|
|
1728
|
+
@inline
|
|
1729
|
+
function FIND_INDEX<TArray extends ArrayBufferView, T extends number>(
|
|
1730
|
+
array: TArray,
|
|
1731
|
+
fn: (value: T, index: i32, array: TArray) => bool,
|
|
1732
|
+
): i32 {
|
|
1733
|
+
let ptr = array.dataStart;
|
|
1734
|
+
for (let i = 0, k = array.length; i < k; i++) {
|
|
1735
|
+
if (fn(load<T>(ptr + (<usize>i << alignof<T>())), i, array)) return i;
|
|
1736
|
+
}
|
|
1737
|
+
return -1;
|
|
1738
|
+
}
|
|
1739
|
+
|
|
1740
|
+
// @ts-ignore: decorator
|
|
1741
|
+
@inline
|
|
1742
|
+
function FIND_LAST_INDEX<TArray extends ArrayBufferView, T extends number>(
|
|
1743
|
+
array: TArray,
|
|
1744
|
+
fn: (value: T, index: i32, array: TArray) => bool,
|
|
1745
|
+
): i32 {
|
|
1746
|
+
let ptr = array.dataStart;
|
|
1747
|
+
for (let i = array.length - 1; i >= 0; --i) {
|
|
1748
|
+
if (fn(load<T>(ptr + (<usize>i << alignof<T>())), i, array)) return i;
|
|
1749
|
+
}
|
|
1750
|
+
return -1;
|
|
1751
|
+
}
|
|
1752
|
+
|
|
1753
|
+
// @ts-ignore: decorator
|
|
1754
|
+
@inline
|
|
1755
|
+
function INCLUDES<TArray extends ArrayBufferView, T extends number>(
|
|
1756
|
+
array: TArray,
|
|
1757
|
+
searchElement: T,
|
|
1758
|
+
fromIndex: i32,
|
|
1759
|
+
): bool {
|
|
1760
|
+
if (isFloat<T>()) {
|
|
1761
|
+
let index: isize = fromIndex;
|
|
1762
|
+
let len: isize = array.length;
|
|
1763
|
+
if (len == 0 || index >= len) return false;
|
|
1764
|
+
if (index < 0) index = max(len + index, 0);
|
|
1765
|
+
let dataStart = array.dataStart;
|
|
1766
|
+
while (index < len) {
|
|
1767
|
+
let elem = load<T>(dataStart + (index << alignof<T>()));
|
|
1768
|
+
// @ts-ignore
|
|
1769
|
+
if (elem == searchElement || isNaN(elem) & isNaN(searchElement)) return true;
|
|
1770
|
+
++index;
|
|
1771
|
+
}
|
|
1772
|
+
return false;
|
|
1773
|
+
} else {
|
|
1774
|
+
return INDEX_OF<TArray, T>(array, searchElement, fromIndex) >= 0;
|
|
1775
|
+
}
|
|
1776
|
+
}
|
|
1777
|
+
|
|
1778
|
+
// @ts-ignore: decorator
|
|
1779
|
+
@inline
|
|
1780
|
+
function INDEX_OF<TArray extends ArrayBufferView, T extends number>(
|
|
1781
|
+
array: TArray,
|
|
1782
|
+
searchElement: T,
|
|
1783
|
+
fromIndex: i32,
|
|
1784
|
+
): i32 {
|
|
1785
|
+
let index: isize = fromIndex;
|
|
1786
|
+
let len: isize = array.length;
|
|
1787
|
+
if (len == 0 || index >= len) return -1;
|
|
1788
|
+
if (index < 0) index = max(len + index, 0);
|
|
1789
|
+
let dataStart = array.dataStart;
|
|
1790
|
+
while (index < len) {
|
|
1791
|
+
if (load<T>(dataStart + (index << alignof<T>())) == searchElement) return <i32>index;
|
|
1792
|
+
++index;
|
|
1793
|
+
}
|
|
1794
|
+
return -1;
|
|
1795
|
+
}
|
|
1796
|
+
|
|
1797
|
+
// @ts-ignore: decorator
|
|
1798
|
+
@inline
|
|
1799
|
+
function LAST_INDEX_OF<TArray extends ArrayBufferView, T extends number>(
|
|
1800
|
+
array: TArray,
|
|
1801
|
+
searchElement: T,
|
|
1802
|
+
fromIndex: i32,
|
|
1803
|
+
): i32 {
|
|
1804
|
+
let index: isize = fromIndex;
|
|
1805
|
+
let len: isize = array.length;
|
|
1806
|
+
if (len == 0) return -1;
|
|
1807
|
+
if (index < 0) index = len + index; // no need to clamp
|
|
1808
|
+
else if (index >= len) index = len - 1;
|
|
1809
|
+
let dataStart = array.dataStart;
|
|
1810
|
+
while (index >= 0) {
|
|
1811
|
+
if (load<T>(dataStart + (index << alignof<T>())) == searchElement) return <i32>index;
|
|
1812
|
+
--index;
|
|
1813
|
+
}
|
|
1814
|
+
return -1;
|
|
1815
|
+
}
|
|
1816
|
+
|
|
1817
|
+
// @ts-ignore: decorator
|
|
1818
|
+
@inline
|
|
1819
|
+
function SOME<TArray extends ArrayBufferView, T extends number>(
|
|
1820
|
+
array: TArray,
|
|
1821
|
+
fn: (value: T, index: i32, array: TArray) => bool,
|
|
1822
|
+
): bool {
|
|
1823
|
+
let ptr = array.dataStart;
|
|
1824
|
+
for (let i = 0, k = array.length; i < k; i++) {
|
|
1825
|
+
if (fn(load<T>(ptr + (<usize>i << alignof<T>())), i, array)) return true;
|
|
1826
|
+
}
|
|
1827
|
+
return false;
|
|
1828
|
+
}
|
|
1829
|
+
|
|
1830
|
+
// @ts-ignore: decorator
|
|
1831
|
+
@inline
|
|
1832
|
+
function EVERY<TArray extends ArrayBufferView, T extends number>(
|
|
1833
|
+
array: TArray,
|
|
1834
|
+
fn: (value: T, index: i32, array: TArray) => bool,
|
|
1835
|
+
): bool {
|
|
1836
|
+
let ptr = array.dataStart;
|
|
1837
|
+
for (let i = 0, k = array.length; i < k; i++) {
|
|
1838
|
+
if (fn(load<T>(ptr + (<usize>i << alignof<T>())), i, array)) continue;
|
|
1839
|
+
return false;
|
|
1840
|
+
}
|
|
1841
|
+
return true;
|
|
1842
|
+
}
|
|
1843
|
+
|
|
1844
|
+
// @ts-ignore: decorator
|
|
1845
|
+
@inline
|
|
1846
|
+
function FOREACH<TArray extends ArrayBufferView, T extends number>(
|
|
1847
|
+
array: TArray,
|
|
1848
|
+
fn: (value: T, index: i32, array: TArray) => void,
|
|
1849
|
+
): void {
|
|
1850
|
+
let ptr = array.dataStart;
|
|
1851
|
+
for (let i = 0, k = array.length; i < k; i++) {
|
|
1852
|
+
fn(load<T>(ptr + (<usize>i << alignof<T>())), i, array);
|
|
1853
|
+
}
|
|
1854
|
+
}
|
|
1855
|
+
|
|
1856
|
+
// @ts-ignore: decorator
|
|
1857
|
+
@inline
|
|
1858
|
+
function WRAP<TArray extends ArrayBufferView, T>(
|
|
1859
|
+
buffer: ArrayBuffer,
|
|
1860
|
+
byteOffset: i32 = 0,
|
|
1861
|
+
len: i32 = -1
|
|
1862
|
+
): TArray {
|
|
1863
|
+
let byteLength: i32;
|
|
1864
|
+
let bufferByteLength = buffer.byteLength;
|
|
1865
|
+
const mask: u32 = sizeof<T>() - 1;
|
|
1866
|
+
if (i32(<u32>byteOffset > <u32>bufferByteLength) | (byteOffset & mask)) {
|
|
1867
|
+
throw new RangeError(E_INDEXOUTOFRANGE);
|
|
1868
|
+
}
|
|
1869
|
+
if (len < 0) {
|
|
1870
|
+
if (len == -1) {
|
|
1871
|
+
if (bufferByteLength & mask) {
|
|
1872
|
+
throw new RangeError(E_INVALIDLENGTH);
|
|
1873
|
+
}
|
|
1874
|
+
byteLength = bufferByteLength - byteOffset;
|
|
1875
|
+
} else {
|
|
1876
|
+
throw new RangeError(E_INVALIDLENGTH);
|
|
1877
|
+
}
|
|
1878
|
+
} else {
|
|
1879
|
+
byteLength = len << alignof<T>();
|
|
1880
|
+
if (byteOffset + byteLength > bufferByteLength) {
|
|
1881
|
+
throw new RangeError(E_INVALIDLENGTH);
|
|
1882
|
+
}
|
|
1883
|
+
}
|
|
1884
|
+
let out = changetype<TArray>(__new(offsetof<TArray>(), idof<TArray>()));
|
|
1885
|
+
store<usize>(changetype<usize>(out), changetype<usize>(buffer), offsetof<TArray>("buffer"));
|
|
1886
|
+
if (ASC_RUNTIME != Runtime.Memory) {
|
|
1887
|
+
__link(changetype<usize>(out), changetype<usize>(buffer), false);
|
|
1888
|
+
}
|
|
1889
|
+
store<u32>(changetype<usize>(out), byteLength, offsetof<TArray>("byteLength"));
|
|
1890
|
+
store<usize>(changetype<usize>(out), changetype<usize>(buffer) + <usize>byteOffset, offsetof<TArray>("dataStart"));
|
|
1891
|
+
return out;
|
|
1892
|
+
}
|
|
1893
|
+
|
|
1894
|
+
// @ts-ignore: decorator
|
|
1895
|
+
@inline
|
|
1896
|
+
function SET<
|
|
1897
|
+
TArray extends ArrayLike<number>,
|
|
1898
|
+
UArray extends ArrayLike<number>
|
|
1899
|
+
>(
|
|
1900
|
+
target: TArray,
|
|
1901
|
+
source: UArray,
|
|
1902
|
+
offset: i32 = 0
|
|
1903
|
+
): void {
|
|
1904
|
+
// need to assert at compile time that U is not a reference or a function
|
|
1905
|
+
if (isReference<valueof<UArray>>()) {
|
|
1906
|
+
ERROR(E_NOTIMPLEMENTED);
|
|
1907
|
+
}
|
|
1908
|
+
let sourceLen = source.length;
|
|
1909
|
+
if (offset < 0 || sourceLen + offset > target.length) {
|
|
1910
|
+
// offset is out of bounds
|
|
1911
|
+
throw new RangeError(E_INDEXOUTOFRANGE);
|
|
1912
|
+
}
|
|
1913
|
+
// @ts-ignore: dataStart
|
|
1914
|
+
let targetStart = target.dataStart + (<usize>offset << (alignof<valueof<TArray>>()));
|
|
1915
|
+
// @ts-ignore: dataStart
|
|
1916
|
+
let sourceStart = source.dataStart;
|
|
1917
|
+
// if the types align and match, use memory.copy() instead of manual loop
|
|
1918
|
+
if (
|
|
1919
|
+
isInteger<valueof<TArray>>() == isInteger<valueof<UArray>>() &&
|
|
1920
|
+
alignof<valueof<TArray>>() == alignof<valueof<UArray>>() &&
|
|
1921
|
+
!(isSigned<valueof<UArray>>() && target instanceof Uint8ClampedArray)
|
|
1922
|
+
) {
|
|
1923
|
+
memory.copy(targetStart, sourceStart, <usize>sourceLen << (alignof<valueof<UArray>>()));
|
|
1924
|
+
} else {
|
|
1925
|
+
for (let i = 0; i < sourceLen; i++) {
|
|
1926
|
+
let ptr = targetStart + (<usize>i << (alignof<valueof<TArray>>()));
|
|
1927
|
+
let value = load<valueof<UArray>>(sourceStart + (<usize>i << (alignof<valueof<UArray>>())));
|
|
1928
|
+
// if TArray is Uint8ClampedArray, then values must be clamped
|
|
1929
|
+
if (target instanceof Uint8ClampedArray) {
|
|
1930
|
+
if (isFloat<valueof<UArray>>()) {
|
|
1931
|
+
store<valueof<TArray>>(ptr,
|
|
1932
|
+
isFinite<valueof<UArray>>(value)
|
|
1933
|
+
? <valueof<TArray>>max<valueof<UArray>>(0, min<valueof<UArray>>(255, value))
|
|
1934
|
+
: 0
|
|
1935
|
+
);
|
|
1936
|
+
} else {
|
|
1937
|
+
if (!isSigned<valueof<UArray>>()) {
|
|
1938
|
+
store<valueof<TArray>>(ptr, min<valueof<UArray>>(255, value));
|
|
1939
|
+
} else if (sizeof<valueof<TArray>>() <= 4) {
|
|
1940
|
+
store<valueof<TArray>>(ptr, ~(<i32>value >> 31) & (((255 - <i32>value) >> 31) | value));
|
|
1941
|
+
} else {
|
|
1942
|
+
store<valueof<TArray>>(ptr, ~(<i64>value >> 63) & (((255 - <i64>value) >> 63) | value));
|
|
1943
|
+
}
|
|
1944
|
+
}
|
|
1945
|
+
} else {
|
|
1946
|
+
if (isFloat<valueof<UArray>>() && !isFloat<valueof<TArray>>()) {
|
|
1947
|
+
store<valueof<TArray>>(ptr, isFinite<valueof<UArray>>(value) ? <valueof<TArray>>value : 0);
|
|
1948
|
+
} else {
|
|
1949
|
+
store<valueof<TArray>>(ptr, <valueof<TArray>>value);
|
|
1950
|
+
}
|
|
1951
|
+
}
|
|
1952
|
+
}
|
|
1953
|
+
}
|
|
1954
|
+
}
|