| 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 // This file relies on the fact that the following declaration has been made | 5 // This file relies on the fact that the following declaration has been made |
| 6 // in runtime.js: | 6 // in runtime.js: |
| 7 // var $Object = global.Object; | 7 // var $Object = global.Object; |
| 8 // var $Array = global.Array; | 8 // var $Array = global.Array; |
| 9 | 9 |
| 10 var $RegExp = global.RegExp; | 10 var $RegExp = global.RegExp; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 return pattern; | 73 return pattern; |
| 74 } | 74 } |
| 75 return new $RegExp(pattern, flags); | 75 return new $RegExp(pattern, flags); |
| 76 } | 76 } |
| 77 } | 77 } |
| 78 | 78 |
| 79 // Deprecated RegExp.prototype.compile method. We behave like the constructor | 79 // Deprecated RegExp.prototype.compile method. We behave like the constructor |
| 80 // were called again. In SpiderMonkey, this method returns the regexp object. | 80 // were called again. In SpiderMonkey, this method returns the regexp object. |
| 81 // In JSC, it returns undefined. For compatibility with JSC, we match their | 81 // In JSC, it returns undefined. For compatibility with JSC, we match their |
| 82 // behavior. | 82 // behavior. |
| 83 function RegExpCompile(pattern, flags) { | 83 function RegExpCompileJS(pattern, flags) { |
| 84 // Both JSC and SpiderMonkey treat a missing pattern argument as the | 84 // Both JSC and SpiderMonkey treat a missing pattern argument as the |
| 85 // empty subject string, and an actual undefined value passed as the | 85 // empty subject string, and an actual undefined value passed as the |
| 86 // pattern as the string 'undefined'. Note that JSC is inconsistent | 86 // pattern as the string 'undefined'. Note that JSC is inconsistent |
| 87 // here, treating undefined values differently in | 87 // here, treating undefined values differently in |
| 88 // RegExp.prototype.compile and in the constructor, where they are | 88 // RegExp.prototype.compile and in the constructor, where they are |
| 89 // the empty string. For compatibility with JSC, we match their | 89 // the empty string. For compatibility with JSC, we match their |
| 90 // behavior. | 90 // behavior. |
| 91 if (this == $RegExp.prototype) { | 91 if (this == $RegExp.prototype) { |
| 92 // We don't allow recompiling RegExp.prototype. | 92 // We don't allow recompiling RegExp.prototype. |
| 93 throw MakeTypeError('incompatible_method_receiver', | 93 throw MakeTypeError('incompatible_method_receiver', |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 function SetUpRegExp() { | 374 function SetUpRegExp() { |
| 375 %CheckIsBootstrapping(); | 375 %CheckIsBootstrapping(); |
| 376 %FunctionSetInstanceClassName($RegExp, 'RegExp'); | 376 %FunctionSetInstanceClassName($RegExp, 'RegExp'); |
| 377 %SetProperty($RegExp.prototype, 'constructor', $RegExp, DONT_ENUM); | 377 %SetProperty($RegExp.prototype, 'constructor', $RegExp, DONT_ENUM); |
| 378 %SetCode($RegExp, RegExpConstructor); | 378 %SetCode($RegExp, RegExpConstructor); |
| 379 | 379 |
| 380 InstallFunctions($RegExp.prototype, DONT_ENUM, $Array( | 380 InstallFunctions($RegExp.prototype, DONT_ENUM, $Array( |
| 381 "exec", RegExpExec, | 381 "exec", RegExpExec, |
| 382 "test", RegExpTest, | 382 "test", RegExpTest, |
| 383 "toString", RegExpToString, | 383 "toString", RegExpToString, |
| 384 "compile", RegExpCompile | 384 "compile", RegExpCompileJS |
| 385 )); | 385 )); |
| 386 | 386 |
| 387 // The length of compile is 1 in SpiderMonkey. | 387 // The length of compile is 1 in SpiderMonkey. |
| 388 %FunctionSetLength($RegExp.prototype.compile, 1); | 388 %FunctionSetLength($RegExp.prototype.compile, 1); |
| 389 | 389 |
| 390 // The properties input, $input, and $_ are aliases for each other. When this | 390 // The properties input, $input, and $_ are aliases for each other. When this |
| 391 // value is set the value it is set to is coerced to a string. | 391 // value is set the value it is set to is coerced to a string. |
| 392 // Getter and setter for the input. | 392 // Getter and setter for the input. |
| 393 var RegExpGetInput = function() { | 393 var RegExpGetInput = function() { |
| 394 var regExpInput = LAST_INPUT(lastMatchInfo); | 394 var regExpInput = LAST_INPUT(lastMatchInfo); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 | 450 |
| 451 for (var i = 1; i < 10; ++i) { | 451 for (var i = 1; i < 10; ++i) { |
| 452 %DefineOrRedefineAccessorProperty($RegExp, '$' + i, | 452 %DefineOrRedefineAccessorProperty($RegExp, '$' + i, |
| 453 RegExpMakeCaptureGetter(i), NoOpSetter, | 453 RegExpMakeCaptureGetter(i), NoOpSetter, |
| 454 DONT_DELETE); | 454 DONT_DELETE); |
| 455 } | 455 } |
| 456 %ToFastProperties($RegExp); | 456 %ToFastProperties($RegExp); |
| 457 } | 457 } |
| 458 | 458 |
| 459 SetUpRegExp(); | 459 SetUpRegExp(); |
| OLD | NEW |