Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editorial: Relocate the definition of StringIndexOf #2069

Merged
merged 1 commit into from
Jul 1, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 21 additions & 21 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -982,6 +982,27 @@ <h1>The String Type</h1>
<p>The rationale behind this design was to keep the implementation of Strings as simple and high-performing as possible. If ECMAScript source text is in Normalized Form C, string literals are guaranteed to also be normalized, as long as they do not contain any Unicode escape sequences.</p>
</emu-note>
<p>In this specification, the phrase "the <dfn>string-concatenation</dfn> of _A_, _B_, ..." (where each argument is a String value, a code unit, or a sequence of code units) denotes the String value whose sequence of code units is the concatenation of the code units (in order) of each of the arguments (in order).</p>

<emu-clause id="sec-stringindexof" aoid="StringIndexOf">
<h1>Runtime Semantics: StringIndexOf ( _string_, _searchValue_, _fromIndex_ )</h1>
<p>The abstract operation StringIndexOf takes arguments _string_ (a String), _searchValue_ (a String), and _fromIndex_ (a non-negative integer). It performs the following steps when called:</p>
<emu-alg>
1. Assert: Type(_string_) is String.
1. Assert: Type(_searchValue_) is String.
1. Assert: ! IsNonNegativeInteger(_fromIndex_) is *true*.
1. Let _len_ be the length of _string_.
1. If _searchValue_ is the empty String and _fromIndex_ &le; _len_, return _fromIndex_.
1. Let _searchLen_ be the length of _searchValue_.
1. If there exists any integer _k_ such that _fromIndex_ &le; _k_ &le; _len_ - _searchLen_ and for all nonnegative integers _j_ less than _searchLen_, the code unit at index _k_ + _j_ within _string_ is the same as the code unit at index _j_ within _searchValue_, let _pos_ be the smallest (closest to *-&infin;*) such integer. Otherwise, let _pos_ be -1.
1. Return _pos_.
</emu-alg>
<emu-note>
<p>If _searchValue_ is empty and _fromIndex_ is less than or equal to the length of _string_, this algorithm returns _fromIndex_. An empty _searchValue_ is effectively found at every position within a string, including after the last code unit.</p>
</emu-note>
<emu-note>
<p>This algorithm always returns -1 if _fromIndex_ &gt; the length of _string_.</p>
</emu-note>
</emu-clause>
</emu-clause>

<emu-clause id="sec-ecmascript-language-types-symbol-type">
Expand Down Expand Up @@ -10456,27 +10477,6 @@ <h1>Static Semantics: UTF16DecodeString ( _string_ )</h1>
</emu-clause>
</emu-clause>

<emu-clause id="sec-stringindexof" aoid="StringIndexOf">
<h1>Runtime Semantics: StringIndexOf ( _string_, _searchValue_, _fromIndex_ )</h1>
<p>The abstract operation StringIndexOf takes arguments _string_ (a String), _searchValue_ (a String), and _fromIndex_ (a non-negative integer). It performs the following steps when called:</p>
<emu-alg>
1. Assert: Type(_string_) is String.
1. Assert: Type(_searchValue_) is String.
1. Assert: ! IsNonNegativeInteger(_fromIndex_) is *true*.
1. Let _len_ be the length of _string_.
1. If _searchValue_ is the empty String and _fromIndex_ &le; _len_, return _fromIndex_.
1. Let _searchLen_ be the length of _searchValue_.
1. If there exists any integer _k_ such that _fromIndex_ &le; _k_ &le; _len_ - _searchLen_ and for all nonnegative integers _j_ less than _searchLen_, the code unit at index _k_ + _j_ within _string_ is the same as the code unit at index _j_ within _searchValue_, let _pos_ be the smallest (closest to *-&infin;*) such integer. Otherwise, let _pos_ be -1.
1. Return _pos_.
</emu-alg>
<emu-note>
<p>If _searchValue_ is empty and _fromIndex_ is less than or equal to the length of _string_, this algorithm returns _fromIndex_. An empty _searchValue_ is effectively found at every position within a string, including after the last code unit.</p>
</emu-note>
<emu-note>
<p>This algorithm always returns -1 if _fromIndex_ &gt; the length of _string_.</p>
</emu-note>
</emu-clause>

<emu-clause id="sec-types-of-source-code">
<h1>Types of Source Code</h1>
<p>There are four types of ECMAScript code:</p>
Expand Down