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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 return null; | 167 return null; |
168 } | 168 } |
169 | 169 |
170 | 170 |
171 function RegExpExec(string) { | 171 function RegExpExec(string) { |
172 if (!IS_REGEXP(this)) { | 172 if (!IS_REGEXP(this)) { |
173 throw MakeTypeError('incompatible_method_receiver', | 173 throw MakeTypeError('incompatible_method_receiver', |
174 ['RegExp.prototype.exec', this]); | 174 ['RegExp.prototype.exec', this]); |
175 } | 175 } |
176 | 176 |
177 if (%_ArgumentsLength() === 0) { | |
178 var regExpInput = LAST_INPUT(lastMatchInfo); | |
179 if (IS_UNDEFINED(regExpInput)) { | |
180 throw MakeError('no_input_to_regexp', [this]); | |
181 } | |
182 string = regExpInput; | |
183 } | |
184 string = TO_STRING_INLINE(string); | 177 string = TO_STRING_INLINE(string); |
185 var lastIndex = this.lastIndex; | 178 var lastIndex = this.lastIndex; |
186 | 179 |
187 // Conversion is required by the ES5 specification (RegExp.prototype.exec | 180 // Conversion is required by the ES5 specification (RegExp.prototype.exec |
188 // algorithm, step 5) even if the value is discarded for non-global RegExps. | 181 // algorithm, step 5) even if the value is discarded for non-global RegExps. |
189 var i = TO_INTEGER(lastIndex); | 182 var i = TO_INTEGER(lastIndex); |
190 | 183 |
191 var global = this.global; | 184 var global = this.global; |
192 if (global) { | 185 if (global) { |
193 if (i < 0 || i > string.length) { | 186 if (i < 0 || i > string.length) { |
(...skipping 28 matching lines...) Expand all Loading... |
222 | 215 |
223 // Section 15.10.6.3 doesn't actually make sense, but the intention seems to be | 216 // Section 15.10.6.3 doesn't actually make sense, but the intention seems to be |
224 // that test is defined in terms of String.prototype.exec. However, it probably | 217 // that test is defined in terms of String.prototype.exec. However, it probably |
225 // means the original value of String.prototype.exec, which is what everybody | 218 // means the original value of String.prototype.exec, which is what everybody |
226 // else implements. | 219 // else implements. |
227 function RegExpTest(string) { | 220 function RegExpTest(string) { |
228 if (!IS_REGEXP(this)) { | 221 if (!IS_REGEXP(this)) { |
229 throw MakeTypeError('incompatible_method_receiver', | 222 throw MakeTypeError('incompatible_method_receiver', |
230 ['RegExp.prototype.test', this]); | 223 ['RegExp.prototype.test', this]); |
231 } | 224 } |
232 if (%_ArgumentsLength() == 0) { | |
233 var regExpInput = LAST_INPUT(lastMatchInfo); | |
234 if (IS_UNDEFINED(regExpInput)) { | |
235 throw MakeError('no_input_to_regexp', [this]); | |
236 } | |
237 string = regExpInput; | |
238 } | |
239 | |
240 string = TO_STRING_INLINE(string); | 225 string = TO_STRING_INLINE(string); |
241 | 226 |
242 var lastIndex = this.lastIndex; | 227 var lastIndex = this.lastIndex; |
243 | 228 |
244 // Conversion is required by the ES5 specification (RegExp.prototype.exec | 229 // Conversion is required by the ES5 specification (RegExp.prototype.exec |
245 // algorithm, step 5) even if the value is discarded for non-global RegExps. | 230 // algorithm, step 5) even if the value is discarded for non-global RegExps. |
246 var i = TO_INTEGER(lastIndex); | 231 var i = TO_INTEGER(lastIndex); |
247 | 232 |
248 if (this.global) { | 233 if (this.global) { |
249 if (i < 0 || i > string.length) { | 234 if (i < 0 || i > string.length) { |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 %DefineAccessor($RegExp, "$'", GETTER, RegExpGetRightContext, DONT_ENUM | DONT
_DELETE); | 467 %DefineAccessor($RegExp, "$'", GETTER, RegExpGetRightContext, DONT_ENUM | DONT
_DELETE); |
483 %DefineAccessor($RegExp, "$'", SETTER, NoOpSetter, DONT_ENUM | DONT_DELETE); | 468 %DefineAccessor($RegExp, "$'", SETTER, NoOpSetter, DONT_ENUM | DONT_DELETE); |
484 | 469 |
485 for (var i = 1; i < 10; ++i) { | 470 for (var i = 1; i < 10; ++i) { |
486 %DefineAccessor($RegExp, '$' + i, GETTER, RegExpMakeCaptureGetter(i), DONT_D
ELETE); | 471 %DefineAccessor($RegExp, '$' + i, GETTER, RegExpMakeCaptureGetter(i), DONT_D
ELETE); |
487 %DefineAccessor($RegExp, '$' + i, SETTER, NoOpSetter, DONT_DELETE); | 472 %DefineAccessor($RegExp, '$' + i, SETTER, NoOpSetter, DONT_DELETE); |
488 } | 473 } |
489 } | 474 } |
490 | 475 |
491 SetUpRegExp(); | 476 SetUpRegExp(); |
OLD | NEW |