| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 var $regexpExec; | 5 var $regexpExec; |
| 6 var $regexpExecNoTests; | 6 var $regexpExecNoTests; |
| 7 var $regexpLastMatchInfo; | 7 var $regexpLastMatchInfo; |
| 8 var $regexpLastMatchInfoOverride; | 8 var $regexpLastMatchInfoOverride; |
| 9 var harmony_regexps = false; | 9 var harmony_regexps = false; |
| 10 var harmony_unicode_regexps = false; | 10 var harmony_unicode_regexps = false; |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 var matchInfo = %_RegExpExec(regexp, string, start, $regexpLastMatchInfo); | 138 var matchInfo = %_RegExpExec(regexp, string, start, $regexpLastMatchInfo); |
| 139 if (matchInfo !== null) { | 139 if (matchInfo !== null) { |
| 140 $regexpLastMatchInfoOverride = null; | 140 $regexpLastMatchInfoOverride = null; |
| 141 RETURN_NEW_RESULT_FROM_MATCH_INFO(matchInfo, string); | 141 RETURN_NEW_RESULT_FROM_MATCH_INFO(matchInfo, string); |
| 142 } | 142 } |
| 143 regexp.lastIndex = 0; | 143 regexp.lastIndex = 0; |
| 144 return null; | 144 return null; |
| 145 } | 145 } |
| 146 | 146 |
| 147 | 147 |
| 148 function RegExpExec(string) { | 148 function RegExpExecJS(string) { |
| 149 if (!IS_REGEXP(this)) { | 149 if (!IS_REGEXP(this)) { |
| 150 throw MakeTypeError('incompatible_method_receiver', | 150 throw MakeTypeError('incompatible_method_receiver', |
| 151 ['RegExp.prototype.exec', this]); | 151 ['RegExp.prototype.exec', this]); |
| 152 } | 152 } |
| 153 | 153 |
| 154 string = TO_STRING_INLINE(string); | 154 string = TO_STRING_INLINE(string); |
| 155 var lastIndex = this.lastIndex; | 155 var lastIndex = this.lastIndex; |
| 156 | 156 |
| 157 // Conversion is required by the ES5 specification (RegExp.prototype.exec | 157 // Conversion is required by the ES5 specification (RegExp.prototype.exec |
| 158 // algorithm, step 5) even if the value is discarded for non-global RegExps. | 158 // algorithm, step 5) even if the value is discarded for non-global RegExps. |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 } | 358 } |
| 359 | 359 |
| 360 // ------------------------------------------------------------------- | 360 // ------------------------------------------------------------------- |
| 361 | 361 |
| 362 %FunctionSetInstanceClassName(GlobalRegExp, 'RegExp'); | 362 %FunctionSetInstanceClassName(GlobalRegExp, 'RegExp'); |
| 363 %AddNamedProperty( | 363 %AddNamedProperty( |
| 364 GlobalRegExp.prototype, 'constructor', GlobalRegExp, DONT_ENUM); | 364 GlobalRegExp.prototype, 'constructor', GlobalRegExp, DONT_ENUM); |
| 365 %SetCode(GlobalRegExp, RegExpConstructor); | 365 %SetCode(GlobalRegExp, RegExpConstructor); |
| 366 | 366 |
| 367 InstallFunctions(GlobalRegExp.prototype, DONT_ENUM, GlobalArray( | 367 InstallFunctions(GlobalRegExp.prototype, DONT_ENUM, GlobalArray( |
| 368 "exec", RegExpExec, | 368 "exec", RegExpExecJS, |
| 369 "test", RegExpTest, | 369 "test", RegExpTest, |
| 370 "toString", RegExpToString, | 370 "toString", RegExpToString, |
| 371 "compile", RegExpCompileJS | 371 "compile", RegExpCompileJS |
| 372 )); | 372 )); |
| 373 | 373 |
| 374 // The length of compile is 1 in SpiderMonkey. | 374 // The length of compile is 1 in SpiderMonkey. |
| 375 %FunctionSetLength(GlobalRegExp.prototype.compile, 1); | 375 %FunctionSetLength(GlobalRegExp.prototype.compile, 1); |
| 376 | 376 |
| 377 // The properties `input` and `$_` are aliases for each other. When this | 377 // The properties `input` and `$_` are aliases for each other. When this |
| 378 // value is set the value it is set to is coerced to a string. | 378 // value is set the value it is set to is coerced to a string. |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 %DefineAccessorPropertyUnchecked(GlobalRegExp, '$' + i, | 437 %DefineAccessorPropertyUnchecked(GlobalRegExp, '$' + i, |
| 438 RegExpMakeCaptureGetter(i), NoOpSetter, | 438 RegExpMakeCaptureGetter(i), NoOpSetter, |
| 439 DONT_DELETE); | 439 DONT_DELETE); |
| 440 } | 440 } |
| 441 %ToFastProperties(GlobalRegExp); | 441 %ToFastProperties(GlobalRegExp); |
| 442 | 442 |
| 443 $regexpExecNoTests = RegExpExecNoTests; | 443 $regexpExecNoTests = RegExpExecNoTests; |
| 444 $regexpExec = DoRegExpExec; | 444 $regexpExec = DoRegExpExec; |
| 445 | 445 |
| 446 })(); | 446 })(); |
| OLD | NEW |