@@ -7,6 +7,7 @@ JavaScript runtimes. For a more user-focussed explanation, take a look at the
7
7
8
8
* [ Grammar] ( #grammar )
9
9
* [ Component definitions] ( #component-definitions )
10
+ * [ Index spaces] ( #index-spaces )
10
11
* [ Instance definitions] ( #instance-definitions )
11
12
* [ Alias definitions] ( #alias-definitions )
12
13
* [ Type definitions] ( #type-definitions )
@@ -129,6 +130,63 @@ next), nothing will be instantiated or executed at runtime; everything here is
129
130
dead code.
130
131
131
132
133
+ #### Index Spaces
134
+
135
+ [ Like Core WebAssembly] [ Core Indices ] , the Component Model places each
136
+ ` definition ` into one of a fixed set of * index spaces* , allowing the
137
+ definition to be referred to by subsequent definitions (in the text and binary
138
+ format) via a nonnegative integral * index* . When defining, validating and
139
+ executing a component, there are 5 component-level index spaces:
140
+ * (component) functions
141
+ * (component) values
142
+ * (component) types
143
+ * component instances
144
+ * components
145
+
146
+ 5 core index spaces that also exist in WebAssembly 1.0:
147
+ * (core) functions
148
+ * (core) tables
149
+ * (core) memories
150
+ * (core) globals
151
+ * (core) types
152
+
153
+ and 2 additional core index spaces that contain core definition introduced by
154
+ the Component Model that are not in WebAssembly 1.0 (yet: the [ module-linking]
155
+ proposal would add them):
156
+ * module instances
157
+ * modules
158
+
159
+ for a total of 12 index spaces that need to be maintained by an implementation
160
+ when, e.g., validating a component. These 12 index spaces correspond 1:1 with
161
+ the terminals of the ` sort ` production defined below and thus "sort" and
162
+ "index space" can be used interchangeably.
163
+
164
+ Also [ like Core WebAssembly] [ Core Identifiers ] , the Component Model text format
165
+ allows * identifiers* to be used in place of these indices, which are resolved
166
+ when parsing into indices in the AST (upon which validation and execution is
167
+ defined). Thus, the following two components are equivalent:
168
+ ``` wasm
169
+ (component
170
+ (core module (; empty ;))
171
+ (component (; empty ;))
172
+ (core module (; empty ;))
173
+ (export "C" (component 0))
174
+ (export "M1" (core module 0))
175
+ (export "M2" (core module 1))
176
+ )
177
+ ```
178
+ ``` wasm
179
+ (component
180
+ (core module $M1 (; empty ;))
181
+ (component $C (; empty ;))
182
+ (core module $M2 (; empty ;))
183
+ (export "C" (component $C))
184
+ (export "M1" (core module $M1))
185
+ (export "M2" (core module $M2))
186
+ )
187
+ ```
188
+
189
+
132
190
### Instance Definitions
133
191
134
192
Whereas modules and components represent immutable * code* , instances associate
@@ -1800,6 +1858,8 @@ and will be added over the coming months to complete the MVP proposal:
1800
1858
[ Structure Section ] : https://webassembly.github.io/spec/core/syntax/index.html
1801
1859
[ Text Format Section ] : https://webassembly.github.io/spec/core/text/index.html
1802
1860
[ Binary Format Section ] : https://webassembly.github.io/spec/core/binary/index.html
1861
+ [ Core Indices ] : https://webassembly.github.io/spec/core/syntax/modules.html#indices
1862
+ [ Core Identifiers ] : https://webassembly.github.io/spec/core/text/values.html#text-id
1803
1863
1804
1864
[ Index Space ] : https://webassembly.github.io/spec/core/syntax/modules.html#indices
1805
1865
[ Abbreviations ] : https://webassembly.github.io/spec/core/text/conventions.html#abbreviations
0 commit comments