Skip to content

Prepare for integration with String Builtins #95

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
9 changes: 8 additions & 1 deletion document/js-api/index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -1386,9 +1386,12 @@ To <dfn export>parse a WebAssembly module</dfn> given a <a>byte sequence</a> |by
1. Let |stableBytes| be a [=get a copy of the buffer source|copy of the bytes held by the buffer=] |bytes|.
1. [=Compile a WebAssembly module|Compile the WebAssembly module=] |stableBytes| and store the result as |module|.
1. If |module| is [=error=], throw a {{CompileError}} exception.
1. Note: When integrating with the JS String Builtins proposal, |builtinSetNames| should be passed in the following step as « "js-string" » and |importedStringModule| as null.
1. [=Construct a WebAssembly module object=] from |module| and |bytes|, and let |module| be the result.
1. Let |requestedModules| be a set.
1. For each (|moduleName|, <var ignore>name</var>, <var ignore>type</var>) in [=module_imports=](|module|.\[[Module]]),
1. For each (|moduleName|, |name|, |type|) in [=module_imports=](|module|.\[[Module]]),
1. Note: The following step only applies when integrating with the JS String Builtins proposal.
1. If [=Find a builtin=] with (|moduleName|, |name|, |type|) and builtins |module|.\[[BuiltinSets]] is not null, then [=iteration/continue=].
1. [=set/Append=] |moduleName| to |requestedModules|.
1. Let |moduleRecord| be {
<!-- Abstract Module Records -->
Expand All @@ -1414,6 +1417,8 @@ To <dfn export>parse a WebAssembly module</dfn> given a <a>byte sequence</a> |by
1. Set |module|.\[[ModuleRecord]] to |moduleRecord|.
1. Return |moduleRecord|.

Note: While this spec is not currently merged with the JS String Builtins proposal, the steps to take when merging are noted here for reference.

Note: From HTML, it's not observable when [=parse a WebAssembly module=] begins, so any work perfomed in compilation may be performed off-thread.
</div>

Expand Down Expand Up @@ -1473,6 +1478,8 @@ WebAssembly Module Records have the following methods:
1. Let |module| be |record|.\[[ModuleSource]].
1. Let |imports| be a new, empty [=map=].
1. For each (|importedModuleName|, |name|, <var ignore>type</var>) in [=module_imports=](|module|.\[[Module]]),
1. Note: The following step only applies when integrating with the JS String Builtins proposal.
1. If [=Find a builtin=] with (|importedModuleName|, |name|) and builtins |module|.\[[BuiltinSets]] is not null, then [=iteration/continue=].
1. If |imports|[|importedModuleName|] does not exist, set |imports|[|importedModuleName|] to a new, empty [=map=].
1. Let |importedModule| be [$GetImportedModule$](|record|, |importedModuleName|).
1. Let |value| be ? |importedModule|.\[[Environment]].GetBindingValue(|name|, true).
Expand Down