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 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
539 // overwrite it. | 539 // overwrite it. |
540 return result + %_SubString(subject, endOfMatch, subject.length); | 540 return result + %_SubString(subject, endOfMatch, subject.length); |
541 } | 541 } |
542 | 542 |
543 | 543 |
544 // ECMA-262 section 15.5.4.12 | 544 // ECMA-262 section 15.5.4.12 |
545 function StringSearch(re) { | 545 function StringSearch(re) { |
546 CHECK_OBJECT_COERCIBLE(this, "String.prototype.search"); | 546 CHECK_OBJECT_COERCIBLE(this, "String.prototype.search"); |
547 | 547 |
548 var regexp; | 548 var regexp; |
549 if (IS_STRING(re)) { | 549 if (IS_REGEXP(re)) { |
550 regexp = %_GetFromCache(STRING_TO_REGEXP_CACHE_ID, re); | |
551 } else if (IS_REGEXP(re)) { | |
552 regexp = re; | 550 regexp = re; |
553 } else { | 551 } else { |
554 regexp = new GlobalRegExp(re); | 552 regexp = new GlobalRegExp(re); |
555 } | 553 } |
556 var match = RegExpExec(regexp, TO_STRING_INLINE(this), 0); | 554 var match = RegExpExec(regexp, TO_STRING_INLINE(this), 0); |
557 if (match) { | 555 if (match) { |
558 return match[CAPTURE0]; | 556 return match[CAPTURE0]; |
559 } | 557 } |
560 return -1; | 558 return -1; |
561 } | 559 } |
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1200 to.StringIndexOf = StringIndexOfJS; | 1198 to.StringIndexOf = StringIndexOfJS; |
1201 to.StringLastIndexOf = StringLastIndexOfJS; | 1199 to.StringLastIndexOf = StringLastIndexOfJS; |
1202 to.StringMatch = StringMatchJS; | 1200 to.StringMatch = StringMatchJS; |
1203 to.StringReplace = StringReplace; | 1201 to.StringReplace = StringReplace; |
1204 to.StringSplit = StringSplitJS; | 1202 to.StringSplit = StringSplitJS; |
1205 to.StringSubstr = StringSubstr; | 1203 to.StringSubstr = StringSubstr; |
1206 to.StringSubstring = StringSubstring; | 1204 to.StringSubstring = StringSubstring; |
1207 }); | 1205 }); |
1208 | 1206 |
1209 }) | 1207 }) |
OLD | NEW |