| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 flags = (pattern.global ? 'g' : '') | 48 flags = (pattern.global ? 'g' : '') |
| 49 + (pattern.ignoreCase ? 'i' : '') | 49 + (pattern.ignoreCase ? 'i' : '') |
| 50 + (pattern.multiline ? 'm' : ''); | 50 + (pattern.multiline ? 'm' : ''); |
| 51 if (harmony_unicode_regexps) | 51 if (harmony_unicode_regexps) |
| 52 flags += (pattern.unicode ? 'u' : ''); | 52 flags += (pattern.unicode ? 'u' : ''); |
| 53 if (harmony_regexps) | 53 if (harmony_regexps) |
| 54 flags += (pattern.sticky ? 'y' : ''); | 54 flags += (pattern.sticky ? 'y' : ''); |
| 55 pattern = pattern.source; | 55 pattern = pattern.source; |
| 56 } | 56 } |
| 57 | 57 |
| 58 pattern = IS_UNDEFINED(pattern) ? '' : $toString(pattern); | 58 pattern = IS_UNDEFINED(pattern) ? '' : ToString(pattern); |
| 59 flags = IS_UNDEFINED(flags) ? '' : $toString(flags); | 59 flags = IS_UNDEFINED(flags) ? '' : ToString(flags); |
| 60 | 60 |
| 61 %RegExpInitializeAndCompile(object, pattern, flags); | 61 %RegExpInitializeAndCompile(object, pattern, flags); |
| 62 } | 62 } |
| 63 | 63 |
| 64 | 64 |
| 65 function RegExpConstructor(pattern, flags) { | 65 function RegExpConstructor(pattern, flags) { |
| 66 if (%_IsConstructCall()) { | 66 if (%_IsConstructCall()) { |
| 67 DoConstructRegExp(this, pattern, flags); | 67 DoConstructRegExp(this, pattern, flags); |
| 68 } else { | 68 } else { |
| 69 // RegExp : Called as function; see ECMA-262, section 15.10.3.1. | 69 // RegExp : Called as function; see ECMA-262, section 15.10.3.1. |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 %FunctionSetLength(GlobalRegExp.prototype.compile, 1); | 374 %FunctionSetLength(GlobalRegExp.prototype.compile, 1); |
| 375 | 375 |
| 376 // The properties `input` and `$_` are aliases for each other. When this | 376 // The properties `input` and `$_` are aliases for each other. When this |
| 377 // value is set the value it is set to is coerced to a string. | 377 // value is set the value it is set to is coerced to a string. |
| 378 // Getter and setter for the input. | 378 // Getter and setter for the input. |
| 379 var RegExpGetInput = function() { | 379 var RegExpGetInput = function() { |
| 380 var regExpInput = LAST_INPUT($regexpLastMatchInfo); | 380 var regExpInput = LAST_INPUT($regexpLastMatchInfo); |
| 381 return IS_UNDEFINED(regExpInput) ? "" : regExpInput; | 381 return IS_UNDEFINED(regExpInput) ? "" : regExpInput; |
| 382 }; | 382 }; |
| 383 var RegExpSetInput = function(string) { | 383 var RegExpSetInput = function(string) { |
| 384 LAST_INPUT($regexpLastMatchInfo) = $toString(string); | 384 LAST_INPUT($regexpLastMatchInfo) = ToString(string); |
| 385 }; | 385 }; |
| 386 | 386 |
| 387 %OptimizeObjectForAddingMultipleProperties(GlobalRegExp, 22); | 387 %OptimizeObjectForAddingMultipleProperties(GlobalRegExp, 22); |
| 388 %DefineAccessorPropertyUnchecked(GlobalRegExp, 'input', RegExpGetInput, | 388 %DefineAccessorPropertyUnchecked(GlobalRegExp, 'input', RegExpGetInput, |
| 389 RegExpSetInput, DONT_DELETE); | 389 RegExpSetInput, DONT_DELETE); |
| 390 %DefineAccessorPropertyUnchecked(GlobalRegExp, '$_', RegExpGetInput, | 390 %DefineAccessorPropertyUnchecked(GlobalRegExp, '$_', RegExpGetInput, |
| 391 RegExpSetInput, DONT_ENUM | DONT_DELETE); | 391 RegExpSetInput, DONT_ENUM | DONT_DELETE); |
| 392 | 392 |
| 393 // The properties multiline and $* are aliases for each other. When this | 393 // The properties multiline and $* are aliases for each other. When this |
| 394 // value is set in SpiderMonkey, the value it is set to is coerced to a | 394 // value is set in SpiderMonkey, the value it is set to is coerced to a |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 %DefineAccessorPropertyUnchecked(GlobalRegExp, '$' + i, | 436 %DefineAccessorPropertyUnchecked(GlobalRegExp, '$' + i, |
| 437 RegExpMakeCaptureGetter(i), NoOpSetter, | 437 RegExpMakeCaptureGetter(i), NoOpSetter, |
| 438 DONT_DELETE); | 438 DONT_DELETE); |
| 439 } | 439 } |
| 440 %ToFastProperties(GlobalRegExp); | 440 %ToFastProperties(GlobalRegExp); |
| 441 | 441 |
| 442 $regexpExecNoTests = RegExpExecNoTests; | 442 $regexpExecNoTests = RegExpExecNoTests; |
| 443 $regexpExec = DoRegExpExec; | 443 $regexpExec = DoRegExpExec; |
| 444 | 444 |
| 445 })(); | 445 })(); |
| OLD | NEW |