| 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 $regexpLastMatchInfoOverride; | 5 var $regexpLastMatchInfoOverride; |
| 6 var harmony_regexps = false; | 6 var harmony_regexps = false; |
| 7 var harmony_unicode_regexps = false; | 7 var harmony_unicode_regexps = false; |
| 8 | 8 |
| 9 (function(global, utils) { | 9 (function(global, utils) { |
| 10 | 10 |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 | 147 |
| 148 function RegExpExecJS(string) { | 148 function RegExpExecJS(string) { |
| 149 if (!IS_REGEXP(this)) { | 149 if (!IS_REGEXP(this)) { |
| 150 throw MakeTypeError(kIncompatibleMethodReceiver, | 150 throw MakeTypeError(kIncompatibleMethodReceiver, |
| 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 ES6 specification (RegExpBuiltinExec | 157 // Conversion is required by the ES5 specification (RegExp.prototype.exec |
| 158 // algorithm, step 4) even if the value is discarded for non-global RegExps. | 158 // algorithm, step 5) even if the value is discarded for non-global RegExps. |
| 159 var i = $toLength(lastIndex); | 159 var i = TO_INTEGER(lastIndex); |
| 160 | 160 |
| 161 var updateLastIndex = this.global || (harmony_regexps && this.sticky); | 161 var updateLastIndex = this.global || (harmony_regexps && this.sticky); |
| 162 if (updateLastIndex) { | 162 if (updateLastIndex) { |
| 163 if (i < 0 || i > string.length) { | 163 if (i < 0 || i > string.length) { |
| 164 this.lastIndex = 0; | 164 this.lastIndex = 0; |
| 165 return null; | 165 return null; |
| 166 } | 166 } |
| 167 } else { | 167 } else { |
| 168 i = 0; | 168 i = 0; |
| 169 } | 169 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 195 // else implements. | 195 // else implements. |
| 196 function RegExpTest(string) { | 196 function RegExpTest(string) { |
| 197 if (!IS_REGEXP(this)) { | 197 if (!IS_REGEXP(this)) { |
| 198 throw MakeTypeError(kIncompatibleMethodReceiver, | 198 throw MakeTypeError(kIncompatibleMethodReceiver, |
| 199 'RegExp.prototype.test', this); | 199 'RegExp.prototype.test', this); |
| 200 } | 200 } |
| 201 string = TO_STRING_INLINE(string); | 201 string = TO_STRING_INLINE(string); |
| 202 | 202 |
| 203 var lastIndex = this.lastIndex; | 203 var lastIndex = this.lastIndex; |
| 204 | 204 |
| 205 // Conversion is required by the ES6 specification (RegExpBuiltinExec | 205 // Conversion is required by the ES5 specification (RegExp.prototype.exec |
| 206 // algorithm, step 4) even if the value is discarded for non-global RegExps. | 206 // algorithm, step 5) even if the value is discarded for non-global RegExps. |
| 207 var i = $toLength(lastIndex); | 207 var i = TO_INTEGER(lastIndex); |
| 208 | 208 |
| 209 if (this.global || (harmony_regexps && this.sticky)) { | 209 if (this.global || (harmony_regexps && this.sticky)) { |
| 210 if (i < 0 || i > string.length) { | 210 if (i < 0 || i > string.length) { |
| 211 this.lastIndex = 0; | 211 this.lastIndex = 0; |
| 212 return false; | 212 return false; |
| 213 } | 213 } |
| 214 // matchIndices is either null or the RegExpLastMatchInfo array. | 214 // matchIndices is either null or the RegExpLastMatchInfo array. |
| 215 var matchIndices = %_RegExpExec(this, string, i, RegExpLastMatchInfo); | 215 var matchIndices = %_RegExpExec(this, string, i, RegExpLastMatchInfo); |
| 216 if (IS_NULL(matchIndices)) { | 216 if (IS_NULL(matchIndices)) { |
| 217 this.lastIndex = 0; | 217 this.lastIndex = 0; |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 // Exports | 444 // Exports |
| 445 | 445 |
| 446 utils.Export(function(to) { | 446 utils.Export(function(to) { |
| 447 to.RegExpExec = DoRegExpExec; | 447 to.RegExpExec = DoRegExpExec; |
| 448 to.RegExpExecNoTests = RegExpExecNoTests; | 448 to.RegExpExecNoTests = RegExpExecNoTests; |
| 449 to.RegExpLastMatchInfo = RegExpLastMatchInfo; | 449 to.RegExpLastMatchInfo = RegExpLastMatchInfo; |
| 450 to.RegExpTest = RegExpTest; | 450 to.RegExpTest = RegExpTest; |
| 451 }); | 451 }); |
| 452 | 452 |
| 453 }) | 453 }) |
| OLD | NEW |