diff --git a/design/mvp/Binary.md b/design/mvp/Binary.md index e196d479..2e772080 100644 --- a/design/mvp/Binary.md +++ b/design/mvp/Binary.md @@ -77,6 +77,7 @@ core:inlineexport ::= n: si: => (e instance ::= ie: => (instance ie) instanceexpr ::= 0x00 c: arg*:vec() => (instantiate c arg*) | 0x01 e*:vec() => e* + | 0x02 i: e*:vec() => (type i) e* instantiatearg ::= n: si: => (with n si) name ::= n: => n sortidx ::= sort: idx: => (sort idx) @@ -102,13 +103,23 @@ Notes: sort, but would be extended to accept other sorts as core wasm is extended. * Validation of `instantiate` requires each `` in `c` to match a `name` in a `with` argument (using plain string equality) and for the types to - match. + match unless the ``'s type is `optional`, in which case no `with` + argument need be given. * When validating `instantiate`, after each individual type-import is supplied via `with`, the actual type supplied is immediately substituted for all uses of the import, so that subsequent imports and all exports are now specialized to the actual type. * The indices in `sortidx` are validated according to their `sort`'s index spaces, which are built incrementally as each definition is validated. +* Validation of an `instanceexpr` with an ascribed `typeidx` requires that the + `typeidx` refer to an `instance` type and the given `inlineexport*` match the + `export`s of that `instance` type with the additional allowances that: + `optional` definitions can be supplied for non-`optional` `export`s of an + `optional` instance; and the `optional` `export`s in an `instance` type can be + omitted (see [optionality]). The resulting `instanceidx`'s type is then + exactly the ascribed type, with superfluous `inlineexport`s ignored. +* If a `typeidx` is not given to the `instanceexpr`, the resulting + `instanceidx`'s type is inferred from the `componentidx` or `inlineexport*`. ## Alias Definitions @@ -222,13 +233,21 @@ labellit ::= len: l: