@@ -1823,6 +1823,15 @@ The <dfn abstract-op lt="FromCharCode">FromCharCode(|v|)</dfn> abstract operatio
1823
1823
1824
1824
</div>
1825
1825
1826
+ <div algorithm>
1827
+
1828
+ The <dfn abstract-op lt="CharCodeAt ">CharCodeAt(|string|, |index|)</dfn> abstract operation, when invoked, performs the following steps:
1829
+
1830
+ 1. Assert: |index| is of type [=i32=] .
1831
+ 1. Return [=!=] [$Call$] ([=String.prototype.charCodeAt=] , |string|, « [=ToJSValue=] (|index|) »).
1832
+
1833
+ </div>
1834
+
1826
1835
<h4 id="js-string-cast">cast</h4>
1827
1836
1828
1837
The |funcType| of this builtin is `(func (param externref) (result externref))`.
@@ -1876,7 +1885,31 @@ When this builtin is invoked with parameters |array|, |start|, and |end|, the fo
1876
1885
1877
1886
<h4 id="js-string-intoCharCodeArray">intoCharCodeArray</h4>
1878
1887
1879
- TODO
1888
+ The |funcType| of this builtin is `(func (param externref (ref null (array (mut i16))) i32) (result i32))`.
1889
+
1890
+ Note: This function only takes a mutable i16 array defined in its own recursion group.
1891
+ If this is an issue for toolchains, we can look into how to relax the function type
1892
+ while still maintaining good performance.
1893
+
1894
+ <div algorithm="js-string-intoCharCodeArray">
1895
+ When this builtin is invoked with parameters |string|, |array|, and |start|, the following steps must be run:
1896
+
1897
+ 1. If |array| is null
1898
+ 1. Throw a {{RuntimeError}} exception. TODO: this needs to not be catchable, like a trap.
1899
+ 1. Let |string| be [=?=] [$UnwrapString$] (|string|).
1900
+ 1. Let |stringLength| be the [=string/length=] of |string|.
1901
+ 1. Let |arrayLength| be the number of elements in |array|.
1902
+ 1. If |start| + |length| > |arrayLength|
1903
+ 1. Throw a {{RuntimeError}} exception. TODO: this needs to not be catchable, like a trap.
1904
+ 1. Let |i| be 0.
1905
+ 1. While |i| < |stringLength|:
1906
+ 1. Let |charCode| be [$CharCodeAt$] (|string|, |i|).
1907
+ 1. Set the element at index |start| + |i| in |array| to [=ToWebAssemblyValue=] (|charCode|).
1908
+ 1. Set |i| to |i| + 1.
1909
+ 1. Return |stringLength|.
1910
+
1911
+ </div>
1912
+
1880
1913
1881
1914
<h4 id="js-string-fromCharCode">fromCharCode</h4>
1882
1915
@@ -1913,7 +1946,7 @@ When this builtin is invoked with parameters |string| and |index|, the following
1913
1946
1. Let |length| be the [=string/length=] of |string|.
1914
1947
1. If |index| >= |length|
1915
1948
1. Throw a {{RuntimeError}} exception. TODO: this needs to not be catchable, like a trap.
1916
- 1. Return [=!=] [$Call $] ([=String.prototype.charCodeAt=] , |string|, « [=ToJSValue=] ( |index|) » ).
1949
+ 1. Return [$CharCodeAt $] (|string|, |index|).
1917
1950
1918
1951
</div>
1919
1952
0 commit comments