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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 } | 190 } |
191 | 191 |
192 var cache = regExpCache; | 192 var cache = regExpCache; |
193 var saveAnswer = false; | 193 var saveAnswer = false; |
194 | 194 |
195 if (%_ObjectEquals(cache.type, 'exec') && | 195 if (%_ObjectEquals(cache.type, 'exec') && |
196 %_ObjectEquals(cache.lastIndex, this.lastIndex) && | 196 %_ObjectEquals(cache.lastIndex, this.lastIndex) && |
197 %_ObjectEquals(cache.regExp, this) && | 197 %_ObjectEquals(cache.regExp, this) && |
198 %_ObjectEquals(cache.subject, string)) { | 198 %_ObjectEquals(cache.subject, string)) { |
199 if (cache.answerSaved) { | 199 if (cache.answerSaved) { |
| 200 if (this.global) this.lastIndex = 0; |
200 return CloneRegExpResult(cache.answer); | 201 return CloneRegExpResult(cache.answer); |
201 } else { | 202 } else { |
202 saveAnswer = true; | 203 saveAnswer = true; |
203 } | 204 } |
204 } | 205 } |
205 | 206 |
206 if (%_ArgumentsLength() == 0) { | 207 if (%_ArgumentsLength() == 0) { |
207 var regExpInput = LAST_INPUT(lastMatchInfo); | 208 var regExpInput = LAST_INPUT(lastMatchInfo); |
208 if (IS_UNDEFINED(regExpInput)) { | 209 if (IS_UNDEFINED(regExpInput)) { |
209 throw MakeError('no_input_to_regexp', [this]); | 210 throw MakeError('no_input_to_regexp', [this]); |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
537 %DefineAccessor($RegExp, "$'", SETTER, NoOpSetter, DONT_ENUM | DONT_DELETE); | 538 %DefineAccessor($RegExp, "$'", SETTER, NoOpSetter, DONT_ENUM | DONT_DELETE); |
538 | 539 |
539 for (var i = 1; i < 10; ++i) { | 540 for (var i = 1; i < 10; ++i) { |
540 %DefineAccessor($RegExp, '$' + i, GETTER, RegExpMakeCaptureGetter(i), DONT_D
ELETE); | 541 %DefineAccessor($RegExp, '$' + i, GETTER, RegExpMakeCaptureGetter(i), DONT_D
ELETE); |
541 %DefineAccessor($RegExp, '$' + i, SETTER, NoOpSetter, DONT_DELETE); | 542 %DefineAccessor($RegExp, '$' + i, SETTER, NoOpSetter, DONT_DELETE); |
542 } | 543 } |
543 } | 544 } |
544 | 545 |
545 | 546 |
546 SetupRegExp(); | 547 SetupRegExp(); |
OLD | NEW |