Chromium Code Reviews| 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 |
| 11 | 11 |
| 12 var GlobalRegExp = global.RegExp; | 12 var GlobalRegExp = global.RegExp; |
| 13 var GlobalNumber = global.Number; | |
| 13 var GlobalString = global.String; | 14 var GlobalString = global.String; |
| 14 var InternalArray = utils.InternalArray; | 15 var InternalArray = utils.InternalArray; |
| 15 var InternalPackedArray = utils.InternalPackedArray; | 16 var InternalPackedArray = utils.InternalPackedArray; |
| 16 | 17 |
| 17 var ArrayIndexOf; | 18 var ArrayIndexOf; |
| 18 var ArrayJoin; | 19 var ArrayJoin; |
| 19 var MathMax; | 20 var MathMax; |
| 20 var MathMin; | 21 var MathMin; |
| 21 var RegExpExec; | 22 var RegExpExec; |
| 22 var RegExpExecNoTests; | 23 var RegExpExecNoTests; |
| (...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 601 | 602 |
| 602 return %_SubString(s, start_i, end_i); | 603 return %_SubString(s, start_i, end_i); |
| 603 } | 604 } |
| 604 | 605 |
| 605 | 606 |
| 606 // ECMA-262 section 15.5.4.14 | 607 // ECMA-262 section 15.5.4.14 |
| 607 function StringSplitJS(separator, limit) { | 608 function StringSplitJS(separator, limit) { |
| 608 CHECK_OBJECT_COERCIBLE(this, "String.prototype.split"); | 609 CHECK_OBJECT_COERCIBLE(this, "String.prototype.split"); |
| 609 | 610 |
| 610 var subject = TO_STRING_INLINE(this); | 611 var subject = TO_STRING_INLINE(this); |
| 611 limit = (IS_UNDEFINED(limit)) ? 0xffffffff : TO_UINT32(limit); | 612 limit = IS_UNDEFINED(limit) ? GlobalNumber.MAX_SAFE_INTEGER |
|
Dan Ehrenberg
2015/07/13 23:19:13
Defined this way, a user could modify Number.MAX_S
adamk
2015/07/14 00:16:48
MAX_SAFE_INTEGER is non-configurable, non-writable
| |
| 613 : $toLength(limit); | |
| 612 | 614 |
| 613 var length = subject.length; | 615 var length = subject.length; |
| 614 if (!IS_REGEXP(separator)) { | 616 if (!IS_REGEXP(separator)) { |
| 615 var separator_string = TO_STRING_INLINE(separator); | 617 var separator_string = TO_STRING_INLINE(separator); |
| 616 | 618 |
| 617 if (limit === 0) return []; | 619 if (limit === 0) return []; |
| 618 | 620 |
| 619 // ECMA-262 says that if separator is undefined, the result should | 621 // ECMA-262 says that if separator is undefined, the result should |
| 620 // be an array of size 1 containing the entire string. | 622 // be an array of size 1 containing the entire string. |
| 621 if (IS_UNDEFINED(separator)) return [subject]; | 623 if (IS_UNDEFINED(separator)) return [subject]; |
| (...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1198 to.StringIndexOf = StringIndexOfJS; | 1200 to.StringIndexOf = StringIndexOfJS; |
| 1199 to.StringLastIndexOf = StringLastIndexOfJS; | 1201 to.StringLastIndexOf = StringLastIndexOfJS; |
| 1200 to.StringMatch = StringMatchJS; | 1202 to.StringMatch = StringMatchJS; |
| 1201 to.StringReplace = StringReplace; | 1203 to.StringReplace = StringReplace; |
| 1202 to.StringSplit = StringSplitJS; | 1204 to.StringSplit = StringSplitJS; |
| 1203 to.StringSubstr = StringSubstr; | 1205 to.StringSubstr = StringSubstr; |
| 1204 to.StringSubstring = StringSubstring; | 1206 to.StringSubstring = StringSubstring; |
| 1205 }); | 1207 }); |
| 1206 | 1208 |
| 1207 }) | 1209 }) |
| OLD | NEW |