| OLD | NEW | 
|---|
| 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without | 
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are | 
| 4 // met: | 4 // met: | 
| 5 // | 5 // | 
| 6 //     * Redistributions of source code must retain the above copyright | 6 //     * Redistributions of source code must retain the above copyright | 
| 7 //       notice, this list of conditions and the following disclaimer. | 7 //       notice, this list of conditions and the following disclaimer. | 
| 8 //     * Redistributions in binary form must reproduce the above | 8 //     * Redistributions in binary form must reproduce the above | 
| 9 //       copyright notice, this list of conditions and the following | 9 //       copyright notice, this list of conditions and the following | 
| 10 //       disclaimer in the documentation and/or other materials provided | 10 //       disclaimer in the documentation and/or other materials provided | 
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 179   } | 179   } | 
| 180 | 180 | 
| 181   var cache = regExpCache; | 181   var cache = regExpCache; | 
| 182   var saveAnswer = false; | 182   var saveAnswer = false; | 
| 183 | 183 | 
| 184   if (%_ObjectEquals(cache.type, 'exec') && | 184   if (%_ObjectEquals(cache.type, 'exec') && | 
| 185       %_ObjectEquals(cache.lastIndex, this.lastIndex) && | 185       %_ObjectEquals(cache.lastIndex, this.lastIndex) && | 
| 186       %_IsRegExpEquivalent(cache.regExp, this) && | 186       %_IsRegExpEquivalent(cache.regExp, this) && | 
| 187       %_ObjectEquals(cache.subject, string)) { | 187       %_ObjectEquals(cache.subject, string)) { | 
| 188     if (cache.answerSaved) { | 188     if (cache.answerSaved) { | 
|  | 189       // If this regexp is not global, cache.lastIndex is zero, so we only get | 
|  | 190       // here if this.lastIndex is zero, and resulting this.lastIndex | 
|  | 191       // must be zero too, so no change is necessary. | 
|  | 192       if (this.global) this.lastIndex = lastMatchInfo[CAPTURE1]; | 
| 189       return %_RegExpCloneResult(cache.answer); | 193       return %_RegExpCloneResult(cache.answer); | 
| 190     } else { | 194     } else { | 
| 191       saveAnswer = true; | 195       saveAnswer = true; | 
| 192     } | 196     } | 
| 193   } | 197   } | 
| 194 | 198 | 
| 195   if (%_ArgumentsLength() == 0) { | 199   if (%_ArgumentsLength() == 0) { | 
| 196     var regExpInput = LAST_INPUT(lastMatchInfo); | 200     var regExpInput = LAST_INPUT(lastMatchInfo); | 
| 197     if (IS_UNDEFINED(regExpInput)) { | 201     if (IS_UNDEFINED(regExpInput)) { | 
| 198       throw MakeError('no_input_to_regexp', [this]); | 202       throw MakeError('no_input_to_regexp', [this]); | 
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 275   } else { | 279   } else { | 
| 276     s = ToString(string); | 280     s = ToString(string); | 
| 277   } | 281   } | 
| 278 | 282 | 
| 279   var lastIndex = this.lastIndex; | 283   var lastIndex = this.lastIndex; | 
| 280   var cache = regExpCache; | 284   var cache = regExpCache; | 
| 281   if (%_ObjectEquals(cache.type, 'test') && | 285   if (%_ObjectEquals(cache.type, 'test') && | 
| 282       %_IsRegExpEquivalent(cache.regExp, this) && | 286       %_IsRegExpEquivalent(cache.regExp, this) && | 
| 283       %_ObjectEquals(cache.subject, string) && | 287       %_ObjectEquals(cache.subject, string) && | 
| 284       %_ObjectEquals(cache.lastIndex, lastIndex)) { | 288       %_ObjectEquals(cache.lastIndex, lastIndex)) { | 
|  | 289     // If this regexp is not global, cache.lastIndex is zero, so we only get | 
|  | 290     // here if this.lastIndex is zero, and resulting this.lastIndex | 
|  | 291     // must be zero too, so no change is necessary. | 
|  | 292     if (this.global) this.lastIndex = lastMatchInfo[CAPTURE1]; | 
| 285     return cache.answer; | 293     return cache.answer; | 
| 286   } | 294   } | 
| 287 | 295 | 
| 288   // Remove irrelevant preceeding '.*' in a test regexp. The expression | 296   // Remove irrelevant preceeding '.*' in a test regexp. The expression | 
| 289   // checks whether this.source starts with '.*' and that the third | 297   // checks whether this.source starts with '.*' and that the third | 
| 290   // char is not a '?' | 298   // char is not a '?' | 
| 291   if (%_StringCharCodeAt(this.source,0) == 46 && // '.' | 299   if (%_StringCharCodeAt(this.source,0) == 46 && // '.' | 
| 292       %_StringCharCodeAt(this.source,1) == 42 && // '*' | 300       %_StringCharCodeAt(this.source,1) == 42 && // '*' | 
| 293       %_StringCharCodeAt(this.source,2) != 63) { // '?' | 301       %_StringCharCodeAt(this.source,2) != 63) { // '?' | 
| 294     if (!%_ObjectEquals(regexp_key, this)) { | 302     if (!%_ObjectEquals(regexp_key, this)) { | 
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 529   %DefineAccessor($RegExp, "$'", SETTER, NoOpSetter, DONT_ENUM | DONT_DELETE); | 537   %DefineAccessor($RegExp, "$'", SETTER, NoOpSetter, DONT_ENUM | DONT_DELETE); | 
| 530 | 538 | 
| 531   for (var i = 1; i < 10; ++i) { | 539   for (var i = 1; i < 10; ++i) { | 
| 532     %DefineAccessor($RegExp, '$' + i, GETTER, RegExpMakeCaptureGetter(i), DONT_D
     ELETE); | 540     %DefineAccessor($RegExp, '$' + i, GETTER, RegExpMakeCaptureGetter(i), DONT_D
     ELETE); | 
| 533     %DefineAccessor($RegExp, '$' + i, SETTER, NoOpSetter, DONT_DELETE); | 541     %DefineAccessor($RegExp, '$' + i, SETTER, NoOpSetter, DONT_DELETE); | 
| 534   } | 542   } | 
| 535 } | 543 } | 
| 536 | 544 | 
| 537 | 545 | 
| 538 SetupRegExp(); | 546 SetupRegExp(); | 
| OLD | NEW | 
|---|