53
53
### Component Definitions
54
54
55
55
At the top-level, a ` component ` is a sequence of definitions of various kinds:
56
- ```
56
+ ``` ebnf
57
57
component ::= (component <id>? <definition>*)
58
58
definition ::= core-prefix(<core:module>)
59
59
| core-prefix(<core:instance>)
@@ -130,7 +130,7 @@ then supplying a set of named *arguments* which satisfy all the named *imports*
130
130
of the selected module or component.
131
131
132
132
The syntax for defining a core module instance is:
133
- ```
133
+ ``` ebnf
134
134
core:instance ::= (instance <id>? <core:instancexpr>)
135
135
core:instanceexpr ::= (instantiate <core:moduleidx> <core:instantiatearg>*)
136
136
| <core:inlineexport>*
@@ -188,7 +188,7 @@ next section.
188
188
The syntax for defining component instances is symmetric to core module
189
189
instances, but with an expanded component-level definition of ` sort ` and
190
190
more restricted version of ` name ` :
191
- ```
191
+ ``` ebnf
192
192
instance ::= (instance <id>? <instanceexpr>)
193
193
instanceexpr ::= (instantiate <componentidx> <instantiatearg>*)
194
194
| <inlineexport>*
@@ -267,7 +267,7 @@ into the current component's index spaces. As represented in the AST below,
267
267
there are three kinds of "targets" for an alias: the ` export ` of a component
268
268
instance, the ` core export ` of a core module instance and a definition of an
269
269
` outer ` component (containing the current component):
270
- ```
270
+ ``` ebnf
271
271
alias ::= (alias <aliastarget> (<sort> <id>?))
272
272
aliastarget ::= export <instanceidx> <string>
273
273
| core export <core:instanceidx> <core:name>
@@ -299,7 +299,7 @@ inline:
299
299
300
300
For ` export ` aliases, the inline sugar extends the definition of ` sortidx `
301
301
and the various sort-specific indices:
302
- ```
302
+ ``` ebnf
303
303
sortidx ::= (<sort> <u32>) ;; as above
304
304
| <inlinealias>
305
305
Xidx ::= <u32> ;; as above
@@ -389,7 +389,7 @@ type and function definitions which are introduced in the next two sections.
389
389
390
390
The syntax for defining core types extends the existing core type definition
391
391
syntax, adding a ` module ` type constructor:
392
- ```
392
+ ``` ebnf
393
393
core:type ::= (type <id>? <core:deftype>) (GC proposal)
394
394
core:deftype ::= <core:functype> (WebAssembly 1.0)
395
395
| <core:structtype> (GC proposal)
@@ -429,7 +429,7 @@ this, module types start with an empty type index space that is populated by
429
429
` type ` declarators, so that, in the future, these ` type ` declarators can refer to
430
430
type imports local to the module type itself. For example, in the future, the
431
431
following module type would be expressible:
432
- ```
432
+ ``` wasm
433
433
(component $C
434
434
(core type $M (module
435
435
(import "" "T" (type $T))
@@ -477,7 +477,7 @@ but use a completely different set of value types. Unlike [`core:valtype`]
477
477
which is low-level and assumes a shared linear memory for communicating
478
478
compound values, component-level value types assume no shared memory and must
479
479
therefore be high-level, describing entire compound values.
480
- ```
480
+ ``` ebnf
481
481
type ::= (type <id>? <deftype>)
482
482
deftype ::= <defvaltype>
483
483
| <resourcetype>
@@ -1063,7 +1063,7 @@ two directions:
1063
1063
1064
1064
Canonical definitions specify one of these two wrapping directions, the function
1065
1065
to wrap and a list of configuration options:
1066
- ```
1066
+ ``` ebnf
1067
1067
canon ::= (canon lift core-prefix(<core:funcidx>) <canonopt>* bind-id(<externdesc>))
1068
1068
| (canon lower <funcidx> <canonopt>* (core func <id>?))
1069
1069
canonopt ::= string-encoding=utf8
@@ -1187,7 +1187,7 @@ adapt *existing* functions, there are also a set of canonical "built-ins" that
1187
1187
define core functions out of nothing that can be imported by core modules to
1188
1188
dynamically interact with Canonical ABI entities like resources (and, when
1189
1189
async is added to the proposal, [ tasks] [ Future and Stream Types ] ).
1190
- ```
1190
+ ``` ebnf
1191
1191
canon ::= ...
1192
1192
| (canon resource.new <typeidx> (core func <id>?))
1193
1193
| (canon resource.drop <typeidx> (core func <id>?))
@@ -1245,7 +1245,7 @@ Like modules, components can have start functions that are called during
1245
1245
instantiation. Unlike modules, components can call start functions at multiple
1246
1246
points during instantiation with each such call having parameters and results.
1247
1247
Thus, ` start ` definitions in components look like function calls:
1248
- ```
1248
+ ``` ebnf
1249
1249
start ::= (start <funcidx> (value <valueidx>)* (result (value <id>?))*)
1250
1250
```
1251
1251
The ` (value <valueidx>)* ` list specifies the arguments passed to ` funcidx ` by
@@ -1257,7 +1257,7 @@ validated to match the signature of `funcidx`.
1257
1257
1258
1258
As with all definition sorts, values may be imported and exported by
1259
1259
components. As an example value import:
1260
- ```
1260
+ ``` wasm
1261
1261
(import "env" (value $env (record (field "locale" (option string)))))
1262
1262
```
1263
1263
As this example suggests, value imports can serve as generalized [ environment
@@ -1302,7 +1302,7 @@ WebAssembly, as part of the `externdesc` (e.g., `(import "x" (func $iden))`).
1302
1302
In the case of exports, the ` <id>? ` right after the ` export ` is bound (the
1303
1303
` <id> ` inside the ` <sortidx> ` is a reference to the preceding definition being
1304
1304
exported). The grammar for imports and exports is:
1305
- ```
1305
+ ``` ebnf
1306
1306
import ::= (import <importname> bind-id(<externdesc>))
1307
1307
export ::= (export <id>? <exportname> <sortidx> <externdesc>?)
1308
1308
exportname ::= <name>
@@ -1771,7 +1771,7 @@ to be satisfied by a JavaScript module via ESM-integration:
1771
1771
export default () => " hi" ;
1772
1772
```
1773
1773
when ` bar.wasm ` is loaded as an ESM:
1774
- ```
1774
+ ``` html
1775
1775
<script src =" bar.wasm" type =" module" ></script >
1776
1776
```
1777
1777
0 commit comments