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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 | 159 |
160 if (%_ObjectEquals(cache.type, 'exec') && | 160 if (%_ObjectEquals(cache.type, 'exec') && |
161 %_ObjectEquals(cache.lastIndex, this.lastIndex) && | 161 %_ObjectEquals(cache.lastIndex, this.lastIndex) && |
162 %_ObjectEquals(cache.regExp, this) && | 162 %_ObjectEquals(cache.regExp, this) && |
163 %_ObjectEquals(cache.subject, string)) { | 163 %_ObjectEquals(cache.subject, string)) { |
164 if (cache.answerSaved) { | 164 if (cache.answerSaved) { |
165 return CloneRegexpAnswer(cache.answer); | 165 return CloneRegexpAnswer(cache.answer); |
166 } else { | 166 } else { |
167 saveAnswer = true; | 167 saveAnswer = true; |
168 } | 168 } |
169 } else { | |
170 cache.answerSaved = false; | |
171 } | 169 } |
172 | 170 |
173 if (%_ArgumentsLength() == 0) { | 171 if (%_ArgumentsLength() == 0) { |
174 var regExpInput = LAST_INPUT(lastMatchInfo); | 172 var regExpInput = LAST_INPUT(lastMatchInfo); |
175 if (IS_UNDEFINED(regExpInput)) { | 173 if (IS_UNDEFINED(regExpInput)) { |
176 throw MakeError('no_input_to_regexp', [this]); | 174 throw MakeError('no_input_to_regexp', [this]); |
177 } | 175 } |
178 string = regExpInput; | 176 string = regExpInput; |
179 } | 177 } |
180 var s; | 178 var s; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 } | 227 } |
230 | 228 |
231 result.index = lastMatchInfo[CAPTURE0]; | 229 result.index = lastMatchInfo[CAPTURE0]; |
232 result.input = s; | 230 result.input = s; |
233 if (this.global) { | 231 if (this.global) { |
234 this.lastIndex = lastMatchInfo[CAPTURE1]; | 232 this.lastIndex = lastMatchInfo[CAPTURE1]; |
235 } else { | 233 } else { |
236 cache.regExp = this; | 234 cache.regExp = this; |
237 cache.subject = s; | 235 cache.subject = s; |
238 cache.lastIndex = lastIndex; | 236 cache.lastIndex = lastIndex; |
239 if (saveAnswer) { | 237 if (saveAnswer) cache.answer = CloneRegexpAnswer(result); |
240 cache.answer = CloneRegexpAnswer(result); | 238 cache.answerSaved = saveAnswer; |
241 cache.answerSaved = true; | |
242 } | |
243 cache.type = 'exec'; | 239 cache.type = 'exec'; |
244 } | 240 } |
245 return result; | 241 return result; |
246 | 242 |
247 } | 243 } |
248 | 244 |
249 | 245 |
250 // Section 15.10.6.3 doesn't actually make sense, but the intention seems to be | 246 // Section 15.10.6.3 doesn't actually make sense, but the intention seems to be |
251 // that test is defined in terms of String.prototype.exec. However, it probably | 247 // that test is defined in terms of String.prototype.exec. However, it probably |
252 // means the original value of String.prototype.exec, which is what everybody | 248 // means the original value of String.prototype.exec, which is what everybody |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 %DefineAccessor($RegExp, "$'", SETTER, NoOpSetter, DONT_ENUM | DONT_DELETE); | 503 %DefineAccessor($RegExp, "$'", SETTER, NoOpSetter, DONT_ENUM | DONT_DELETE); |
508 | 504 |
509 for (var i = 1; i < 10; ++i) { | 505 for (var i = 1; i < 10; ++i) { |
510 %DefineAccessor($RegExp, '$' + i, GETTER, RegExpMakeCaptureGetter(i), DONT_D
ELETE); | 506 %DefineAccessor($RegExp, '$' + i, GETTER, RegExpMakeCaptureGetter(i), DONT_D
ELETE); |
511 %DefineAccessor($RegExp, '$' + i, SETTER, NoOpSetter, DONT_DELETE); | 507 %DefineAccessor($RegExp, '$' + i, SETTER, NoOpSetter, DONT_DELETE); |
512 } | 508 } |
513 } | 509 } |
514 | 510 |
515 | 511 |
516 SetupRegExp(); | 512 SetupRegExp(); |
OLD | NEW |