| OLD | NEW |
| 1 // Copyright 2006-2009 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 |
| 11 // with the distribution. | 11 // with the distribution. |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 // value is set the value it is set to is coerced to a string. | 414 // value is set the value it is set to is coerced to a string. |
| 415 // Getter and setter for the input. | 415 // Getter and setter for the input. |
| 416 var RegExpGetInput = function() { | 416 var RegExpGetInput = function() { |
| 417 var regExpInput = LAST_INPUT(lastMatchInfo); | 417 var regExpInput = LAST_INPUT(lastMatchInfo); |
| 418 return IS_UNDEFINED(regExpInput) ? "" : regExpInput; | 418 return IS_UNDEFINED(regExpInput) ? "" : regExpInput; |
| 419 }; | 419 }; |
| 420 var RegExpSetInput = function(string) { | 420 var RegExpSetInput = function(string) { |
| 421 LAST_INPUT(lastMatchInfo) = ToString(string); | 421 LAST_INPUT(lastMatchInfo) = ToString(string); |
| 422 }; | 422 }; |
| 423 | 423 |
| 424 %DefineOrRedefineAccessorProperty($RegExp, 'input', GETTER, RegExpGetInput, | 424 %DefineOrRedefineAccessorProperty($RegExp, 'input', RegExpGetInput, |
| 425 DONT_DELETE); | 425 RegExpSetInput, DONT_DELETE); |
| 426 %DefineOrRedefineAccessorProperty($RegExp, 'input', SETTER, RegExpSetInput, | 426 %DefineOrRedefineAccessorProperty($RegExp, '$_', RegExpGetInput, |
| 427 DONT_DELETE); | 427 RegExpSetInput, DONT_ENUM | DONT_DELETE); |
| 428 %DefineOrRedefineAccessorProperty($RegExp, '$_', GETTER, RegExpGetInput, | 428 %DefineOrRedefineAccessorProperty($RegExp, '$input', RegExpGetInput, |
| 429 DONT_ENUM | DONT_DELETE); | 429 RegExpSetInput, DONT_ENUM | DONT_DELETE); |
| 430 %DefineOrRedefineAccessorProperty($RegExp, '$_', SETTER, RegExpSetInput, | |
| 431 DONT_ENUM | DONT_DELETE); | |
| 432 %DefineOrRedefineAccessorProperty($RegExp, '$input', GETTER, RegExpGetInput, | |
| 433 DONT_ENUM | DONT_DELETE); | |
| 434 %DefineOrRedefineAccessorProperty($RegExp, '$input', SETTER, RegExpSetInput, | |
| 435 DONT_ENUM | DONT_DELETE); | |
| 436 | 430 |
| 437 // The properties multiline and $* are aliases for each other. When this | 431 // The properties multiline and $* are aliases for each other. When this |
| 438 // value is set in SpiderMonkey, the value it is set to is coerced to a | 432 // value is set in SpiderMonkey, the value it is set to is coerced to a |
| 439 // boolean. We mimic that behavior with a slight difference: in SpiderMonkey | 433 // boolean. We mimic that behavior with a slight difference: in SpiderMonkey |
| 440 // the value of the expression 'RegExp.multiline = null' (for instance) is the | 434 // the value of the expression 'RegExp.multiline = null' (for instance) is the |
| 441 // boolean false (i.e., the value after coercion), while in V8 it is the value | 435 // boolean false (i.e., the value after coercion), while in V8 it is the value |
| 442 // null (i.e., the value before coercion). | 436 // null (i.e., the value before coercion). |
| 443 | 437 |
| 444 // Getter and setter for multiline. | 438 // Getter and setter for multiline. |
| 445 var multiline = false; | 439 var multiline = false; |
| 446 var RegExpGetMultiline = function() { return multiline; }; | 440 var RegExpGetMultiline = function() { return multiline; }; |
| 447 var RegExpSetMultiline = function(flag) { multiline = flag ? true : false; }; | 441 var RegExpSetMultiline = function(flag) { multiline = flag ? true : false; }; |
| 448 | 442 |
| 449 %DefineOrRedefineAccessorProperty($RegExp, 'multiline', GETTER, | 443 %DefineOrRedefineAccessorProperty($RegExp, 'multiline', RegExpGetMultiline, |
| 450 RegExpGetMultiline, DONT_DELETE); | |
| 451 %DefineOrRedefineAccessorProperty($RegExp, 'multiline', SETTER, | |
| 452 RegExpSetMultiline, DONT_DELETE); | 444 RegExpSetMultiline, DONT_DELETE); |
| 453 %DefineOrRedefineAccessorProperty($RegExp, '$*', GETTER, RegExpGetMultiline, | 445 %DefineOrRedefineAccessorProperty($RegExp, '$*', RegExpGetMultiline, |
| 454 DONT_ENUM | DONT_DELETE); | 446 RegExpSetMultiline, |
| 455 %DefineOrRedefineAccessorProperty($RegExp, '$*', SETTER, RegExpSetMultiline, | |
| 456 DONT_ENUM | DONT_DELETE); | 447 DONT_ENUM | DONT_DELETE); |
| 457 | 448 |
| 458 | 449 |
| 459 var NoOpSetter = function(ignored) {}; | 450 var NoOpSetter = function(ignored) {}; |
| 460 | 451 |
| 461 | 452 |
| 462 // Static properties set by a successful match. | 453 // Static properties set by a successful match. |
| 463 %DefineOrRedefineAccessorProperty($RegExp, 'lastMatch', GETTER, | 454 %DefineOrRedefineAccessorProperty($RegExp, 'lastMatch', RegExpGetLastMatch, |
| 464 RegExpGetLastMatch, DONT_DELETE); | 455 NoOpSetter, DONT_DELETE); |
| 465 %DefineOrRedefineAccessorProperty($RegExp, 'lastMatch', SETTER, NoOpSetter, | 456 %DefineOrRedefineAccessorProperty($RegExp, '$&', RegExpGetLastMatch, |
| 457 NoOpSetter, DONT_ENUM | DONT_DELETE); |
| 458 %DefineOrRedefineAccessorProperty($RegExp, 'lastParen', RegExpGetLastParen, |
| 459 NoOpSetter, DONT_DELETE); |
| 460 %DefineOrRedefineAccessorProperty($RegExp, '$+', RegExpGetLastParen, |
| 461 NoOpSetter, DONT_ENUM | DONT_DELETE); |
| 462 %DefineOrRedefineAccessorProperty($RegExp, 'leftContext', |
| 463 RegExpGetLeftContext, NoOpSetter, |
| 466 DONT_DELETE); | 464 DONT_DELETE); |
| 467 %DefineOrRedefineAccessorProperty($RegExp, '$&', GETTER, RegExpGetLastMatch, | 465 %DefineOrRedefineAccessorProperty($RegExp, '$`', RegExpGetLeftContext, |
| 468 DONT_ENUM | DONT_DELETE); | 466 NoOpSetter, DONT_ENUM | DONT_DELETE); |
| 469 %DefineOrRedefineAccessorProperty($RegExp, '$&', SETTER, NoOpSetter, | 467 %DefineOrRedefineAccessorProperty($RegExp, 'rightContext', |
| 470 DONT_ENUM | DONT_DELETE); | 468 RegExpGetRightContext, NoOpSetter, |
| 471 %DefineOrRedefineAccessorProperty($RegExp, 'lastParen', GETTER, | |
| 472 RegExpGetLastParen, DONT_DELETE); | |
| 473 %DefineOrRedefineAccessorProperty($RegExp, 'lastParen', SETTER, NoOpSetter, | |
| 474 DONT_DELETE); | 469 DONT_DELETE); |
| 475 %DefineOrRedefineAccessorProperty($RegExp, '$+', GETTER, RegExpGetLastParen, | 470 %DefineOrRedefineAccessorProperty($RegExp, "$'", RegExpGetRightContext, |
| 476 DONT_ENUM | DONT_DELETE); | 471 NoOpSetter, DONT_ENUM | DONT_DELETE); |
| 477 %DefineOrRedefineAccessorProperty($RegExp, '$+', SETTER, NoOpSetter, | |
| 478 DONT_ENUM | DONT_DELETE); | |
| 479 %DefineOrRedefineAccessorProperty($RegExp, 'leftContext', GETTER, | |
| 480 RegExpGetLeftContext, DONT_DELETE); | |
| 481 %DefineOrRedefineAccessorProperty($RegExp, 'leftContext', SETTER, NoOpSetter, | |
| 482 DONT_DELETE); | |
| 483 %DefineOrRedefineAccessorProperty($RegExp, '$`', GETTER, RegExpGetLeftContext, | |
| 484 DONT_ENUM | DONT_DELETE); | |
| 485 %DefineOrRedefineAccessorProperty($RegExp, '$`', SETTER, NoOpSetter, | |
| 486 DONT_ENUM | DONT_DELETE); | |
| 487 %DefineOrRedefineAccessorProperty($RegExp, 'rightContext', GETTER, | |
| 488 RegExpGetRightContext, DONT_DELETE); | |
| 489 %DefineOrRedefineAccessorProperty($RegExp, 'rightContext', SETTER, NoOpSetter, | |
| 490 DONT_DELETE); | |
| 491 %DefineOrRedefineAccessorProperty($RegExp, "$'", GETTER, | |
| 492 RegExpGetRightContext, | |
| 493 DONT_ENUM | DONT_DELETE); | |
| 494 %DefineOrRedefineAccessorProperty($RegExp, "$'", SETTER, NoOpSetter, | |
| 495 DONT_ENUM | DONT_DELETE); | |
| 496 | 472 |
| 497 for (var i = 1; i < 10; ++i) { | 473 for (var i = 1; i < 10; ++i) { |
| 498 %DefineOrRedefineAccessorProperty($RegExp, '$' + i, GETTER, | 474 %DefineOrRedefineAccessorProperty($RegExp, '$' + i, |
| 499 RegExpMakeCaptureGetter(i), DONT_DELETE); | 475 RegExpMakeCaptureGetter(i), NoOpSetter, |
| 500 %DefineOrRedefineAccessorProperty($RegExp, '$' + i, SETTER, NoOpSetter, | |
| 501 DONT_DELETE); | 476 DONT_DELETE); |
| 502 } | 477 } |
| 503 } | 478 } |
| 504 | 479 |
| 505 SetUpRegExp(); | 480 SetUpRegExp(); |
| OLD | NEW |