diff --git a/document/js-api/index.bs b/document/js-api/index.bs index 64dfd22f77..11f3ecea06 100644 --- a/document/js-api/index.bs +++ b/document/js-api/index.bs @@ -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 @@ -1487,19 +1488,23 @@ The algorithm ToWebAssemblyValue(|v|, |type|) coerces a JavaScript va
-The algorithm AddressValueToU64(|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 AddressValueToU64(|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| < 0 or |n| > 264 − 1, [=throw=] a {{TypeError}}. + 1. Let |n| be [=?=] [$ToBigInt$](|jsValue|). + 1. Let |r| be [=ℝ=](|n|). + 1. If |r| < 0 or |r| > 264 − 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.