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