Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions document/js-api/index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ urlPrefix: https://webidl.spec.whatwg.org/; spec: WebIDL
text: [EnforceRange]; url: #EnforceRange
text: unsigned long; url: #idl-unsigned-long
text: js-unsigned-long; url: #js-unsigned-long
text: converted to a JavaScript value; url: #dfn-convert-idl-to-javascript-value
urlPrefix: https://webassembly.github.io/js-types/js-api/; spec: WebAssembly JS API (JS Type Reflection)
type: abstract-op; text: FromValueType; url: abstract-opdef-fromvaluetype
urlPrefix: https://tc39.es/proposal-resizablearraybuffer/; spec: ResizableArrayBuffer proposal
Expand Down Expand Up @@ -1487,19 +1488,23 @@ The algorithm <dfn>ToWebAssemblyValue</dfn>(|v|, |type|) coerces a JavaScript va
</div>

<div algorithm>
The algorithm <dfn>AddressValueToU64</dfn>(|v|, |addrtype|) converts a JavaScript value to a WebAssembly [=u64=] for use in embedding operations. It is designed to act like [=[EnforceRange]=] [=unsigned long=] for {{AddressType}} "i32", and to extend these semantics to {{AddressType}} "i64", by performing the following steps:
The algorithm <dfn>AddressValueToU64</dfn>(|v|, |addrtype|) converts an IDL value to a WebAssembly [=u64=] for use in embedding operations. It is designed to act like [=[EnforceRange]=] [=unsigned long=] for {{AddressType}} "i32", and to extend these semantics to {{AddressType}} "i64", by performing the following steps:

1. Let |jsValue| be |v|, [=converted to a JavaScript value=].

Note: The IDL `any` type is a discriminated union, not a transparent wrapper around a JavaScript value.
1. If |addrtype| is [=i32=],
1. Let |n| be [=?=] [$ConvertToInt$](|v|, 32, "unsigned"), where the destination type is associated with [=[EnforceRange]=].
1. Let |n| be [=?=] [$ConvertToInt$](|jsValue|, 32, "unsigned"), where the destination type is associated with [=[EnforceRange]=].

Note: This is equivalent to the [=js-unsigned-long|JS conversion rules=] for [=[EnforceRange]=] [=unsigned long=].
1. Return [=ℝ=](|n|) as a WebAssembly [=u64=].
1. If |addrtype| is [=i64=],
1. Let |n| be [=?=] [$ToBigInt$](|v|).
1. If |n| &lt; 0 or |n| &gt; 2<sup>64</sup> &minus; 1, [=throw=] a {{TypeError}}.
1. Let |n| be [=?=] [$ToBigInt$](|jsValue|).
1. Let |r| be [=ℝ=](|n|).
1. If |r| &lt; 0 or |r| &gt; 2<sup>64</sup> &minus; 1, [=throw=] a {{TypeError}}.

Note: This operation is designed to emulate [=[EnforceRange]=].
1. Return [=ℝ=](|n|) as a WebAssembly [=u64=].
1. Return |r| as a WebAssembly [=u64=].
1. Assert: This step is not reached.

</div>
Expand Down
Loading