diff --git a/document/js-api/index.bs b/document/js-api/index.bs index 0c82236a18..644d920e07 100644 --- a/document/js-api/index.bs +++ b/document/js-api/index.bs @@ -720,10 +720,10 @@ dictionary GlobalDescriptor { boolean mutable = false; }; -[LegacyNamespace=WebAssembly, Constructor(GlobalDescriptor descriptor, unrestricted double value = 0), Exposed=(Window,Worker,Worklet)] +[LegacyNamespace=WebAssembly, Constructor(GlobalDescriptor descriptor, optional any value), Exposed=(Window,Worker,Worklet)] interface Global { - unrestricted double valueOf(); - attribute unrestricted double value; + any valueOf(); + attribute any value; }; @@ -753,11 +753,19 @@ which can be simultaneously referenced by multiple {{Instance}} objects. Each 1. Otherwise, throw a {{TypeError}} exception. +
+ The algorithm DefaultValue(|valuetype|) performs the following steps: + 1. If |valuetype| equals [=𝗂πŸ₯𝟀=], return [=𝗂πŸ₯𝟀.π–Όπ—ˆπ—‡π—Œπ—=] 0. + 1. If |valuetype| equals [=𝖿πŸ₯𝟀=], return [=𝖿πŸ₯𝟀.π–Όπ—ˆπ—‡π—Œπ—=] 0. + 1. If |valuetype| equals [=π–ΏπŸ¨πŸ¦=], return [=π–ΏπŸ¨πŸ¦.π–Όπ—ˆπ—‡π—Œπ—=] 0. + 1. Otherwise, throw a {{TypeError}} exception. +
+
The Global(descriptor, v) constructor, when invoked, performs the following steps: 1. Let |mutable| be |descriptor|["mutable"]. 1. Let |valuetype| be [=ToValueType=](|descriptor|["value"]). - 1. Let |value| be [=ToWebAssemblyValue=](|v|, |valuetype|). + 1. If |v| is undefined, let |value| be [=DefaultValue=](|valuetype|); otherwise, let |value| be [=ToWebAssemblyValue=](|v|, |valuetype|). 1. If |mutable| is true, let |globaltype| be [=var=] |valuetype|; otherwise, let |globaltype| be [=const=] |valuetype|. 1. Let |store| be the current agent's [=associated store=]. 1. Let (|store|, |globaladdr|) be [=alloc_global=](|store|, |globaltype|, |value|).