| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 (function(global, utils) { | 5 (function(global, utils) { |
| 6 | 6 |
| 7 %CheckIsBootstrapping(); | 7 %CheckIsBootstrapping(); |
| 8 | 8 |
| 9 // ------------------------------------------------------------------- | 9 // ------------------------------------------------------------------- |
| 10 // Imports | 10 // Imports |
| (...skipping 979 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 990 pos = $toInteger(pos); | 990 pos = $toInteger(pos); |
| 991 } | 991 } |
| 992 | 992 |
| 993 var s_len = s.length; | 993 var s_len = s.length; |
| 994 var start = MathMin(MathMax(pos, 0), s_len); | 994 var start = MathMin(MathMax(pos, 0), s_len); |
| 995 var ss_len = ss.length; | 995 var ss_len = ss.length; |
| 996 if (ss_len + start > s_len) { | 996 if (ss_len + start > s_len) { |
| 997 return false; | 997 return false; |
| 998 } | 998 } |
| 999 | 999 |
| 1000 return %StringIndexOf(s, ss, start) === start; | 1000 return %_SubString(s, start, start + ss_len) === ss; |
| 1001 } | 1001 } |
| 1002 | 1002 |
| 1003 | 1003 |
| 1004 // ES6 draft 04-05-14, section 21.1.3.7 | 1004 // ES6 draft 04-05-14, section 21.1.3.7 |
| 1005 function StringEndsWith(searchString /* position */) { // length == 1 | 1005 function StringEndsWith(searchString /* position */) { // length == 1 |
| 1006 CHECK_OBJECT_COERCIBLE(this, "String.prototype.endsWith"); | 1006 CHECK_OBJECT_COERCIBLE(this, "String.prototype.endsWith"); |
| 1007 | 1007 |
| 1008 var s = TO_STRING_INLINE(this); | 1008 var s = TO_STRING_INLINE(this); |
| 1009 | 1009 |
| 1010 if (IS_REGEXP(searchString)) { | 1010 if (IS_REGEXP(searchString)) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1021 } | 1021 } |
| 1022 } | 1022 } |
| 1023 | 1023 |
| 1024 var end = MathMin(MathMax(pos, 0), s_len); | 1024 var end = MathMin(MathMax(pos, 0), s_len); |
| 1025 var ss_len = ss.length; | 1025 var ss_len = ss.length; |
| 1026 var start = end - ss_len; | 1026 var start = end - ss_len; |
| 1027 if (start < 0) { | 1027 if (start < 0) { |
| 1028 return false; | 1028 return false; |
| 1029 } | 1029 } |
| 1030 | 1030 |
| 1031 return %StringLastIndexOf(s, ss, start) === start; | 1031 return %_SubString(s, start, start + ss_len) === ss; |
| 1032 } | 1032 } |
| 1033 | 1033 |
| 1034 | 1034 |
| 1035 // ES6 draft 04-05-14, section 21.1.3.6 | 1035 // ES6 draft 04-05-14, section 21.1.3.6 |
| 1036 function StringIncludes(searchString /* position */) { // length == 1 | 1036 function StringIncludes(searchString /* position */) { // length == 1 |
| 1037 CHECK_OBJECT_COERCIBLE(this, "String.prototype.includes"); | 1037 CHECK_OBJECT_COERCIBLE(this, "String.prototype.includes"); |
| 1038 | 1038 |
| 1039 var string = TO_STRING_INLINE(this); | 1039 var string = TO_STRING_INLINE(this); |
| 1040 | 1040 |
| 1041 if (IS_REGEXP(searchString)) { | 1041 if (IS_REGEXP(searchString)) { |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1206 to.StringLastIndexOf = StringLastIndexOfJS; | 1206 to.StringLastIndexOf = StringLastIndexOfJS; |
| 1207 to.StringMatch = StringMatchJS; | 1207 to.StringMatch = StringMatchJS; |
| 1208 to.StringReplace = StringReplace; | 1208 to.StringReplace = StringReplace; |
| 1209 to.StringSlice = StringSlice; | 1209 to.StringSlice = StringSlice; |
| 1210 to.StringSplit = StringSplitJS; | 1210 to.StringSplit = StringSplitJS; |
| 1211 to.StringSubstr = StringSubstr; | 1211 to.StringSubstr = StringSubstr; |
| 1212 to.StringSubstring = StringSubstring; | 1212 to.StringSubstring = StringSubstring; |
| 1213 }); | 1213 }); |
| 1214 | 1214 |
| 1215 }) | 1215 }) |
| OLD | NEW |