Skip to content

Commit 7c7bd2a

Browse files
authored
Fix some js-api bugs. (#128)
1 parent c19b709 commit 7c7bd2a

File tree

1 file changed

+15
-22
lines changed

1 file changed

+15
-22
lines changed

Diff for: document/js-api/index.bs

+15-22
Original file line numberDiff line numberDiff line change
@@ -740,14 +740,9 @@ interface Table {
740740
};
741741
</pre>
742742

743-
<div>
744-
A {{Table}} object represents a single [=table instance=]
745-
which can be simultaneously referenced by multiple {{Instance}} objects.
746-
Each {{Table}} object has the following internal slots:
747-
748-
* \[[Table]] : a [=table address=]
749-
* \[[Values]] : a [=list=] whose elements depend on the element type of \[[Table]]'s [=table type=].
750-
</div>
743+
A {{Table}} object represents a single [=table instance=] which can be simultaneously referenced by
744+
multiple {{Instance}} objects.
745+
Each {{Table}} object has a \[[Table]] internal slot, which is a [=table address=].
751746

752747
<div algorithm>
753748
To <dfn>initialize a table object</dfn> |table| from a [=table address=] |tableaddr|, perform the following steps:
@@ -770,7 +765,7 @@ Each {{Table}} object has the following internal slots:
770765
<div algorithm>
771766
The <dfn constructor for="Table">Table(|descriptor|, |value|)</dfn> constructor, when invoked, performs the following steps:
772767
1. Let |elementType| be [=ToValueType=](|descriptor|["element"]).
773-
1. let |initial| be |descriptor|["initial"].
768+
1. Let |initial| be |descriptor|["initial"].
774769
1. If |descriptor|["maximum"] [=map/exists=], let |maximum| be |descriptor|["maximum"]; otherwise, let |maximum| be empty.
775770
1. If |maximum| is not empty and |maximum| &lt; |initial|, throw a {{RangeError}} exception.
776771
1. If |value| is missing,
@@ -782,8 +777,6 @@ Each {{Table}} object has the following internal slots:
782777
1. Let (|store|, |tableaddr|) be [=table_alloc=](|store|, |type|, |ref|). <!-- TODO(littledan): Report allocation failure https://github.com/WebAssembly/spec/issues/584 -->
783778
1. Set the [=surrounding agent=]'s [=associated store=] to |store|.
784779
1. [=initialize a table object|Initialize=] **this** from |tableaddr|.
785-
1. [=list/Empty=] **this**.\[[Values]].
786-
1. [=list/Append=] |value| to **this**.\[[Values]] |initial| times.
787780
</div>
788781

789782
<div algorithm=dom-Table-grow>
@@ -802,7 +795,6 @@ Each {{Table}} object has the following internal slots:
802795
Note: The above exception can happen due to either insufficient memory or an invalid size parameter.
803796

804797
1. Set the [=surrounding agent=]'s [=associated store=] to |result|.
805-
1. [=list/Append=] |value| to **this**.\[[Values]] |delta| times.
806798
1. Return |initialSize|.
807799
</div>
808800

@@ -819,14 +811,12 @@ Each {{Table}} object has the following internal slots:
819811
1. Let |store| be the [=surrounding agent=]'s [=associated store=].
820812
1. Let |result| be [=table_read=](|store|, |tableaddr|, |index|).
821813
1. If |result| is [=error=], throw a {{RangeError}} exception.
822-
1. Let |function| be the result of creating [=a new Exported Function=] from |result|.
823-
1. Return |function|.
814+
1. Return [=ToJSValue=](|result|).
824815
</div>
825816

826817
<div algorithm>
827818
The <dfn method for="Table">set(|index|, |value|)</dfn> method, when invoked, performs the following steps:
828819
1. Let |tableaddr| be **this**.\[[Table]].
829-
1. Let |values| be **this**.\[[Values]].
830820
1. Let (<var ignore>limits</var>, |elementType|) be [=table_type=](|tableaddr|).
831821
1. If |value| is missing,
832822
1. Let |ref| be [=DefaultValue=](|elementType|).
@@ -897,7 +887,7 @@ which can be simultaneously referenced by multiple {{Instance}} objects. Each
897887
1. If |s| equals "i64", return [=i64=].
898888
1. If |s| equals "f32", return [=f32=].
899889
1. If |s| equals "f64", return [=f64=].
900-
1. If |s| equals "funcref", return [=funcref=].
890+
1. If |s| equals "anyfunc", return [=funcref=].
901891
1. If |s| equals "externref", return [=externref=].
902892
1. Assert: This step is not reached.
903893
</div>
@@ -908,6 +898,7 @@ which can be simultaneously referenced by multiple {{Instance}} objects. Each
908898
1. If |valuetype| equals [=i64=], return [=i64.const=] 0.
909899
1. If |valuetype| equals [=f32=], return [=f32.const=] 0.
910900
1. If |valuetype| equals [=f64=], return [=f64.const=] 0.
901+
1. If |valuetype| equals [=funcref=], return [=ref.null=] [=funcref=].
911902
1. If |valuetype| equals [=externref=], return [=ToWebAssemblyValue=](undefined, |valuetype|).
912903
1. Assert: This step is not reached.
913904
</div>
@@ -917,7 +908,7 @@ which can be simultaneously referenced by multiple {{Instance}} objects. Each
917908
1. Let |mutable| be |descriptor|["mutable"].
918909
1. Let |valuetype| be [=ToValueType=](|descriptor|["value"]).
919910
1. If |v| is missing,
920-
1. let |value| be [=DefaultValue=](|valuetype|).
911+
1. Let |value| be [=DefaultValue=](|valuetype|).
921912
1. Otherwise,
922913
1. Let |value| be [=ToWebAssemblyValue=](|v|, |valuetype|).
923914
1. If |mutable| is true, let |globaltype| be [=var=] |valuetype|; otherwise, let |globaltype| be [=const=] |valuetype|.
@@ -1088,10 +1079,13 @@ Note: Number values which are equal to NaN may have various observable NaN paylo
10881079
</div>
10891080

10901081
<div algorithm>
1091-
For <dfn>retrieving an extern value</dfn> from a [=extern address=] |externaddr|, perform the following steps:
1092-
1. Let |map| be the [=surrounding agent=]'s associated [=extern value cache=].
1093-
1. Assert: |map|[|externaddr|] [=map/exists=].
1094-
1. Return |map|[|externaddr|].
1082+
1083+
For <dfn>retrieving an extern value</dfn> from an [=extern address=] |externaddr|, perform the following steps:
1084+
1085+
1. Let |map| be the [=surrounding agent=]'s associated [=extern value cache=].
1086+
1. Assert: |map|[|externaddr|] [=map/exists=].
1087+
1. Return |map|[|externaddr|].
1088+
10951089
</div>
10961090

10971091
<div algorithm>
@@ -1129,7 +1123,6 @@ The algorithm <dfn>ToWebAssemblyValue</dfn>(|v|, |type|) coerces a JavaScript va
11291123

11301124
</div>
11311125

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

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

0 commit comments

Comments
 (0)