| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 'use strict'; | 5 'use strict'; |
| 6 | 6 |
| 7 // This file relies on the fact that the following declaration has been made | 7 // This file relies on the fact that the following declaration has been made |
| 8 // in runtime.js: | 8 // in runtime.js: |
| 9 // var $String = global.String; | 9 // var $String = global.String; |
| 10 // var $Array = global.Array; | 10 // var $Array = global.Array; |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 var start = end - ss_len; | 88 var start = end - ss_len; |
| 89 if (start < 0) { | 89 if (start < 0) { |
| 90 return false; | 90 return false; |
| 91 } | 91 } |
| 92 | 92 |
| 93 return %StringLastIndexOf(s, ss, start) === start; | 93 return %StringLastIndexOf(s, ss, start) === start; |
| 94 } | 94 } |
| 95 | 95 |
| 96 | 96 |
| 97 // ES6 draft 04-05-14, section 21.1.3.6 | 97 // ES6 draft 04-05-14, section 21.1.3.6 |
| 98 function StringIncludes(searchString /* position */) { // length == 1 | 98 function StringContains(searchString /* position */) { // length == 1 |
| 99 CHECK_OBJECT_COERCIBLE(this, "String.prototype.includes"); | 99 CHECK_OBJECT_COERCIBLE(this, "String.prototype.contains"); |
| 100 | 100 |
| 101 var s = TO_STRING_INLINE(this); | 101 var s = TO_STRING_INLINE(this); |
| 102 | 102 |
| 103 if (IS_REGEXP(searchString)) { | 103 if (IS_REGEXP(searchString)) { |
| 104 throw MakeTypeError("first_argument_not_regexp", | 104 throw MakeTypeError("first_argument_not_regexp", |
| 105 ["String.prototype.includes"]); | 105 ["String.prototype.contains"]); |
| 106 } | 106 } |
| 107 | 107 |
| 108 var ss = TO_STRING_INLINE(searchString); | 108 var ss = TO_STRING_INLINE(searchString); |
| 109 var pos = 0; | 109 var pos = 0; |
| 110 if (%_ArgumentsLength() > 1) { | 110 if (%_ArgumentsLength() > 1) { |
| 111 pos = %_Arguments(1); // position | 111 pos = %_Arguments(1); // position |
| 112 pos = ToInteger(pos); | 112 pos = ToInteger(pos); |
| 113 } | 113 } |
| 114 | 114 |
| 115 var s_len = s.length; | 115 var s_len = s.length; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 %CheckIsBootstrapping(); | 177 %CheckIsBootstrapping(); |
| 178 | 178 |
| 179 // Set up the non-enumerable functions on the String object. | 179 // Set up the non-enumerable functions on the String object. |
| 180 InstallFunctions($String, DONT_ENUM, $Array( | 180 InstallFunctions($String, DONT_ENUM, $Array( |
| 181 "fromCodePoint", StringFromCodePoint | 181 "fromCodePoint", StringFromCodePoint |
| 182 )); | 182 )); |
| 183 | 183 |
| 184 // Set up the non-enumerable functions on the String prototype object. | 184 // Set up the non-enumerable functions on the String prototype object. |
| 185 InstallFunctions($String.prototype, DONT_ENUM, $Array( | 185 InstallFunctions($String.prototype, DONT_ENUM, $Array( |
| 186 "codePointAt", StringCodePointAt, | 186 "codePointAt", StringCodePointAt, |
| 187 "includes", StringIncludes, | 187 "contains", StringContains, |
| 188 "endsWith", StringEndsWith, | 188 "endsWith", StringEndsWith, |
| 189 "repeat", StringRepeat, | 189 "repeat", StringRepeat, |
| 190 "startsWith", StringStartsWith | 190 "startsWith", StringStartsWith |
| 191 )); | 191 )); |
| 192 } | 192 } |
| 193 | 193 |
| 194 ExtendStringPrototype(); | 194 ExtendStringPrototype(); |
| OLD | NEW |