Skip to content

Commit

Permalink
update for exnref
Browse files Browse the repository at this point in the history
  • Loading branch information
dschuff committed Apr 5, 2024
1 parent a80e7b3 commit bc04bb4
Showing 1 changed file with 21 additions and 12 deletions.
33 changes: 21 additions & 12 deletions document/js-api/index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,23 @@ The verification of WebAssembly type requirements is deferred to the

Note: A follow-on streaming API is documented in the <a href="https://webassembly.github.io/spec/web-api/index.html">WebAssembly Web API</a>.

<div algorithm>
<dfn>create the WebAssembly namespace object</dfn>:

When the [=namespace object=] for the {{WebAssembly}} namespace is [=create a namespace object|created=], the following steps must be run:

1. Let |namespaceObject| be the [=namespace object=].
1. [=list/iterate|For each=] |error| of « "CompileError", "LinkError", "RuntimeError" »,
1. Let |constructor| be a new object, implementing the [=NativeError Object Structure=], with <var ignore>NativeError</var> set to |error|.
1. [=!=] [$DefineMethodProperty$](|namespaceObject|, |error|, |constructor|, True).
1. Let |JsTagAddr| be the result of [=get the JavaScript exception tag|getting the JavaScript exception tag=].
1. Let |JsTagObject| be the result of [=create a Tag object|creating a Tag object=] from |JsTagAddr|.
1. [=!=] [$DefineMethodProperty$](|namespaceObject|, "JSTag", |JsTagObject|, True).

</div>

Note: It is not currently possible to define this behavior using Web IDL.

<h3 id="modules">Modules</h3>

<pre class="idl">
Expand Down Expand Up @@ -1361,6 +1378,7 @@ The <dfn>JavaScript exception tag</dfn> is a [=tag address=] associated with
the surrounding agent. It is allocated in the agent's [=associated store=] on
first use and cached. It always has the [=tag type=] « [=externref=] » → « ».

It is exposed to JavaScript code via {{WebAssembly}}.{{JSTag}} a global pre-initialized

<div algorithm>

Expand All @@ -1376,25 +1394,16 @@ To <dfn>get the JavaScript exception tag</dfn>, perform the following steps:

</div>

<h3 id="error-objects">Error Objects</h3>

WebAssembly defines the following Error classes: <dfn exception>CompileError</dfn>, <dfn exception>LinkError</dfn>, and <dfn exception>RuntimeError</dfn>.

<div algorithm="create the WebAssembly namespace object">
When the [=namespace object=] for the {{WebAssembly}} namespace is [=create a namespace object|created=], the following steps must be run:

1. Let |namespaceObject| be the [=namespace object=].
1. [=list/iterate|For each=] |error| of « "CompileError", "LinkError", "RuntimeError" »,
1. Let |constructor| be a new object, implementing the [=NativeError Object Structure=], with <var ignore>NativeError</var> set to |error|.
1. [=!=] [$CreateMethodProperty$](|namespaceObject|, |error|, |constructor|).
<h3 id="error-objects">Error Objects</h3>

</div>
WebAssembly defines the following Error classes: <dfn exception>CompileError</dfn>, <dfn exception>LinkError</dfn>, and <dfn exception>RuntimeError</dfn>.
Their initialization is described in [=create the WebAssembly namespace object=].

Note: This defines {{CompileError}}, {{LinkError}}, and {{RuntimeError}} classes on the {{WebAssembly}} namespace, which are produced by the APIs defined in this specification.
They expose the same interface as native JavaScript errors like {{TypeError}} and {{RangeError}}.

Note: It is not currently possible to define this behavior using Web IDL.


<h2 id="errors">Error Condition Mappings to JavaScript</h2>

Expand Down

0 comments on commit bc04bb4

Please sign in to comment.