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 | 189 // If this regexp is global, cache.lastIndex is zero, so we only get |
190 // here if this.lastIndex is zero, and resulting this.lastIndex | 190 // here if this.lastIndex is zero, and resulting this.lastIndex |
191 // must be zero too, so no change is necessary. | 191 // must be zero too, so no change is necessary. |
192 if (this.global) this.lastIndex = lastMatchInfo[CAPTURE1]; | 192 if (!this.global) this.lastIndex = lastMatchInfo[CAPTURE1]; |
193 return %_RegExpCloneResult(cache.answer); | 193 return %_RegExpCloneResult(cache.answer); |
194 } else { | 194 } else { |
195 saveAnswer = true; | 195 saveAnswer = true; |
196 } | 196 } |
197 } | 197 } |
198 | 198 |
199 if (%_ArgumentsLength() == 0) { | 199 if (%_ArgumentsLength() == 0) { |
200 var regExpInput = LAST_INPUT(lastMatchInfo); | 200 var regExpInput = LAST_INPUT(lastMatchInfo); |
201 if (IS_UNDEFINED(regExpInput)) { | 201 if (IS_UNDEFINED(regExpInput)) { |
202 throw MakeError('no_input_to_regexp', [this]); | 202 throw MakeError('no_input_to_regexp', [this]); |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
537 %DefineAccessor($RegExp, "$'", SETTER, NoOpSetter, DONT_ENUM | DONT_DELETE); | 537 %DefineAccessor($RegExp, "$'", SETTER, NoOpSetter, DONT_ENUM | DONT_DELETE); |
538 | 538 |
539 for (var i = 1; i < 10; ++i) { | 539 for (var i = 1; i < 10; ++i) { |
540 %DefineAccessor($RegExp, '$' + i, GETTER, RegExpMakeCaptureGetter(i), DONT_D
ELETE); | 540 %DefineAccessor($RegExp, '$' + i, GETTER, RegExpMakeCaptureGetter(i), DONT_D
ELETE); |
541 %DefineAccessor($RegExp, '$' + i, SETTER, NoOpSetter, DONT_DELETE); | 541 %DefineAccessor($RegExp, '$' + i, SETTER, NoOpSetter, DONT_DELETE); |
542 } | 542 } |
543 } | 543 } |
544 | 544 |
545 | 545 |
546 SetupRegExp(); | 546 SetupRegExp(); |
OLD | NEW |