Skip to content

Commit f2e5080

Browse files
committed
Add basic support for fromCharCodeArray
Needs more detail to properly integrate with GC array ops.
1 parent ebd3d5f commit f2e5080

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

document/js-api/index.bs

+29-2
Original file line numberDiff line numberDiff line change
@@ -1814,6 +1814,15 @@ The <dfn abstract-op lt="UnwrapString">UnwrapString(|v|)</dfn> abstract operatio
18141814

18151815
</div>
18161816

1817+
<div algorithm>
1818+
1819+
The <dfn abstract-op lt="FromCharCode">FromCharCode(|v|)</dfn> abstract operation, when invoked, performs the following steps:
1820+
1821+
1. Assert: |v| is of type [=i32=].
1822+
1. Return [=!=] [$Call$]([=String.fromCharCode=], undefined, « [=ToJSValue=](|v|) »).
1823+
1824+
</div>
1825+
18171826
<h4 id="js-string-cast">cast</h4>
18181827

18191828
The |funcType| of this builtin is `(func (param externref) (result externref))`.
@@ -1840,7 +1849,25 @@ When this builtin is invoked with parameter |v|, the following steps must be run
18401849

18411850
<h4 id="js-string-fromCharCodeArray">fromCharCodeArray</h4>
18421851

1843-
TODO
1852+
The |funcType| of this builtin is `(func (param (ref null (array (mut i16))) i32 i32) (result externref))`.
1853+
1854+
<div algorithm="js-string-fromCharCodeArray">
1855+
When this builtin is invoked with parameters |array|, |start|, and |end|, the following steps must be run:
1856+
1857+
1. If |array| is nul]
1858+
1. Throw a {{RuntimeError}} exception. TODO: this needs to not be catchable, like a trap.
1859+
1. If |start| > |end| or |end| > [=array_len=](|array|)
1860+
1. Throw a {{RuntimeError}} exception. TODO: this needs to not be catchable, like a trap.
1861+
1. Let |result| be the empty string
1862+
1. Let |i| be |start|
1863+
1. While |i| < |end|:
1864+
1. Let |charCode| be [=array_i16_get=](|array|, |i|).
1865+
1. Let |charCodeString| be [$FromCharCode$](|charCode|).
1866+
1. Let |result| be the concatenation of |result| and |charCodeString|.
1867+
1. Set |i| to |i| + 1.
1868+
1. Return |result|
1869+
1870+
</div>
18441871

18451872
<h4 id="js-string-intoCharCodeArray">intoCharCodeArray</h4>
18461873

@@ -1853,7 +1880,7 @@ The |funcType| of this builtin is `(func (param i32) (result externref))`.
18531880
<div algorithm="js-string-fromCharCode">
18541881
When this builtin is invoked with parameter |v|, the following steps must be run:
18551882

1856-
1. Return [=!=] [$Call$]([=String.fromCharCode=], undefined, « [=ToJSValue=](|v|) »).
1883+
1. Return [$FromCharCode$](|v|).
18571884

18581885
</div>
18591886

0 commit comments

Comments
 (0)