Skip to content

Commit e6462a6

Browse files
ajkleineqrion
authored andcommitted
Make fromCharCodeArray slightly less formal
This avoids having to refer to actual Wasm instructions, since after all this is a host function.
1 parent a402a3a commit e6462a6

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

document/js-api/index.bs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1851,21 +1851,26 @@ When this builtin is invoked with parameter |v|, the following steps must be run
18511851

18521852
The |funcType| of this builtin is `(func (param (ref null (array (mut i16))) i32 i32) (result externref))`.
18531853

1854+
Note: This function only takes a mutable i16 array defined in its own recursion group.
1855+
If this is an issue for toolchains, we can look into how to relax the function type
1856+
while still maintaining good performance.
1857+
18541858
<div algorithm="js-string-fromCharCodeArray">
18551859
When this builtin is invoked with parameters |array|, |start|, and |end|, the following steps must be run:
18561860

1857-
1. If |array| is nul]
1861+
1. If |array| is null
18581862
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|)
1863+
1. Let |length| be the number of elements in |array|.
1864+
1. If |start| > |end| or |end| > |length|
18601865
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|
1866+
1. Let |result| be the empty string.
1867+
1. Let |i| be |start|.
18631868
1. While |i| < |end|:
1864-
1. Let |charCode| be [=array_i16_get=](|array|, |i|).
1869+
1. Let |charCode| be the value of the element stored at index |i| in |array|.
18651870
1. Let |charCodeString| be [$FromCharCode$](|charCode|).
18661871
1. Let |result| be the concatenation of |result| and |charCodeString|.
18671872
1. Set |i| to |i| + 1.
1868-
1. Return |result|
1873+
1. Return |result|.
18691874

18701875
</div>
18711876

0 commit comments

Comments
 (0)