diff --git a/spec.html b/spec.html index 0bff4f784e..1a32d1cbdd 100644 --- a/spec.html +++ b/spec.html @@ -982,6 +982,27 @@

The String Type

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.

In this specification, the phrase "the string-concatenation 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).

+ + +

Runtime Semantics: StringIndexOf ( _string_, _searchValue_, _fromIndex_ )

+

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:

+ + 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_ ≤ _len_, return _fromIndex_. + 1. Let _searchLen_ be the length of _searchValue_. + 1. If there exists any integer _k_ such that _fromIndex_ ≤ _k_ ≤ _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 *-∞*) such integer. Otherwise, let _pos_ be -1. + 1. Return _pos_. + + +

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.

+
+ +

This algorithm always returns -1 if _fromIndex_ > the length of _string_.

+
+
@@ -10456,27 +10477,6 @@

Static Semantics: UTF16DecodeString ( _string_ )

- -

Runtime Semantics: StringIndexOf ( _string_, _searchValue_, _fromIndex_ )

-

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:

- - 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_ ≤ _len_, return _fromIndex_. - 1. Let _searchLen_ be the length of _searchValue_. - 1. If there exists any integer _k_ such that _fromIndex_ ≤ _k_ ≤ _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 *-∞*) such integer. Otherwise, let _pos_ be -1. - 1. Return _pos_. - - -

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.

-
- -

This algorithm always returns -1 if _fromIndex_ > the length of _string_.

-
-
-

Types of Source Code

There are four types of ECMAScript code: