@@ -48,6 +48,12 @@ Instances are automatically populated with useful utility:
48
48
* ** U32** : ` Uint32Array ` <br />
49
49
A 32-bit unsigned integer view on the memory.
50
50
51
+ * ** I64** : ` BigInt64Array ` <br />
52
+ A 64-bit signed integer view on the memory<sup >1</sup >.
53
+
54
+ * ** U64** : ` BigUint64Array ` <br />
55
+ A 64-bit unsigned integer view on the memory<sup >1</sup >.
56
+
51
57
* ** F32** : ` Float32Array ` <br />
52
58
A 32-bit float view on the memory.
53
59
@@ -65,6 +71,8 @@ Instances are automatically populated with useful utility:
65
71
* ** getString** (ptr: ` number ` ): ` string ` <br />
66
72
Gets a string from the module's memory by its pointer.
67
73
74
+ <sup >1</sup > This feature has not yet landed in any VM as of this writing.
75
+
68
76
Examples
69
77
--------
70
78
@@ -82,13 +90,16 @@ const myModule = await loader.instantiateStreaming(fetch("myModule.wasm"), myImp
82
90
83
91
``` js
84
92
var ptrToInt8 = ... ;
85
- var value = myModule .U16 [ptrToInt8]; // alignment of log2(1)=0
93
+ var value = myModule .I8 [ptrToInt8]; // alignment of log2(1)=0
86
94
87
95
var ptrToInt16 = ... ;
88
- var value = myModule .U16 [ptrToInt16 >>> 1 ]; // alignment of log2(2)=1
96
+ var value = myModule .I16 [ptrToInt16 >>> 1 ]; // alignment of log2(2)=1
89
97
90
98
var ptrToInt32 = ... ;
91
- var value = myModule .U32 [ptrToInt32 >>> 2 ]; // alignment of log2(4)=2
99
+ var value = myModule .I32 [ptrToInt32 >>> 2 ]; // alignment of log2(4)=2
100
+
101
+ var ptrToInt64 = ... ;
102
+ var value = myModule .I64 [ptrToInt64 >>> 3 ]; // alignment of log2(8)=3
92
103
93
104
var ptrToFloat32 = ... ;
94
105
var value = myModule .F32 [ptrToFloat32 >>> 2 ]; // alignment of log2(4)=2
@@ -97,9 +108,10 @@ var ptrToFloat64 = ...;
97
108
var value = myModule .F64 [ptrToFloat64 >>> 3 ]; // alignment of log2(8)=3
98
109
99
110
// Likewise, for writing
100
- myModule .U16 [ptrToInt8] = newValue;
101
- myModule .U16 [ptrToInt16 >>> 1 ] = newValue;
102
- myModule .U32 [ptrToInt32 >>> 2 ] = newValue;
111
+ myModule .I8 [ptrToInt8] = newValue;
112
+ myModule .I16 [ptrToInt16 >>> 1 ] = newValue;
113
+ myModule .I32 [ptrToInt32 >>> 2 ] = newValue;
114
+ myModule .I64 [ptrToInt64 >>> 3 ] = newValue;
103
115
myModule .F32 [ptrToFloat32 >>> 2 ] = newValue;
104
116
myModule .F64 [ptrToFloat64 >>> 3 ] = newValue;
105
117
```
@@ -128,5 +140,3 @@ import MyModule from "myModule"; // pointing at the d.ts
128
140
129
141
const myModule = loader .instatiateBuffer <typeof MyModule >(fs .readFileSync (" myModule.wasm" ), myImports );
130
142
```
131
-
132
- ** Hint:** You can produce a ` .d.ts ` for your module with the ` -d ` option on the command line.
0 commit comments