/
index.d.ts
1564 lines (1499 loc) · 87 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* Environment definitions for compiling AssemblyScript to WebAssembly using asc.
* @module std/assembly
*//***/
/// <reference no-default-lib="true"/>
// Types
/** An 8-bit signed integer. */
declare type i8 = number;
/** A 16-bit signed integer. */
declare type i16 = number;
/** A 32-bit signed integer. */
declare type i32 = number;
/** A 64-bit signed integer. */
declare type i64 = number;
/** A 32-bit signed integer when targeting 32-bit WebAssembly or a 64-bit signed integer when targeting 64-bit WebAssembly. */
declare type isize = number;
/** An 8-bit unsigned integer. */
declare type u8 = number;
/** A 16-bit unsigned integer. */
declare type u16 = number;
/** A 32-bit unsigned integer. */
declare type u32 = number;
/** A 64-bit unsigned integer. */
declare type u64 = number;
/** A 32-bit unsigned integer when targeting 32-bit WebAssembly or a 64-bit unsigned integer when targeting 64-bit WebAssembly. */
declare type usize = number;
/** A 1-bit unsigned integer. */
declare type bool = boolean | number;
/** A 32-bit float. */
declare type f32 = number;
/** A 64-bit float. */
declare type f64 = number;
/** A 128-bit vector. */
declare type v128 = object;
// Compiler hints
/** Compiler target. 0 = JS, 1 = WASM32, 2 = WASM64. */
declare const ASC_TARGET: i32;
/** Provided noAssert option. */
declare const ASC_NO_ASSERT: bool;
/** Provided memoryBase option. */
declare const ASC_MEMORY_BASE: i32;
/** Provided optimizeLevel option. */
declare const ASC_OPTIMIZE_LEVEL: i32;
/** Provided shrinkLevel option. */
declare const ASC_SHRINK_LEVEL: i32;
/** Whether the mutable global feature is enabled. */
declare const ASC_FEATURE_MUTABLE_GLOBAL: bool;
/** Whether the sign extension feature is enabled. */
declare const ASC_FEATURE_SIGN_EXTENSION: bool;
/** Whether the bulk memory feature is enabled. */
declare const ASC_FEATURE_BULK_MEMORY: bool;
/** Whether the SIMD feature is enabled. */
declare const ASC_FEATURE_SIMD: bool;
/** Whether the threads feature is enabled. */
declare const ASC_FEATURE_THREADS: bool;
// Builtins
/** Performs the sign-agnostic count leading zero bits operation on a 32-bit or 64-bit integer. All zero bits are considered leading if the value is zero. */
declare function clz<T = i32 | i64>(value: T): T;
/** Performs the sign-agnostic count tailing zero bits operation on a 32-bit or 64-bit integer. All zero bits are considered trailing if the value is zero. */
declare function ctz<T = i32 | i64>(value: T): T;
/** Performs the sign-agnostic count number of one bits operation on a 32-bit or 64-bit integer. */
declare function popcnt<T = i32 | i64>(value: T): T;
/** Performs the sign-agnostic rotate left operation on a 32-bit or 64-bit integer. */
declare function rotl<T = i32 | i64>(value: T, shift: T): T;
/** Performs the sign-agnostic rotate right operation on a 32-bit or 64-bit integer. */
declare function rotr<T = i32 | i64>(value: T, shift: T): T;
/** Computes the absolute value of an integer or float. */
declare function abs<T = i32 | i64 | f32 | f64>(value: T): T;
/** Determines the maximum of two integers or floats. If either operand is `NaN`, returns `NaN`. */
declare function max<T = i32 | i64 | f32 | f64>(left: T, right: T): T;
/** Determines the minimum of two integers or floats. If either operand is `NaN`, returns `NaN`. */
declare function min<T = i32 | i64 | f32 | f64>(left: T, right: T): T;
/** Performs the ceiling operation on a 32-bit or 64-bit float. */
declare function ceil<T = f32 | f64>(value: T): T;
/** Composes a 32-bit or 64-bit float from the magnitude of `x` and the sign of `y`. */
declare function copysign<T = f32 | f64>(x: T, y: T): T;
/** Performs the floor operation on a 32-bit or 64-bit float. */
declare function floor<T = f32 | f64>(value: T): T;
/** Rounds to the nearest integer tied to even of a 32-bit or 64-bit float. */
declare function nearest<T = f32 | f64>(value: T): T;
/** Reinterprets the bits of the specified value as type `T`. Valid reinterpretations are u32/i32 to/from f32 and u64/i64 to/from f64. */
declare function reinterpret<T = i32 | i64 | f32 | f64>(value: number): T;
/** Selects one of two pre-evaluated values depending on the condition. */
declare function select<T>(ifTrue: T, ifFalse: T, condition: bool): T;
/** Calculates the square root of a 32-bit or 64-bit float. */
declare function sqrt<T = f32 | f64>(value: T): T;
/** Rounds to the nearest integer towards zero of a 32-bit or 64-bit float. */
declare function trunc<T = f32 | f64>(value: T): T;
/** Loads a value of the specified type from memory. Equivalent to dereferncing a pointer in other languages. */
declare function load<T>(ptr: usize, immOffset?: usize, immAlign?: usize): T;
/** Stores a value of the specified type to memory. Equivalent to dereferencing a pointer in other languages when assigning a value. */
declare function store<T>(ptr: usize, value: any, immOffset?: usize, immAlign?: usize): void;
/** Emits an unreachable operation that results in a runtime error when executed. Both a statement and an expression of any type. */
declare function unreachable(): any; // sic
/** NaN (not a number) as a 32-bit or 64-bit float depending on context. */
declare const NaN: f32 | f64;
/** Positive infinity as a 32-bit or 64-bit float depending on context. */
declare const Infinity: f32 | f64;
/** Heap base offset. */
declare const __heap_base: usize;
/** Determines the byte size of the specified underlying core type. Compiles to a constant. */
declare function sizeof<T>(): usize;
/** Determines the alignment (log2) of the specified underlying core type. Compiles to a constant. */
declare function alignof<T>(): usize;
/** Determines the end offset of the given class type. Compiles to a constant. */
declare function offsetof<T>(): usize;
/** Determines the offset of the specified field within the given class type. Compiles to a constant. */
declare function offsetof<T>(fieldName: keyof T | string): usize;
/** Determines the offset of the specified field within the given class type. Returns the class type's end offset if field name has been omitted. Compiles to a constant. */
declare function offsetof<T>(fieldName?: string): usize;
/** Determines the unique runtime id of a class type. Compiles to a constant. */
declare function idof<T>(): u32;
/** Changes the type of any value of `usize` kind to another one of `usize` kind. Useful for casting class instances to their pointer values and vice-versa. Beware that this is unsafe.*/
declare function changetype<T>(value: any): T;
/** Explicitly requests no bounds checks on the provided expression. Useful for array accesses. */
declare function unchecked<T>(value: T): T;
/** Emits a `call_indirect` instruction, calling the specified function in the function table by index with the specified arguments. Does result in a runtime error if the arguments do not match the called function. */
declare function call_indirect<T>(target: Function | u32, ...args: any[]): T;
/** Emits a `call` instruction, calling the specified function in the function table directly with the specified arguments. Function index must be a compile-time constant. */
declare function call_direct<T>(target: Function | u32, ...args: any[]): T;
/** Instantiates a new instance of `T` using the specified constructor arguments. */
declare function instantiate<T>(...args: any[]): T;
/** Tests if a 32-bit or 64-bit float is `NaN`. */
declare function isNaN<T = f32 | f64>(value: T): bool;
/** Tests if a 32-bit or 64-bit float is finite, that is not `NaN` or +/-`Infinity`. */
declare function isFinite<T = f32 | f64>(value: T): bool;
/** Tests if the specified type *or* expression is of an integer type and not a reference. Compiles to a constant. */
declare function isInteger<T>(value?: any): value is number;
/** Tests if the specified type *or* expression is of a float type. Compiles to a constant. */
declare function isFloat<T>(value?: any): value is number;
/** Tests if the specified type *or* expression is of a boolean type. */
declare function isBoolean<T>(value?: any): value is number;
/** Tests if the specified type *or* expression can represent negative numbers. Compiles to a constant. */
declare function isSigned<T>(value?: any): value is number;
/** Tests if the specified type *or* expression is of a reference type. Compiles to a constant. */
declare function isReference<T>(value?: any): value is object | string;
/** Tests if the specified type *or* expression can be used as a string. Compiles to a constant. */
declare function isString<T>(value?: any): value is string | String;
/** Tests if the specified type *or* expression can be used as an array. Compiles to a constant. */
declare function isArray<T>(value?: any): value is Array<any>;
/** Tests if the specified type *or* expression can be used as an array like object. Compiles to a constant. */
declare function isArrayLike<T>(value?: any): value is ArrayLike<any>;
/** Tests if the specified type *or* expression is of a function type. Compiles to a constant. */
declare function isFunction<T>(value?: any): value is (...args: any) => any;
/** Tests if the specified type *or* expression is of a nullable reference type. Compiles to a constant. */
declare function isNullable<T>(value?: any): bool;
/** Tests if the specified expression resolves to a defined element. Compiles to a constant. */
declare function isDefined(expression: any): bool;
/** Tests if the specified expression evaluates to a constant value. Compiles to a constant. */
declare function isConstant(expression: any): bool;
/** Tests if the specified type *or* expression is of a managed type. Compiles to a constant. */
declare function isManaged<T>(value?: any): bool;
/** Traps if the specified value is not true-ish, otherwise returns the (non-nullable) value. */
declare function assert<T>(isTrueish: T, message?: string): T & object; // any better way to model `: T != null`?
/** Parses an integer string to a 64-bit float. */
declare function parseInt(str: string, radix?: i32): f64;
/** Parses a string to a 64-bit float. */
declare function parseFloat(str: string): f64;
/** Returns the 64-bit floating-point remainder of `x/y`. */
declare function fmod(x: f64, y: f64): f64;
/** Returns the 32-bit floating-point remainder of `x/y`. */
declare function fmodf(x: f32, y: f32): f32;
/** Atomic operations. */
declare namespace atomic {
/** Atomically loads an integer value from memory and returns it. */
export function load<T>(offset: usize, immOffset?: usize): T;
/** Atomically stores an integer value to memory. */
export function store<T>(offset: usize, value: T, immOffset?: usize): void;
/** Atomically adds an integer value in memory. */
export function add<T>(ptr: usize, value: T, immOffset?: usize): T;
/** Atomically subtracts an integer value in memory. */
export function sub<T>(ptr: usize, value: T, immOffset?: usize): T;
/** Atomically performs a bitwise AND operation on an integer value in memory. */
export function and<T>(ptr: usize, value: T, immOffset?: usize): T;
/** Atomically performs a bitwise OR operation on an integer value in memory. */
export function or<T>(ptr: usize, value: T, immOffset?: usize): T;
/** Atomically performs a bitwise XOR operation on an integer value in memory. */
export function xor<T>(ptr: usize, value: T, immOffset?: usize): T;
/** Atomically exchanges an integer value in memory. */
export function xchg<T>(ptr: usize, value: T, immOffset?: usize): T;
/** Atomically compares and exchanges an integer value in memory if the condition is met. */
export function cmpxchg<T>(ptr: usize, expected: T, replacement: T, immOffset?: usize): T;
/** Performs a wait operation on an address in memory suspending this agent if the integer condition is met. */
export function wait<T>(ptr: usize, expected: T, timeout: i64): AtomicWaitResult;
/** Performs a notify operation on an address in memory waking up suspended agents. */
export function notify(ptr: usize, count: i32): i32;
}
/** Describes the result of an atomic wait operation. */
declare enum AtomicWaitResult {
/** Woken by another agent. */
OK,
/** Loaded value did not match the expected value. */
NOT_EQUAL,
/** Not woken before the timeout expired. */
TIMED_OUT
}
/** Converts any other numeric value to an 8-bit signed integer. */
declare function i8(value: any): i8;
declare namespace i8 {
/** Smallest representable value. */
export const MIN_VALUE: i8;
/** Largest representable value. */
export const MAX_VALUE: i8;
}
/** Converts any other numeric value to a 16-bit signed integer. */
declare function i16(value: any): i8;
declare namespace i16 {
/** Smallest representable value. */
export const MIN_VALUE: i16;
/** Largest representable value. */
export const MAX_VALUE: i16;
}
/** Converts any other numeric value to a 32-bit signed integer. */
declare function i32(value: any): i32;
declare namespace i32 {
/** Smallest representable value. */
export const MIN_VALUE: i32;
/** Largest representable value. */
export const MAX_VALUE: i32;
/** Loads an 8-bit signed integer value from memory and returns it as a 32-bit integer. */
export function load8_s(offset: usize, immOffset?: usize, immAlign?: usize): i32;
/** Loads an 8-bit unsigned integer value from memory and returns it as a 32-bit integer. */
export function load8_u(offset: usize, immOffset?: usize, immAlign?: usize): i32;
/** Loads a 16-bit signed integer value from memory and returns it as a 32-bit integer. */
export function load16_s(offset: usize, immOffset?: usize, immAlign?: usize): i32;
/** Loads a 16-bit unsigned integer value from memory and returns it as a 32-bit integer. */
export function load16_u(offset: usize, immOffset?: usize, immAlign?: usize): i32;
/** Loads a 32-bit integer value from memory. */
export function load(offset: usize, immOffset?: usize, immAlign?: usize): i32;
/** Stores a 32-bit integer value to memory as an 8-bit integer. */
export function store8(offset: usize, value: i32, immOffset?: usize, immAlign?: usize): void;
/** Stores a 32-bit integer value to memory as a 16-bit integer. */
export function store16(offset: usize, value: i32, immOffset?: usize, immAlign?: usize): void;
/** Stores a 32-bit integer value to memory. */
export function store(offset: usize, value: i32, immOffset?: usize, immAlign?: usize): void;
/** Atomic 32-bit integer operations. */
export namespace atomic {
/** Atomically loads an 8-bit unsigned integer value from memory and returns it as a 32-bit integer. */
export function load8_u(offset: usize, immOffset?: usize): i32;
/** Atomically loads a 16-bit unsigned integer value from memory and returns it as a 32-bit integer. */
export function load16_u(offset: usize, immOffset?: usize): i32;
/** Atomically loads a 32-bit integer value from memory and returns it. */
export function load(offset: usize, immOffset?: usize): i32;
/** Atomically stores a 32-bit integer value to memory as an 8-bit integer. */
export function store8(offset: usize, value: i32, immOffset?: usize): void;
/** Atomically stores a 32-bit integer value to memory as a 16-bit integer. */
export function store16(offset: usize, value: i32, immOffset?: usize): void;
/** Atomically stores a 32-bit integer value to memory. */
export function store(offset: usize, value: i32, immOffset?: usize): void;
/** Performs a wait operation on a 32-bit integer value in memory suspending this agent if the condition is met. */
export function wait(ptr: usize, expected: i32, timeout: i64): AtomicWaitResult;
/** Atomic 32-bit integer read-modify-write operations on 8-bit values. */
export namespace rmw8 {
/** Atomically adds an 8-bit unsigned integer value in memory. */
export function add_u(offset: usize, value: i32, immOffset?: usize): i32;
/** Atomically subtracts an 8-bit unsigned integer value in memory. */
export function sub_u(offset: usize, value: i32, immOffset?: usize): i32;
/** Atomically performs a bitwise AND operation an 8-bit unsigned integer value in memory. */
export function and_u(offset: usize, value: i32, immOffset?: usize): i32;
/** Atomically performs a bitwise OR operation an 8-bit unsigned integer value in memory. */
export function or_u(offset: usize, value: i32, immOffset?: usize): i32;
/** Atomically performs a bitwise XOR operation an 8-bit unsigned integer value in memory. */
export function xor_u(offset: usize, value: i32, immOffset?: usize): i32;
/** Atomically exchanges an 8-bit unsigned integer value in memory. */
export function xchg_u(offset: usize, value: i32, immOffset?: usize): i32;
/** Atomically compares and exchanges an 8-bit unsigned integer value in memory if the condition is met. */
export function cmpxchg_u(offset: usize, expected: i32, replacement: i32, immOffset?: usize): i32;
}
/** Atomic 32-bit integer read-modify-write operations on 16-bit values. */
export namespace rmw16 {
/** Atomically adds a 16-bit unsigned integer value in memory. */
export function add_u(offset: usize, value: i32, immOffset?: usize): i32;
/** Atomically adds a 16-bit unsigned integer value in memory. */
export function sub_u(offset: usize, value: i32, immOffset?: usize): i32;
/** Atomically performs a bitwise AND operation a 16-bit unsigned integer value in memory. */
export function and_u(offset: usize, value: i32, immOffset?: usize): i32;
/** Atomically performs a bitwise OR operation a 16-bit unsigned integer value in memory. */
export function or_u(offset: usize, value: i32, immOffset?: usize): i32;
/** Atomically performs a bitwise XOR operation a 16-bit unsigned integer value in memory. */
export function xor_u(offset: usize, value: i32, immOffset?: usize): i32;
/** Atomically exchanges a 16-bit unsigned integer value in memory. */
export function xchg_u(offset: usize, value: i32, immOffset?: usize): i32;
/** Atomically compares and exchanges a 16-bit unsigned integer value in memory if the condition is met. */
export function cmpxchg_u(offset: usize, expected: i32, replacement: i32, immOffset?: usize): i32;
}
/** Atomic 32-bit integer read-modify-write operations. */
export namespace rmw {
/** Atomically adds a 32-bit integer value in memory. */
export function add(offset: usize, value: i32, immOffset?: usize): i32;
/** Atomically subtracts a 32-bit integer value in memory. */
export function sub(offset: usize, value: i32, immOffset?: usize): i32;
/** Atomically performs a bitwise AND operation a 32-bit integer value in memory. */
export function and(offset: usize, value: i32, immOffset?: usize): i32;
/** Atomically performs a bitwise OR operation a 32-bit integer value in memory. */
export function or(offset: usize, value: i32, immOffset?: usize): i32;
/** Atomically performs a bitwise XOR operation a 32-bit integer value in memory. */
export function xor(offset: usize, value: i32, immOffset?: usize): i32;
/** Atomically exchanges a 32-bit integer value in memory. */
export function xchg(offset: usize, value: i32, immOffset?: usize): i32;
/** Atomically compares and exchanges a 32-bit integer value in memory if the condition is met. */
export function cmpxchg(offset: usize, expected: i32, replacement: i32, immOffset?: usize): i32;
}
}
}
/** Converts any other numeric value to a 64-bit signed integer. */
declare function i64(value: any): i64;
declare namespace i64 {
/** Smallest representable value. */
export const MIN_VALUE: i64;
/** Largest representable value. */
export const MAX_VALUE: i64;
/** Loads an 8-bit signed integer value from memory and returns it as a 64-bit integer. */
export function load8_s(offset: usize, immOffset?: usize, immAlign?: usize): i64;
/** Loads an 8-bit unsigned integer value from memory and returns it as a 64-bit integer. */
export function load8_u(offset: usize, immOffset?: usize, immAlign?: usize): i64;
/** Loads a 16-bit signed integer value from memory and returns it as a 64-bit integer. */
export function load16_s(offset: usize, immOffset?: usize, immAlign?: usize): i64;
/** Loads a 16-bit unsigned integer value from memory and returns it as a 64-bit integer. */
export function load16_u(offset: usize, immOffset?: usize, immAlign?: usize): i64;
/** Loads a 32-bit signed integer value from memory and returns it as a 64-bit integer. */
export function load32_s(offset: usize, immOffset?: usize, immAlign?: usize): i64;
/** Loads a 32-bit unsigned integer value from memory and returns it as a 64-bit integer. */
export function load32_u(offset: usize, immOffset?: usize, immAlign?: usize): i64;
/** Loads a 64-bit unsigned integer value from memory. */
export function load(offset: usize, immOffset?: usize, immAlign?: usize): i64;
/** Stores a 64-bit integer value to memory as an 8-bit integer. */
export function store8(offset: usize, value: i64, immOffset?: usize, immAlign?: usize): void;
/** Stores a 64-bit integer value to memory as a 16-bit integer. */
export function store16(offset: usize, value: i64, immOffset?: usize, immAlign?: usize): void;
/** Stores a 64-bit integer value to memory as a 32-bit integer. */
export function store32(offset: usize, value: i64, immOffset?: usize, immAlign?: usize): void;
/** Stores a 64-bit integer value to memory. */
export function store(offset: usize, value: i64, immOffset?: usize, immAlign?: usize): void;
/** Atomic 64-bit integer operations. */
export namespace atomic {
/** Atomically loads an 8-bit unsigned integer value from memory and returns it as a 64-bit integer. */
export function load8_u(offset: usize, immOffset?: usize): i64;
/** Atomically loads a 16-bit unsigned integer value from memory and returns it as a 64-bit integer. */
export function load16_u(offset: usize, immOffset?: usize): i64;
/** Atomically loads a 32-bit unsigned integer value from memory and returns it as a 64-bit integer. */
export function load32_u(offset: usize, immOffset?: usize): i64;
/** Atomically loads a 64-bit integer value from memory and returns it. */
export function load(offset: usize, immOffset?: usize): i64;
/** Atomically stores a 64-bit integer value to memory as an 8-bit integer. */
export function store8(offset: usize, value: i64, immOffset?: usize): void;
/** Atomically stores a 64-bit integer value to memory as a 16-bit integer. */
export function store16(offset: usize, value: i64, immOffset?: usize): void;
/** Atomically stores a 64-bit integer value to memory as a 32-bit integer. */
export function store32(offset: usize, value: i64, immOffset?: usize): void;
/** Atomically stores a 64-bit integer value to memory. */
export function store(offset: usize, value: i64, immOffset?: usize): void;
/** Performs a wait operation on a 64-bit integer value in memory suspending this agent if the condition is met. */
export function wait(ptr: usize, expected: i64, timeout: i64): AtomicWaitResult;
/** Atomic 64-bit integer read-modify-write operations on 8-bit values. */
export namespace rmw8 {
/** Atomically adds an 8-bit unsigned integer value in memory. */
export function add_u(offset: usize, value: i64, immOffset?: usize): i64;
/** Atomically subtracts an 8-bit unsigned integer value in memory. */
export function sub_u(offset: usize, value: i64, immOffset?: usize): i64;
/** Atomically performs a bitwise AND operation on an 8-bit unsigned integer value in memory. */
export function and_u(offset: usize, value: i64, immOffset?: usize): i64;
/** Atomically performs a bitwise OR operation on an 8-bit unsigned integer value in memory. */
export function or_u(offset: usize, value: i64, immOffset?: usize): i64;
/** Atomically performs a bitwise XOR operation on an 8-bit unsigned integer value in memory. */
export function xor_u(offset: usize, value: i64, immOffset?: usize): i64;
/** Atomically exchanges an 8-bit unsigned integer value in memory. */
export function xchg_u(offset: usize, value: i64, immOffset?: usize): i64;
/** Atomically compares and exchanges an 8-bit unsigned integer value in memory if the condition is met. */
export function cmpxchg_u(offset: usize, expected: i64, replacement: i64, immOffset?: usize): i64;
}
/** Atomic 64-bit integer read-modify-write operations on 16-bit values. */
export namespace rmw16 {
/** Atomically adds a 16-bit unsigned integer value in memory. */
export function add_u(offset: usize, value: i64, immOffset?: usize): i64;
/** Atomically subtracts a 16-bit unsigned integer value in memory. */
export function sub_u(offset: usize, value: i64, immOffset?: usize): i64;
/** Atomically performs a bitwise AND operation on a 16-bit unsigned integer value in memory. */
export function and_u(offset: usize, value: i64, immOffset?: usize): i64;
/** Atomically performs a bitwise OR operation on a 16-bit unsigned integer value in memory. */
export function or_u(offset: usize, value: i64, immOffset?: usize): i64;
/** Atomically performs a bitwise XOR operation on a 16-bit unsigned integer value in memory. */
export function xor_u(offset: usize, value: i64, immOffset?: usize): i64;
/** Atomically exchanges a 16-bit unsigned integer value in memory. */
export function xchg_u(offset: usize, value: i64, immOffset?: usize): i64;
/** Atomically compares and exchanges a 16-bit unsigned integer value in memory if the condition is met. */
export function cmpxchg_u(offset: usize, expected: i64, replacement: i64, immOffset?: usize): i64;
}
/** Atomic 64-bit integer read-modify-write operations on 32-bit values. */
export namespace rmw32 {
/** Atomically adds a 32-bit unsigned integer value in memory. */
export function add_u(offset: usize, value: i64, immOffset?: usize): i64;
/** Atomically subtracts a 32-bit unsigned integer value in memory. */
export function sub_u(offset: usize, value: i64, immOffset?: usize): i64;
/** Atomically performs a bitwise AND operation on a 32-bit unsigned integer value in memory. */
export function and_u(offset: usize, value: i64, immOffset?: usize): i64;
/** Atomically performs a bitwise OR operation on a 32-bit unsigned integer value in memory. */
export function or_u(offset: usize, value: i64, immOffset?: usize): i64;
/** Atomically performs a bitwise XOR operation on a 32-bit unsigned integer value in memory. */
export function xor_u(offset: usize, value: i64, immOffset?: usize): i64;
/** Atomically exchanges a 32-bit unsigned integer value in memory. */
export function xchg_u(offset: usize, value: i64, immOffset?: usize): i64;
/** Atomically compares and exchanges a 32-bit unsigned integer value in memory if the condition is met. */
export function cmpxchg_u(offset: usize, expected: i64, replacement: i64, immOffset?: usize): i64;
}
/** Atomic 64-bit integer read-modify-write operations. */
export namespace rmw {
/** Atomically adds a 64-bit integer value in memory. */
export function add(offset: usize, value: i64, immOffset?: usize): i64;
/** Atomically subtracts a 64-bit integer value in memory. */
export function sub(offset: usize, value: i64, immOffset?: usize): i64;
/** Atomically performs a bitwise AND operation on a 64-bit integer value in memory. */
export function and(offset: usize, value: i64, immOffset?: usize): i64;
/** Atomically performs a bitwise OR operation on a 64-bit integer value in memory. */
export function or(offset: usize, value: i64, immOffset?: usize): i64;
/** Atomically performs a bitwise XOR operation on a 64-bit integer value in memory. */
export function xor(offset: usize, value: i64, immOffset?: usize): i64;
/** Atomically exchanges a 64-bit integer value in memory. */
export function xchg(offset: usize, value: i64, immOffset?: usize): i64;
/** Atomically compares and exchanges a 64-bit integer value in memory if the condition is met. */
export function cmpxchg(offset: usize, expected: i64, replacement: i64, immOffset?: usize): i64;
}
}
}
/** Converts any other numeric value to a 32-bit (in WASM32) respectivel 64-bit (in WASM64) signed integer. */
declare var isize: typeof i32 | typeof i64;
/** Converts any other numeric value to an 8-bit unsigned integer. */
declare function u8(value: any): i8;
declare namespace u8 {
/** Smallest representable value. */
export const MIN_VALUE: u8;
/** Largest representable value. */
export const MAX_VALUE: u8;
}
/** Converts any other numeric value to a 16-bit unsigned integer. */
declare function u16(value: any): i8;
declare namespace u16 {
/** Smallest representable value. */
export const MIN_VALUE: u16;
/** Largest representable value. */
export const MAX_VALUE: u16;
}
/** Converts any other numeric value to a 32-bit unsigned integer. */
declare function u32(value: any): i32;
declare namespace u32 {
/** Smallest representable value. */
export const MIN_VALUE: u32;
/** Largest representable value. */
export const MAX_VALUE: u32;
}
/** Converts any other numeric value to a 64-bit unsigned integer. */
declare function u64(value: any): i64;
declare namespace u64 {
/** Smallest representable value. */
export const MIN_VALUE: u64;
/** Largest representable value. */
export const MAX_VALUE: u64;
}
/** Converts any other numeric value to a 32-bit (in WASM32) respectivel 64-bit (in WASM64) unsigned integer. */
declare var usize: typeof u32 | typeof u64;
/** Converts any other numeric value to a 1-bit unsigned integer. */
declare function bool(value: any): bool;
declare namespace bool {
/** Smallest representable value. */
export const MIN_VALUE: bool;
/** Largest representable value. */
export const MAX_VALUE: bool;
}
/** Converts any other numeric value to a 32-bit float. */
declare function f32(value: any): f32;
declare namespace f32 {
/** Smallest representable value. */
export const MIN_VALUE: f32;
/** Largest representable value. */
export const MAX_VALUE: f32;
/** Smallest normalized positive value. */
export const MIN_POSITIVE_VALUE: f32;
/** Smallest safely representable integer value. */
export const MIN_SAFE_INTEGER: f32;
/** Largest safely representable integer value. */
export const MAX_SAFE_INTEGER: f32;
/** Difference between 1 and the smallest representable value greater than 1. */
export const EPSILON: f32;
/** Loads a 32-bit float from memory. */
export function load(offset: usize, immOffset?: usize, immAlign?: usize): f32;
/** Stores a 32-bit float to memory. */
export function store(offset: usize, value: f32, immOffset?: usize, immAlign?: usize): void;
}
/** Converts any other numeric value to a 64-bit float. */
declare function f64(value: any): f64;
declare namespace f64 {
/** Smallest representable value. */
export const MIN_VALUE: f64;
/** Largest representable value. */
export const MAX_VALUE: f64;
/** Smallest normalized positive value. */
export const MIN_POSITIVE_VALUE: f64;
/** Smallest safely representable integer value. */
export const MIN_SAFE_INTEGER: f64;
/** Largest safely representable integer value. */
export const MAX_SAFE_INTEGER: f64;
/** Difference between 1 and the smallest representable value greater than 1. */
export const EPSILON: f64;
/** Loads a 64-bit float from memory. */
export function load(offset: usize, immOffset?: usize, immAlign?: usize): f64;
/** Stores a 64-bit float to memory. */
export function store(offset: usize, value: f64, immOffset?: usize, immAlign?: usize): void;
}
/** Initializes a 128-bit vector from sixteen 8-bit integer values. Arguments must be compile-time constants. */
declare function v128(a: i8, b: i8, c: i8, d: i8, e: i8, f: i8, g: i8, h: i8, i: i8, j: i8, k: i8, l: i8, m: i8, n: i8, o: i8, p: i8): v128;
declare namespace v128 {
/** Creates a 128-bit vector with identical lanes. */
export function splat<T>(x: T): v128;
/** Extracts one lane from a 128-bit vector as a scalar. */
export function extract_lane<T>(x: v128, idx: u8): T;
/** Replaces one lane in a 128-bit vector. */
export function replace_lane<T>(x: v128, idx: u8, value: T): v128;
/** Selects lanes from either 128-bit vector according to the specified lane indexes. */
export function shuffle<T>(a: v128, b: v128, ...lanes: u8[]): v128;
/** Loads a 128-bit vector from memory. */
export function load(offset: usize, immOffset?: usize, immAlign?: usize): v128;
/** Stores a 128-bit vector to memory. */
export function store(offset: usize, value: v128, immOffset?: usize, immAlign?: usize): void;
/** Adds each lane of two 128-bit vectors. */
export function add<T>(a: v128, b: v128): v128;
/** Subtracts each lane of two 128-bit vectors. */
export function sub<T>(a: v128, b: v128): v128;
/** Multiplies each lane of two 128-bit vectors. */
export function mul<T>(a: v128, b: v128): v128; // except i64
/** Divides each lane of two 128-bit vectors. */
export function div<T = f32 | f64>(a: v128, b: v128): v128;
/** Negates each lane of a 128-bit vector. */
export function neg<T>(a: v128): v128;
/** Adds each lane of two 128-bit vectors using saturation. */
export function add_saturate<T>(a: v128, b: v128): v128;
/** Subtracts each lane of two 128-bit vectors using saturation. */
export function sub_saturate<T>(a: v128, b: v128): v128;
/** Performs a bitwise left shift on each lane of a 128-bit vector by a scalar. */
export function shl<T>(a: v128, b: i32): v128;
/** Performs a bitwise right shift on each lane of a 128-bit vector by a scalar. */
export function shr<T>(a: v128, b: i32): v128;
/** Performs the bitwise AND operation on each lane of two 128-bit vectors. */
export function and(a: v128, b: v128): v128;
/** Performs the bitwise OR operation on each lane of two 128-bit vectors. */
export function or(a: v128, b: v128): v128;
/** Performs the bitwise XOR operation on each lane of two 128-bit vectors. */
export function xor(a: v128, b: v128): v128;
/** Performs the bitwise NOT operation on each lane of a 128-bit vector. */
export function not(a: v128): v128;
/** Selects bits of either 128-bit vector according to the specified mask. */
export function bitselect(v1: v128, v2: v128, mask: v128): v128;
/** Reduces a 128-bit vector to a scalar indicating whether any lane is considered `true`. */
export function any_true<T>(a: v128): bool;
/** Reduces a 128-bit vector to a scalar indicating whether all lanes are considered `true`. */
export function all_true<T>(a: v128): bool;
/** Computes the minimum of each lane of two 128-bit vectors. */
export function min<T = f32 | f64>(a: v128, b: v128): v128;
/** Computes the maximum of each lane of two 128-bit vectors. */
export function max<T = f32 | f64>(a: v128, b: v128): v128;
/** Computes the absolute value of each lane of a 128-bit vector. */
export function abs<T = f32 | f64>(a: v128): v128;
/** Computes the square root of each lane of a 128-bit vector. */
export function sqrt<T = f32 | f64>(a: v128): v128;
/** Computes which lanes of two 128-bit vectors are equal. */
export function eq<T>(a: v128, b: v128): v128;
/** Computes which lanes of two 128-bit vectors are not equal. */
export function ne<T>(a: v128, b: v128): v128;
/** Computes which lanes of the first 128-bit vector are less than those of the second. */
export function lt<T>(a: v128, b: v128): v128;
/** Computes which lanes of the first 128-bit vector are less than or equal those of the second. */
export function le<T>(a: v128, b: v128): v128;
/** Computes which lanes of the first 128-bit vector are greater than those of the second. */
export function gt<T>(a: v128, b: v128): v128;
/** Computes which lanes of the first 128-bit vector are greater than or equal those of the second. */
export function ge<T>(a: v128, b: v128): v128;
/** Converts each lane of a 128-bit vector from integer to floating point. */
export function convert<TFrom = i32 | u32 | i64 | u64>(a: v128): v128;
/** Truncates each lane of a 128-bit vector from floating point to integer with saturation. */
export function trunc<TTo = i32 | u32 | i64 | u64>(a: v128): v128;
}
/** Initializes a 128-bit vector from sixteen 8-bit integer values. Arguments must be compile-time constants. */
declare function i8x16(a: i8, b: i8, c: i8, d: i8, e: i8, f: i8, g: i8, h: i8, i: i8, j: i8, k: i8, l: i8, m: i8, n: i8, o: i8, p: i8): v128;
declare namespace i8x16 {
/** Creates a vector with sixteen identical 8-bit integer lanes. */
export function splat(x: i8): v128;
/** Extracts one 8-bit integer lane from a 128-bit vector as a signed scalar. */
export function extract_lane_s(x: v128, idx: u8): i8;
/** Extracts one 8-bit integer lane from a 128-bit vector as an unsigned scalar. */
export function extract_lane_u(x: v128, idx: u8): u8;
/** Replaces one 8-bit integer lane in a 128-bit vector. */
export function replace_lane(x: v128, idx: u8, value: i8): v128;
/** Adds each 8-bit integer lane of two 128-bit vectors. */
export function add(a: v128, b: v128): v128;
/** Subtracts each 8-bit integer lane of two 128-bit vectors. */
export function sub(a: v128, b: v128): v128;
/** Multiplies each 8-bit integer lane of two 128-bit vectors. */
export function mul(a: v128, b: v128): v128;
/** Negates each 8-bit integer lane of a 128-bit vector. */
export function neg(a: v128): v128;
/** Adds each 8-bit integer lane of two 128-bit vectors using signed saturation. */
export function add_saturate_s(a: v128, b: v128): v128;
/** Adds each 8-bit integer lane of two 128-bit vectors using unsigned saturation. */
export function add_saturate_u(a: v128, b: v128): v128;
/** Subtracts each 8-bit integer lane of two 128-bit vectors using signed saturation. */
export function sub_saturate_s(a: v128, b: v128): v128;
/** Subtracts each 8-bit integer lane of two 128-bit vectors using unsigned saturation. */
export function sub_saturate_u(a: v128, b: v128): v128;
/** Performs a bitwise left shift on each 8-bit integer lane of a 128-bit vector by a scalar. */
export function shl(a: v128, b: i32): v128;
/** Performs a bitwise arithmetic right shift on each 8-bit integer lane of a 128-bit vector by a scalar. */
export function shr_s(a: v128, b: i32): v128;
/** Performs a bitwise logical right shift on each 8-bit integer lane of a 128-bit vector by a scalar. */
export function shr_u(a: v128, b: i32): v128;
/** Reduces a 128-bit vector to a scalar indicating whether any 8-bit integer lane is considered `true`. */
export function any_true(a: v128): bool;
/** Reduces a 128-bit vector to a scalar indicating whether all 8-bit integer lanes are considered `true`. */
export function all_true(a: v128): bool;
/** Computes which 8-bit integer lanes of two 128-bit vectors are equal. */
export function eq(a: v128, b: v128): v128;
/** Computes which 8-bit integer lanes of two 128-bit vectors are not equal. */
export function ne(a: v128, b: v128): v128;
/** Computes which 8-bit signed integer lanes of the first 128-bit vector are less than those of the second. */
export function lt_s(a: v128, b: v128): v128;
/** Computes which 8-bit unsigned integer lanes of the first 128-bit vector are less than those of the second. */
export function lt_u(a: v128, b: v128): v128;
/** Computes which 8-bit signed integer lanes of the first 128-bit vector are less than or equal those of the second. */
export function le_s(a: v128, b: v128): v128;
/** Computes which 8-bit unsigned integer lanes of the first 128-bit vector are less than or equal those of the second. */
export function le_u(a: v128, b: v128): v128;
/** Computes which 8-bit signed integer lanes of the first 128-bit vector are greater than those of the second. */
export function gt_s(a: v128, b: v128): v128;
/** Computes which 8-bit unsigned integer lanes of the first 128-bit vector are greater than those of the second. */
export function gt_u(a: v128, b: v128): v128;
/** Computes which 8-bit signed integer lanes of the first 128-bit vector are greater than or equal those of the second. */
export function ge_s(a: v128, b: v128): v128;
/** Computes which 8-bit unsigned integer lanes of the first 128-bit vector are greater than or equal those of the second. */
export function ge_u(a: v128, b: v128): v128;
}
/** Initializes a 128-bit vector from eight 16-bit integer values. Arguments must be compile-time constants. */
declare function i16x8(a: i16, b: i16, c: i16, d: i16, e: i16, f: i16, g: i16, h: i16): v128;
declare namespace i16x8 {
/** Creates a vector with eight identical 16-bit integer lanes. */
export function splat(x: i16): v128;
/** Extracts one 16-bit integer lane from a 128-bit vector as a signed scalar. */
export function extract_lane_s(x: v128, idx: u8): i16;
/** Extracts one 16-bit integer lane from a 128-bit vector as an unsigned scalar. */
export function extract_lane_u(x: v128, idx: u8): u16;
/** Replaces one 16-bit integer lane in a 128-bit vector. */
export function replace_lane(x: v128, idx: u8, value: i16): v128;
/** Adds each 16-bit integer lane of two 128-bit vectors. */
export function add(a: v128, b: v128): v128;
/** Subtracts each 16-bit integer lane of two 128-bit vectors. */
export function sub(a: v128, b: v128): v128;
/** Multiplies each 16-bit integer lane of two 128-bit vectors. */
export function mul(a: v128, b: v128): v128;
/** Negates each 16-bit integer lane of a 128-bit vector. */
export function neg(a: v128): v128;
/** Adds each 16-bit integer lane of two 128-bit vectors using signed saturation. */
export function add_saturate_s(a: v128, b: v128): v128;
/** Adds each 16-bit integer lane of two 128-bit vectors using unsigned saturation. */
export function add_saturate_u(a: v128, b: v128): v128;
/** Subtracts each 16-bit integer lane of two 128-bit vectors using signed saturation. */
export function sub_saturate_s(a: v128, b: v128): v128;
/** Subtracts each 16-bit integer lane of two 128-bit vectors using unsigned saturation. */
export function sub_saturate_u(a: v128, b: v128): v128;
/** Performs a bitwise left shift on each 16-bit integer lane of a 128-bit vector by a scalar. */
export function shl(a: v128, b: i32): v128;
/** Performs a bitwise arithmetic right shift each 16-bit integer lane of a 128-bit vector by a scalar. */
export function shr_s(a: v128, b: i32): v128;
/** Performs a bitwise logical right shift on each 16-bit integer lane of a 128-bit vector by a scalar. */
export function shr_u(a: v128, b: i32): v128;
/** Reduces a 128-bit vector to a scalar indicating whether any 16-bit integer lane is considered `true`. */
export function any_true(a: v128): bool;
/** Reduces a 128-bit vector to a scalar indicating whether all 16-bit integer lanes are considered `true`. */
export function all_true(a: v128): bool;
/** Computes which 16-bit integer lanes of two 128-bit vectors are equal. */
export function eq(a: v128, b: v128): v128;
/** Computes which 16-bit integer lanes of two 128-bit vectors are not equal. */
export function ne(a: v128, b: v128): v128;
/** Computes which 16-bit signed integer lanes of the first 128-bit vector are less than those of the second. */
export function lt_s(a: v128, b: v128): v128;
/** Computes which 16-bit unsigned integer lanes of the first 128-bit vector are less than those of the second. */
export function lt_u(a: v128, b: v128): v128;
/** Computes which 16-bit signed integer lanes of the first 128-bit vector are less than or equal those of the second. */
export function le_s(a: v128, b: v128): v128;
/** Computes which 16-bit unsigned integer lanes of the first 128-bit vector are less than or equal those of the second. */
export function le_u(a: v128, b: v128): v128;
/** Computes which 16-bit signed integer lanes of the first 128-bit vector are greater than those of the second. */
export function gt_s(a: v128, b: v128): v128;
/** Computes which 16-bit unsigned integer lanes of the first 128-bit vector are greater than those of the second. */
export function gt_u(a: v128, b: v128): v128;
/** Computes which 16-bit signed integer lanes of the first 128-bit vector are greater than or equal those of the second. */
export function ge_s(a: v128, b: v128): v128;
/** Computes which 16-bit unsigned integer lanes of the first 128-bit vector are greater than or equal those of the second. */
export function ge_u(a: v128, b: v128): v128;
}
/** Initializes a 128-bit vector from four 32-bit integer values. Arguments must be compile-time constants. */
declare function i32x4(a: i32, b: i32, c: i32, d: i32): v128;
declare namespace i32x4 {
/** Creates a 128-bit vector with four identical 32-bit integer lanes. */
export function splat(x: i32): v128;
/** Extracts one 32-bit integer lane from a 128-bit vector as a scalar. */
export function extract_lane(x: v128, idx: u8): i32;
/** Replaces one 32-bit integer lane in a 128-bit vector. */
export function replace_lane(x: v128, idx: u8, value: i32): v128;
/** Adds each 32-bit integer lane of two 128-bit vectors. */
export function add(a: v128, b: v128): v128;
/** Subtracts each 32-bit integer lane of two 128-bit vectors. */
export function sub(a: v128, b: v128): v128;
/** Multiplies each 32-bit integer lane of two 128-bit vectors. */
export function mul(a: v128, b: v128): v128;
/** Negates each 32-bit integer lane of a 128-bit vector. */
export function neg(a: v128): v128;
/** Performs a bitwise left shift on each 32-bit integer lane of a 128-bit vector by a scalar. */
export function shl(a: v128, b: i32): v128;
/** Performs a bitwise arithmetic right shift on each 32-bit integer lane of a 128-bit vector by a scalar. */
export function shr_s(a: v128, b: i32): v128;
/** Performs a bitwise logical right shift on each 32-bit integer lane of a 128-bit vector by a scalar. */
export function shr_u(a: v128, b: i32): v128;
/** Reduces a 128-bit vector to a scalar indicating whether any 32-bit integer lane is considered `true`. */
export function any_true(a: v128): bool;
/** Reduces a 128-bit vector to a scalar indicating whether all 32-bit integer lanes are considered `true`. */
export function all_true(a: v128): bool;
/** Computes which 32-bit integer lanes of two 128-bit vectors are equal. */
export function eq(a: v128, b: v128): v128;
/** Computes which 32-bit integer lanes of two 128-bit vectors are not equal. */
export function ne(a: v128, b: v128): v128;
/** Computes which 32-bit signed integer lanes of the first 128-bit vector are less than those of the second. */
export function lt_s(a: v128, b: v128): v128;
/** Computes which 32-bit unsigned integer lanes of the first 128-bit vector are less than those of the second. */
export function lt_u(a: v128, b: v128): v128;
/** Computes which 32-bit signed integer lanes of the first 128-bit vector are less than or equal those of the second. */
export function le_s(a: v128, b: v128): v128;
/** Computes which 32-bit unsigned integer lanes of the first 128-bit vector are less than or equal those of the second. */
export function le_u(a: v128, b: v128): v128;
/** Computes which 32-bit signed integer lanes of the first 128-bit vector are greater than those of the second. */
export function gt_s(a: v128, b: v128): v128;
/** Computes which 32-bit unsigned integer lanes of the first 128-bit vector are greater than those of the second. */
export function gt_u(a: v128, b: v128): v128;
/** Computes which 32-bit signed integer lanes of the first 128-bit vector are greater than or equal those of the second. */
export function ge_s(a: v128, b: v128): v128;
/** Computes which 32-bit unsigned integer lanes of the first 128-bit vector are greater than or equal those of the second. */
export function ge_u(a: v128, b: v128): v128;
/** Truncates each 32-bit float lane of a 128-bit vector to a signed integer with saturation. */
export function trunc_s_f32x4_sat(a: v128): v128;
/** Truncates each 32-bit float lane of a 128-bit vector to an unsigned integer with saturation. */
export function trunc_u_f32x4_sat(a: v128): v128;
}
/** Initializes a 128-bit vector from two 64-bit integer values. Arguments must be compile-time constants. */
declare function i64x2(a: i64, b: i64): v128;
declare namespace i64x2 {
/** Creates a 128-bit vector with two identical 64-bit integer lanes. */
export function splat(x: i64): v128;
/** Extracts one 64-bit integer lane from a 128-bit vector as a scalar. */
export function extract_lane(x: v128, idx: u8): i64;
/** Replaces one 64-bit integer lane in a 128-bit vector. */
export function replace_lane(x: v128, idx: u8, value: i64): v128;
/** Adds each 64-bit integer lane of two 128-bit vectors. */
export function add(a: v128, b: v128): v128;
/** Subtracts each 64-bit integer lane of two 128-bit vectors. */
export function sub(a: v128, b: v128): v128;
/** Multiplies each 64-bit integer lane of two 128-bit vectors. */
export function mul(a: v128, b: v128): v128;
/** Negates each 64-bit integer lane of a 128-bit vector. */
export function neg(a: v128): v128;
/** Performs a bitwise left shift on each 64-bit integer lane of a 128-bit vector by a scalar. */
export function shl(a: v128, b: i32): v128;
/** Performs a bitwise arithmetic right shift on each 64-bit integer lane of a 128-bit vector by a scalar. */
export function shr_s(a: v128, b: i32): v128;
/** Performs a bitwise logical right shift on each 64-bit integer lane of a 128-bit vector by a scalar. */
export function shr_u(a: v128, b: i32): v128;
/** Reduces a 128-bit vector to a scalar indicating whether any 64-bit integer lane is considered `true`. */
export function any_true(a: v128): bool;
/** Reduces a 128-bit vector to a scalar indicating whether all 64-bit integer lanes are considered `true`. */
export function all_true(a: v128): bool;
/** Truncates each 64-bit float lane of a 128-bit vector to a signed integer with saturation. */
export function trunc_s_f64x2_sat(a: v128): v128;
/** Truncates each 64-bit float lane of a 128-bit vector to an unsigned integer with saturation. */
export function trunc_u_f64x2_sat(a: v128): v128;
}
/** Initializes a 128-bit vector from four 32-bit float values. Arguments must be compile-time constants. */
declare function f32x4(a: f32, b: f32, c: f32, d: f32): v128;
declare namespace f32x4 {
/** Creates a 128-bit vector with four identical 32-bit float lanes. */
export function splat(x: f32): v128;
/** Extracts one 32-bit float lane from a 128-bit vector as a scalar. */
export function extract_lane(x: v128, idx: u8): f32;
/** Replaces one 32-bit float lane in a 128-bit vector. */
export function replace_lane(x: v128, idx: u8, value: f32): v128;
/** Adds each 32-bit float lane of two 128-bit vectors. */
export function add(a: v128, b: v128): v128;
/** Subtracts each 32-bit float lane of two 128-bit vectors. */
export function sub(a: v128, b: v128): v128;
/** Multiplies each 32-bit float lane of two 128-bit vectors. */
export function mul(a: v128, b: v128): v128;
/** Divides each 32-bit float lane of two 128-bit vectors. */
export function div(a: v128, b: v128): v128;
/** Negates each 32-bit float lane of a 128-bit vector. */
export function neg(a: v128): v128;
/** Computes the minimum of each 32-bit float lane of two 128-bit vectors. */
export function min(a: v128, b: v128): v128;
/** Computes the maximum of each 32-bit float lane of two 128-bit vectors. */
export function max(a: v128, b: v128): v128;
/** Computes the absolute value of each 32-bit float lane of a 128-bit vector. */
export function abs(a: v128): v128;
/** Computes the square root of each 32-bit float lane of a 128-bit vector. */
export function sqrt(a: v128): v128;
/** Computes which 32-bit float lanes of two 128-bit vectors are equal. */
export function eq(a: v128, b: v128): v128;
/** Computes which 32-bit float lanes of two 128-bit vectors are not equal. */
export function ne(a: v128, b: v128): v128;
/** Computes which 32-bit float lanes of the first 128-bit vector are less than those of the second. */
export function lt(a: v128, b: v128): v128;
/** Computes which 32-bit float lanes of the first 128-bit vector are less than or equal those of the second. */
export function le(a: v128, b: v128): v128;
/** Computes which 32-bit float lanes of the first 128-bit vector are greater than those of the second. */
export function gt(a: v128, b: v128): v128;
/** Computes which 32-bit float lanes of the first 128-bit vector are greater than or equal those of the second. */
export function ge(a: v128, b: v128): v128;
/** Converts each 32-bit signed integer lane of a 128-bit vector to floating point. */
export function convert_s_i32x4(a: v128): v128;
/** Converts each 32-bit unsigned integer lane of a 128-bit vector to floating point. */
export function convert_u_i32x4(a: v128): v128;
}
/** Initializes a 128-bit vector from two 64-bit float values. Arguments must be compile-time constants. */
declare function f64x2(a: f64, b: f64): v128;
declare namespace f64x2 {
/** Creates a 128-bit vector with two identical 64-bit float lanes. */
export function splat(x: f64): v128;
/** Extracts one 64-bit float lane from a 128-bit vector as a scalar. */
export function extract_lane(x: v128, idx: u8): f64;
/** Replaces one 64-bit float lane in a 128-bit vector. */
export function replace_lane(x: v128, idx: u8, value: f64): v128;
/** Adds each 64-bit float lane of two 128-bit vectors. */
export function add(a: v128, b: v128): v128;
/** Subtracts each 64-bit float lane of two 128-bit vectors. */
export function sub(a: v128, b: v128): v128;
/** Multiplies each 64-bit float lane of two 128-bit vectors. */
export function mul(a: v128, b: v128): v128;
/** Divides each 64-bit float lane of two 128-bit vectors. */
export function div(a: v128, b: v128): v128;
/** Negates each 64-bit float lane of a 128-bit vector. */
export function neg(a: v128): v128;
/** Computes the minimum of each 64-bit float lane of two 128-bit vectors. */
export function min(a: v128, b: v128): v128;
/** Computes the maximum of each 64-bit float lane of two 128-bit vectors. */
export function max(a: v128, b: v128): v128;
/** Computes the absolute value of each 64-bit float lane of a 128-bit vector. */
export function abs(a: v128): v128;
/** Computes the square root of each 64-bit float lane of a 128-bit vector. */
export function sqrt(a: v128): v128;
/** Computes which 64-bit float lanes of two 128-bit vectors are equal. */
export function eq(a: v128, b: v128): v128;
/** Computes which 64-bit float lanes of two 128-bit vectors are not equal. */
export function ne(a: v128, b: v128): v128;
/** Computes which 64-bit float lanes of the first 128-bit vector are less than those of the second. */
export function lt(a: v128, b: v128): v128;
/** Computes which 64-bit float lanes of the first 128-bit vector are less than or equal those of the second. */
export function le(a: v128, b: v128): v128;
/** Computes which 64-bit float lanes of the first 128-bit vector are greater than those of the second. */
export function gt(a: v128, b: v128): v128;
/** Computes which 64-bit float lanes of the first 128-bit vector are greater than or equal those of the second. */
export function ge(a: v128, b: v128): v128;
/** Converts each 64-bit signed integer lane of a 128-bit vector to floating point. */
export function convert_s_i64x2(a: v128): v128;
/** Converts each 64-bit unsigned integer lane of a 128-bit vector to floating point. */
export function convert_u_i64x2(a: v128): v128;
}
declare namespace v8x16 {
/** Selects 8-bit lanes from either 128-bit vector according to the specified lane indexes. */
export function shuffle(a: v128, b: v128, l0: u8, l1: u8, l2: u8, l3: u8, l4: u8, l5: u8, l6: u8, l7: u8, l8: u8, l9: u8, l10: u8, l11: u8, l12: u8, l13: u8, l14: u8, l15: u8): v128;
}
/** Macro type evaluating to the underlying native WebAssembly type. */
declare type native<T> = T;
/** Special type evaluating the indexed access index type. */
declare type indexof<T extends unknown[]> = keyof T;
/** Special type evaluating the indexed access value type. */
declare type valueof<T extends unknown[]> = T[0];
/** Pseudo-class representing the backing class of integer types. */
declare class _Integer {
/** Smallest representable value. */
static readonly MIN_VALUE: number;
/** Largest representable value. */
static readonly MAX_VALUE: number;
/** Converts a string to an integer of this type. */
static parseInt(value: string, radix?: number): number;
/** Converts this integer to a string. */
toString(): string;
}
/** Pseudo-class representing the backing class of floating-point types. */
declare class _Float {
/** Difference between 1 and the smallest representable value greater than 1. */
static readonly EPSILON: f32 | f64;
/** Smallest representable value. */
static readonly MIN_VALUE: f32 | f64;
/** Largest representable value. */
static readonly MAX_VALUE: f32 | f64;
/** Smallest safely representable integer value. */
static readonly MIN_SAFE_INTEGER: f32 | f64;
/** Largest safely representable integer value. */
static readonly MAX_SAFE_INTEGER: f32 | f64;
/** Value representing positive infinity. */
static readonly POSITIVE_INFINITY: f32 | f64;
/** Value representing negative infinity. */
static readonly NEGATIVE_INFINITY: f32 | f64;
/** Value representing 'not a number'. */
static readonly NaN: f32 | f64;
/** Returns a boolean value that indicates whether a value is the reserved value NaN (not a number). */
static isNaN(value: f32 | f64): bool;
/** Returns true if passed value is finite. */
static isFinite(value: f32 | f64): bool;
/** Returns true if the value passed is a safe integer. */
static isSafeInteger(value: f32 | f64): bool;
/** Returns true if the value passed is an integer, false otherwise. */
static isInteger(value: f32 | f64): bool;
/** Converts a string to an integer. */
static parseInt(value: string, radix?: i32): f32 | f64;
/** Converts a string to a floating-point number. */
static parseFloat(value: string): f32 | f64;
/** Converts this floating-point number to a string. */
toString(this: f64): string;
}
/** Backing class of signed 8-bit integers. */
declare const I8: typeof _Integer;
/** Backing class of signed 16-bit integers. */
declare const I16: typeof _Integer;
/** Backing class of signed 32-bit integers. */
declare const I32: typeof _Integer;
/** Backing class of signed 64-bit integers. */
declare const I64: typeof _Integer;
/** Backing class of signed size integers. */
declare const Isize: typeof _Integer;
/** Backing class of unsigned 8-bit integers. */
declare const U8: typeof _Integer;
/** Backing class of unsigned 16-bit integers. */
declare const U16: typeof _Integer;
/** Backing class of unsigned 32-bit integers. */
declare const U32: typeof _Integer;
/** Backing class of unsigned 64-bit integers. */
declare const U64: typeof _Integer;
/** Backing class of unsigned size integers. */
declare const Usize: typeof _Integer;
/** Backing class of 32-bit floating-point values. */
declare const F32: typeof _Float;
/** Backing class of 64-bit floating-point values. */
declare const F64: typeof _Float;
// User-defined diagnostic macros
/** Emits a user-defined diagnostic error when encountered. */
declare function ERROR(message?: any): void;
/** Emits a user-defined diagnostic warning when encountered. */
declare function WARNING(message?: any): void;
/** Emits a user-defined diagnostic info when encountered. */
declare function INFO(message?: any): void;
// Polyfills
/** Performs the sign-agnostic reverse bytes **/
declare function bswap<T = i8 | u8 | i16 | u16 | i32 | u32 | i64 | u64 | isize | usize>(value: T): T;
/** Performs the sign-agnostic reverse bytes only for last 16-bit **/
declare function bswap16<T = i8 | u8 | i16 | u16 | i32 | u32>(value: T): T;
// Standard library
/** Memory operations. */
declare namespace memory {
/** Whether the memory managed interface is implemented. */
export const implemented: bool;
/** Returns the current memory size in units of pages. One page is 64kb. */
export function size(): i32;
/** Grows linear memory by a given unsigned delta of pages. One page is 64kb. Returns the previous memory size in units of pages or `-1` on failure. */
export function grow(value: i32): i32;
/** Sets n bytes beginning at the specified destination in memory to the specified byte value. */
export function fill(dst: usize, value: u8, count: usize): void;
/** Copies n bytes from the specified source to the specified destination in memory. These regions may overlap. */
export function copy(dst: usize, src: usize, n: usize): void;
/** Repeats `src` of length `srcLength` `count` times at `dst`. */
export function repeat(dst: usize, src: usize, srcLength: usize, count: usize): void;
/** Copies elements from a passive element segment to a table. */
export function init(segmentIndex: u32, srcOffset: usize, dstOffset: usize, n: usize): void;
/** Prevents further use of a passive element segment. */
export function drop(segmentIndex: u32): void;
/** Compares two chunks of memory. Returns `0` if equal, otherwise the difference of the first differing bytes. */
export function compare(vl: usize, vr: usize, n: usize): i32;
}