@@ -722,10 +722,10 @@ dictionary TableDescriptor {
722
722
723
723
[LegacyNamespace=WebAssembly, Exposed=(Window,Worker,Worklet)]
724
724
interface Table {
725
- constructor(TableDescriptor descriptor);
726
- unsigned long grow([EnforceRange] unsigned long delta);
727
- Function? get([EnforceRange] unsigned long index);
728
- void set([EnforceRange] unsigned long index, Function? value);
725
+ constructor(TableDescriptor descriptor, optional any value );
726
+ unsigned long grow([EnforceRange] unsigned long delta, optional any value );
727
+ any get([EnforceRange] unsigned long index);
728
+ void set([EnforceRange] unsigned long index, any value);
729
729
readonly attribute unsigned long length;
730
730
};
731
731
</pre>
@@ -736,7 +736,7 @@ which can be simultaneously referenced by multiple {{Instance}} objects. Each
736
736
{{Table}} object has the following internal slots:
737
737
738
738
* \[[Table]] : a [=table address=]
739
- * \[[Values]] : a [=list=] whose elements are either null or [=Exported Function=] s .
739
+ * \[[Values]] : a [=list=] whose elements depend on the element type of \ [[Table]] 's [=table type=] .
740
740
</div>
741
741
742
742
<div algorithm>
@@ -761,29 +761,39 @@ which can be simultaneously referenced by multiple {{Instance}} objects. Each
761
761
</div>
762
762
763
763
<div algorithm>
764
- The <dfn constructor for="Table">Table(|descriptor|)</dfn> constructor, when invoked, performs the following steps:
764
+ The <dfn constructor for="Table">Table(|descriptor|, |value|)</dfn> constructor, when invoked, performs the following steps:
765
+ 1. Let |elementType| be |descriptor|["element"] .
765
766
1. let |initial| be |descriptor|["initial"] .
766
767
1. If |descriptor|["maximum"] is [=present=] , let |maximum| be |descriptor|["maximum"] ; otherwise, let |maximum| be empty.
767
768
1. If |maximum| is not empty and |maximum| < |initial|, throw a {{RangeError}} exception.
768
- 1. Let |type| be the [=table type=] {[=table type|𝗆𝗂𝗇=] n, [=table type|𝗆𝖺𝗑=] |maximum|} [=table type|funcref=] .
769
+ 1. If |value| is missing and |elementType| is {{TableKind/anyfunc}} ,
770
+ 1. Set |value| to null.
771
+ 1. Let |ref| be ? [=ToWebAssemblyValue=] (|value|, |elementType|).
772
+ 1. Let |type| be the [=table type=] {[=table type|𝗆𝗂𝗇=] |initial|, [=table type|𝗆𝖺𝗑=] |maximum|} |elementType|.
769
773
1. Let |store| be the [=surrounding agent=] 's [=associated store=] .
770
- 1. Let (|store|, |tableaddr|) be [=table_alloc=] (|store|, |type|, [= ref.null=] ). <!-- TODO(littledan): Report allocation failure https://github.com/WebAssembly/spec/issues/584 -->
774
+ 1. Let (|store|, |tableaddr|) be [=table_alloc=] (|store|, |type|, | ref| ). <!-- TODO(littledan): Report allocation failure https://github.com/WebAssembly/spec/issues/584 -->
771
775
1. Set the [=surrounding agent=] 's [=associated store=] to |store|.
772
776
1. [=initialize a table object|Initialize=] **this** from |tableaddr|.
777
+ 1. [=list/Empty=] **this**.\[[Values]] .
778
+ 1. [=list/Append=] |value| to **this**.\[[Values]] |initial| times.
773
779
</div>
774
780
775
781
<div algorithm=dom-Table-grow>
776
- The <dfn method for="Table">grow(|delta|)</dfn> method, when invoked, performs the following steps:
782
+ The <dfn method for="Table">grow(|delta|, |value| )</dfn> method, when invoked, performs the following steps:
777
783
1. Let |tableaddr| be **this**.\[[Table]] .
778
784
1. Let |initialSize| be the length of **this**.\[[Values]] .
779
785
1. Let |store| be the [=surrounding agent=] 's [=associated store=] .
780
- 1. Let |result| be [=table_grow=] (|store|, |tableaddr|, |delta|, [=ref.null=] ).
786
+ 1. Let (<var ignore> limits</var> , |elementType|) be [=table_type=] (|tableaddr|).
787
+ 1. If |value| is missing and |elementType| is {{TableKind/anyfunc}} ,
788
+ 1. Set |value| to null.
789
+ 1. Let |ref| be ? [=ToWebAssemblyValue=] (|value|, |elementType|).
790
+ 1. Let |result| be [=table_grow=] (|store|, |tableaddr|, |delta|, |ref|).
781
791
1. If |result| is [=error=] , throw a {{RangeError}} exception.
782
792
783
793
Note: The above exception may happen due to either insufficient memory or an invalid size parameter.
784
794
785
795
1. Set the [=surrounding agent=] 's [=associated store=] to |result|.
786
- 1. [=list/Append=] null to **this**.\[[Values]] |delta| times.
796
+ 1. [=list/Append=] |value| to **this**.\[[Values]] |delta| times.
787
797
1. Return |initialSize|.
788
798
</div>
789
799
@@ -803,10 +813,10 @@ which can be simultaneously referenced by multiple {{Instance}} objects. Each
803
813
The <dfn method for="Table">set(|index|, |value|)</dfn> method, when invoked, performs the following steps:
804
814
1. Let |tableaddr| be **this**.\[[Table]] .
805
815
1. Let |values| be **this**.\[[Values]] .
806
- 1. If |value| is null, let |ref| be [=ref.null=] .
807
- 1. Otherwise ,
808
- 1. If |value| does not have a \ [[FunctionAddress]] internal slot, throw a {{TypeError}} exception .
809
- 1. Let |ref| be [=ref.func=] |value|.\ [[FunctionAddress]] .
816
+ 1. Let ( <var ignore> limits </var> , |elementType|) be [=table_type=] (|tableaddr|) .
817
+ 1. If |value| is undefined and |elementType| is {{TableKind/anyfunc}} ,
818
+ 1. Set |value| to null .
819
+ 1. Let |ref| be ? [=ToWebAssemblyValue=] ( |value|, |elementType|) .
810
820
1. Let |store| be the [=surrounding agent=] 's [=associated store=] .
811
821
1. Let |store| be [=table_write=] (|store|, |tableaddr|, |index|, |ref|).
812
822
1. If |store| is [=error=] , throw a {{RangeError}} exception.
0 commit comments