@@ -115,7 +115,7 @@ A new section defining local instances
115115```
116116instancesec ::= i*:section_15(vec(instancedef)) -> i*
117117
118- instancedef ::= 0x00 m:moduleidx e *:vec(exportdesc ) -> {instantiate m, imports e *}
118+ instancedef ::= 0x00 m:moduleidx arg *:vec(export ) -> {instantiate m, imports arg *}
119119```
120120
121121This defines instances in the module, appending to the instance index space.
@@ -130,18 +130,9 @@ the future we'll likely want this binary value to match that.
130130* The module index ` m ` must be in bounds.
131131* Indices of items referred to by ` exportdesc ` are all in-bounds. Can only refer
132132 to imports/previous aliases, since only those sections can precede.
133- * The ` e* ` list is validated against the module type's declared list
134- of [ imports pairwise and in-order] ( Explainer.md#module-imports-and-nested-instances ) .
135- The type of each item must be a subtype of the expected type listed in the
136- module's type.
133+ * The ` arg* ` list is validated against ` m ` 's imports according to
134+ [ module subtyping] ( Subtyping.md#instantiation ) rules.
137135
138- ** Execution notes**
139-
140- * The actual module being instantiated does not need to list imports in the
141- exact same order as its type declaration. The ` e* ` has names based on the
142- local module type's declaration.
143- * Be sure to read up on [ subtyping] ( ./Subtyping.md ) to ensure that instances
144- with a single name can be used to match imports with a two-level namespace.
145136
146137## Alias section (16)
147138
@@ -151,39 +142,22 @@ A new module section is added
151142aliassec ::= a*:section_16(vec(alias)) -> a*
152143
153144alias ::=
154- 0x00 i:instanceidx 0x00 e:exportidx -> (alias (instance $i) (func $e))
155- 0x00 i:instanceidx 0x01 e:exportidx -> (alias (instance $i) (table $e))
156- 0x00 i:instanceidx 0x02 e:exportidx -> (alias (instance $i) (memory $e))
157- 0x00 i:instanceidx 0x03 e:exportidx -> (alias (instance $i) (global $e))
158- 0x00 i:instanceidx 0x05 e:exportidx -> (alias (instance $i) (module $e))
159- 0x00 i:instanceidx 0x06 e:exportidx -> (alias (instance $i) (instance $e))
160- 0x01 0x05 m:moduleidx -> (alias parent (module $m))
161- 0x01 0x07 t:typeidx -> (alias parent (type $t))
145+ 0x00 i:instanceidx nm:name -> (alias (* $i nm))
146+ 0x01 ct:varu32 0x05 m:moduleidx -> (alias (module outer ct m))
147+ 0x01 ct:varu32 0x07 t:typeidx -> (alias (type outer ct t))
162148```
163149
164150** Validation**
165151
166- * Aliased instance indexes are all in bounds. Remember "in bounds" here means it
167- can't refer to instances defined after the ` alias ` item.
168- * Aliased instance export indices are in bounds relative to the instance's
169- * locally-declared* (via module or instance type) list of exports.
170- * Export indices match the actual type of the export
171- * Aliases append to the respective index space.
172- * Parent aliases can only happen in submodules (not the top-level module) and
173- the index specifies is the entry, in the parent's raw index space, for that
174- item.
175- * Parent aliases can only refer to preceeding module/type definitions, relative
176- to the binary location where the inline module's type was declared. Note that
177- when the module code section is defined all of the parent's modules/types are
178- available, but inline modules still may not have access to all of these if the
179- items were declared after the module's type in the corresponding module
180- section.
181-
182- ** Execution notes**
183-
184- * Note for child aliases that while the export is referred to by index it's
185- actually loaded from the specified instance by name. The name loaded
186- corresponds to the ` i ` th export's name in the locally defined type.
152+ * The instance, module and type indices are all in bounds. Remember that "in bounds"
153+ means only those definitions preceding this alias definition in binary format
154+ order. In the case of outer aliases, this means the position of the nested module
155+ definition in the outer module.
156+ * Aliased instance export names must be found in the instance ` $i ` .
157+ * For instance export aliases, the index space into which the alias is
158+ injected is determined by the definition kind of the named export.
159+ * The ` ct ` of an outer alias must be * less than* the number of enclosing modules
160+ which implicitly prevents outer aliases from appearing in top-level modules.
187161
188162## Function section
189163
0 commit comments