You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1. If :math:`\externtype_1` and :math:`\externtype_2` are both of the form :math:`\ETFUNC~\functype_1` and :math:`\ETFUNC~\functype_2` respectively:
147
+
148
+
a. Return true if and only if :math:`\vdashexterntypematch\ETFUNC~\functype_1\matchesexterntype\ETFUNC~\functype_2`.
149
+
150
+
2. If :math:`\externtype_1` and :math:`\externtype_2` are both of the form :math:`\ETTABLE~\tabletype_1` and :math:`\ETTABLE~\tabletype_2` respectively:
151
+
152
+
a. Return true if and only if :math:`\vdashexterntypematch\ETTABLE~\tabletype_1\matchesexterntype\ETTABLE~\tabletype_2`.
153
+
154
+
3. If :math:`\externtype_1` and :math:`\externtype_2` are both of the form :math:`\ETMEM~\memtype_1` and :math:`\ETMEM~\memtype_2` respectively:
155
+
156
+
a. Return true if and only if :math:`\vdashexterntypematch\ETMEM~\memtype_1\matchesexterntype\ETMEM~\memtype_2`.
157
+
158
+
4. If :math:`\externtype_1` and :math:`\externtype_2` are both of the form :math:`\ETGLOBAL~\globaltype_1` and :math:`\ETGLOBAL~\globaltype_2` respectively:
159
+
160
+
a. Return true if and only if :math:`\vdashexterntypematch\ETGLOBAL~\globaltype_1\matchesexterntype\ETGLOBAL~\globaltype_2`.
This function encapsulates the external type matching relation defined in the :ref:`Import Subtyping <match>` of the validation section, where the :math:`\vdashexterntypematch\externtype_1\matchesexterntype\externtype_2` judgment establishes compatibility between external types. This allows for explicit checking of type compatibility when linking modules or validating imports against exports.
Copy file name to clipboardExpand all lines: proposals/esm-integration/EXAMPLES.md
+8-4Lines changed: 8 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -123,13 +123,17 @@ for (let index = 0; index < length; index++)
123
123
| table |`WebAssembly.Table` object |
124
124
| function | WebAssembly exported function |
125
125
126
+
Wasm bindings cannot be reassigned as it can in JS, so the exported value will not change in their object identity. But the value that it points to (e.g. `.value` in the case of `WebAssembly.Global`) can change.
127
+
126
128
1. JS module is parsed
127
129
1. wasm module is parsed
128
130
1. wasm module has a lexical environment created for its exports. All exports are initially in TDZ.
129
131
1. JS module is instantiated. Imports are bound to the same memory locations.
130
132
1. wasm module is instantiated evaluated. Functions are initialized. Memories and tables are initialized and filled with data/elem sections. Globals are initialized and initializer expressions are evaluated. The start function runs.
131
133
1. JS module is evaluated. All values are available.
132
134
135
+
The value of the export for `WebAssembly.Global` is provided directly on the JS namespace object, with mutable globals reflected as live bindings to JS.
136
+
133
137
#### Example
134
138
135
139
```js
@@ -177,7 +181,7 @@ Wasm exports can be imported as accurate, immutable bindings to other wasm modul
177
181
178
182
### wasm imports <- JS re-exports <- wasm exports
179
183
180
-
Any wasm exports that are re-exported via a JS module will be available to the other wasm module as accuratebindings. If the binding is a mutable global, then that binding will be a live export binding in JS reflecting changes to the Wasm global value. When imported from JS, the first and second Wasm modules will yield the same Wasm identities for the multiply exported Wasm objects.
184
+
Any wasm exports that are re-exported via a JS module will be available to the other wasm module as accurate, immutable bindings. The wasm export gets wrapped into a JS object (e.g. `WebAssembly.Global`) and then unwrapped to the wasm import in the importing wasm module. When imported from JS, the first and second Wasm modules will yield the same object identities for the multiply exported Wasm objects.
181
185
182
186
#### Example
183
187
@@ -213,7 +217,7 @@ export {memoryExport} from "./b.wasm";
213
217
214
218
1. JS module is parsed
215
219
1. wasm module is parsed
216
-
1. wasm module has a lexical environment created for its exports. All direct exports are initially in TDZ, indirect exports are available as they resolve.
220
+
1. wasm module has a lexical environment created for its exports. All exports are initially in TDZ.
217
221
1. JS module is instantiated. All imports (including functions) from the wasm module are memory locations holding undefined.
218
222
1. wasm module is instantiated and evaluated. Snapshots of imports are taken. Export bindings are initialized.
219
223
1. JS module is evaluated.
@@ -251,8 +255,8 @@ export function functionExport() {
251
255
1. wasm module is parsed
252
256
1. JS module is parsed
253
257
1. JS module is instantiated.
254
-
1. wasm module has a lexical environment created for its exports. All direct exports are initially in TDZ, indirect exports are available as they resolve.
255
-
1. JS module is evaluated. wasm exports in TDZ lead to a ReferenceError if used.
258
+
1. wasm module has a lexical environment created for its exports. All exports are initially in TDZ.
259
+
1. JS module is evaluated. wasm exports lead to a ReferenceError if used.
256
260
1. wasm module is instantiated and evaluated; wasm-exported bindings are updated to their appropriate JS API-exposed values.
0 commit comments