| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 | 199 |
| 200 // Successful match. | 200 // Successful match. |
| 201 lastMatchInfoOverride = null; | 201 lastMatchInfoOverride = null; |
| 202 if (global) { | 202 if (global) { |
| 203 this.lastIndex = lastMatchInfo[CAPTURE1]; | 203 this.lastIndex = lastMatchInfo[CAPTURE1]; |
| 204 } | 204 } |
| 205 return BuildResultFromMatchInfo(matchIndices, string); | 205 return BuildResultFromMatchInfo(matchIndices, string); |
| 206 } | 206 } |
| 207 | 207 |
| 208 | 208 |
| 209 function RegExpExecNoResult(string) { |
| 210 if (!IS_REGEXP(this)) { |
| 211 throw MakeTypeError('incompatible_method_receiver', |
| 212 ['RegExp.prototype.exec', this]); |
| 213 } |
| 214 |
| 215 if (%_ArgumentsLength() === 0) { |
| 216 var regExpInput = LAST_INPUT(lastMatchInfo); |
| 217 if (IS_UNDEFINED(regExpInput)) { |
| 218 throw MakeError('no_input_to_regexp', [this]); |
| 219 } |
| 220 string = regExpInput; |
| 221 } |
| 222 string = TO_STRING_INLINE(string); |
| 223 var lastIndex = this.lastIndex; |
| 224 |
| 225 // Conversion is required by the ES5 specification (RegExp.prototype.exec |
| 226 // algorithm, step 5) even if the value is discarded for non-global RegExps. |
| 227 var i = TO_INTEGER(lastIndex); |
| 228 |
| 229 var global = this.global; |
| 230 if (global) { |
| 231 if (i < 0 || i > string.length) { |
| 232 this.lastIndex = 0; |
| 233 return null; |
| 234 } |
| 235 } else { |
| 236 i = 0; |
| 237 } |
| 238 |
| 239 %_Log('regexp', 'regexp-exec,%0r,%1S,%2i', [this, string, lastIndex]); |
| 240 // matchIndices is either null or the lastMatchInfo array. |
| 241 var matchIndices = %_RegExpExec(this, string, i, lastMatchInfo); |
| 242 |
| 243 if (matchIndices === null) { |
| 244 if (global) this.lastIndex = 0; |
| 245 return null; |
| 246 } |
| 247 } |
| 248 |
| 249 |
| 209 // One-element cache for the simplified test regexp. | 250 // One-element cache for the simplified test regexp. |
| 210 var regexp_key; | 251 var regexp_key; |
| 211 var regexp_val; | 252 var regexp_val; |
| 212 | 253 |
| 213 // Section 15.10.6.3 doesn't actually make sense, but the intention seems to be | 254 // Section 15.10.6.3 doesn't actually make sense, but the intention seems to be |
| 214 // that test is defined in terms of String.prototype.exec. However, it probably | 255 // that test is defined in terms of String.prototype.exec. However, it probably |
| 215 // means the original value of String.prototype.exec, which is what everybody | 256 // means the original value of String.prototype.exec, which is what everybody |
| 216 // else implements. | 257 // else implements. |
| 217 function RegExpTest(string) { | 258 function RegExpTest(string) { |
| 218 if (!IS_REGEXP(this)) { | 259 if (!IS_REGEXP(this)) { |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 | 517 |
| 477 for (var i = 1; i < 10; ++i) { | 518 for (var i = 1; i < 10; ++i) { |
| 478 %DefineOrRedefineAccessorProperty($RegExp, '$' + i, | 519 %DefineOrRedefineAccessorProperty($RegExp, '$' + i, |
| 479 RegExpMakeCaptureGetter(i), NoOpSetter, | 520 RegExpMakeCaptureGetter(i), NoOpSetter, |
| 480 DONT_DELETE); | 521 DONT_DELETE); |
| 481 } | 522 } |
| 482 %ToFastProperties($RegExp); | 523 %ToFastProperties($RegExp); |
| 483 } | 524 } |
| 484 | 525 |
| 485 SetUpRegExp(); | 526 SetUpRegExp(); |
| OLD | NEW |