Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(343)

Side by Side Diff: src/regexp.js

Issue 9424033: Removed Runtime_DefineAccessor. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Incorporated review comments. Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/mips/full-codegen-mips.cc ('k') | src/runtime.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 %DefineAccessor($RegExp, 'input', GETTER, RegExpGetInput, DONT_DELETE); 424 %DefineOrRedefineAccessorProperty($RegExp, 'input', GETTER, RegExpGetInput,
425 %DefineAccessor($RegExp, 'input', SETTER, RegExpSetInput, DONT_DELETE); 425 DONT_DELETE);
426 %DefineAccessor($RegExp, '$_', GETTER, RegExpGetInput, 426 %DefineOrRedefineAccessorProperty($RegExp, 'input', SETTER, RegExpSetInput,
427 DONT_ENUM | DONT_DELETE); 427 DONT_DELETE);
428 %DefineAccessor($RegExp, '$_', SETTER, RegExpSetInput, 428 %DefineOrRedefineAccessorProperty($RegExp, '$_', GETTER, RegExpGetInput,
429 DONT_ENUM | DONT_DELETE); 429 DONT_ENUM | DONT_DELETE);
430 %DefineAccessor($RegExp, '$input', GETTER, RegExpGetInput, 430 %DefineOrRedefineAccessorProperty($RegExp, '$_', SETTER, RegExpSetInput,
431 DONT_ENUM | DONT_DELETE); 431 DONT_ENUM | DONT_DELETE);
432 %DefineAccessor($RegExp, '$input', SETTER, RegExpSetInput, 432 %DefineOrRedefineAccessorProperty($RegExp, '$input', GETTER, RegExpGetInput,
433 DONT_ENUM | DONT_DELETE); 433 DONT_ENUM | DONT_DELETE);
434 %DefineOrRedefineAccessorProperty($RegExp, '$input', SETTER, RegExpSetInput,
435 DONT_ENUM | DONT_DELETE);
434 436
435 // The properties multiline and $* are aliases for each other. When this 437 // The properties multiline and $* are aliases for each other. When this
436 // value is set in SpiderMonkey, the value it is set to is coerced to a 438 // value is set in SpiderMonkey, the value it is set to is coerced to a
437 // boolean. We mimic that behavior with a slight difference: in SpiderMonkey 439 // boolean. We mimic that behavior with a slight difference: in SpiderMonkey
438 // the value of the expression 'RegExp.multiline = null' (for instance) is the 440 // the value of the expression 'RegExp.multiline = null' (for instance) is the
439 // boolean false (i.e., the value after coercion), while in V8 it is the value 441 // boolean false (i.e., the value after coercion), while in V8 it is the value
440 // null (i.e., the value before coercion). 442 // null (i.e., the value before coercion).
441 443
442 // Getter and setter for multiline. 444 // Getter and setter for multiline.
443 var multiline = false; 445 var multiline = false;
444 var RegExpGetMultiline = function() { return multiline; }; 446 var RegExpGetMultiline = function() { return multiline; };
445 var RegExpSetMultiline = function(flag) { multiline = flag ? true : false; }; 447 var RegExpSetMultiline = function(flag) { multiline = flag ? true : false; };
446 448
447 %DefineAccessor($RegExp, 'multiline', GETTER, RegExpGetMultiline, 449 %DefineOrRedefineAccessorProperty($RegExp, 'multiline', GETTER,
448 DONT_DELETE); 450 RegExpGetMultiline, DONT_DELETE);
449 %DefineAccessor($RegExp, 'multiline', SETTER, RegExpSetMultiline, 451 %DefineOrRedefineAccessorProperty($RegExp, 'multiline', SETTER,
450 DONT_DELETE); 452 RegExpSetMultiline, DONT_DELETE);
451 %DefineAccessor($RegExp, '$*', GETTER, RegExpGetMultiline, 453 %DefineOrRedefineAccessorProperty($RegExp, '$*', GETTER, RegExpGetMultiline,
452 DONT_ENUM | DONT_DELETE); 454 DONT_ENUM | DONT_DELETE);
453 %DefineAccessor($RegExp, '$*', SETTER, RegExpSetMultiline, 455 %DefineOrRedefineAccessorProperty($RegExp, '$*', SETTER, RegExpSetMultiline,
454 DONT_ENUM | DONT_DELETE); 456 DONT_ENUM | DONT_DELETE);
455 457
456 458
457 var NoOpSetter = function(ignored) {}; 459 var NoOpSetter = function(ignored) {};
458 460
459 461
460 // Static properties set by a successful match. 462 // Static properties set by a successful match.
461 %DefineAccessor($RegExp, 'lastMatch', GETTER, RegExpGetLastMatch, 463 %DefineOrRedefineAccessorProperty($RegExp, 'lastMatch', GETTER,
462 DONT_DELETE); 464 RegExpGetLastMatch, DONT_DELETE);
463 %DefineAccessor($RegExp, 'lastMatch', SETTER, NoOpSetter, DONT_DELETE); 465 %DefineOrRedefineAccessorProperty($RegExp, 'lastMatch', SETTER, NoOpSetter,
464 %DefineAccessor($RegExp, '$&', GETTER, RegExpGetLastMatch, 466 DONT_DELETE);
465 DONT_ENUM | DONT_DELETE); 467 %DefineOrRedefineAccessorProperty($RegExp, '$&', GETTER, RegExpGetLastMatch,
466 %DefineAccessor($RegExp, '$&', SETTER, NoOpSetter, DONT_ENUM | DONT_DELETE); 468 DONT_ENUM | DONT_DELETE);
467 %DefineAccessor($RegExp, 'lastParen', GETTER, RegExpGetLastParen, 469 %DefineOrRedefineAccessorProperty($RegExp, '$&', SETTER, NoOpSetter,
468 DONT_DELETE); 470 DONT_ENUM | DONT_DELETE);
469 %DefineAccessor($RegExp, 'lastParen', SETTER, NoOpSetter, DONT_DELETE); 471 %DefineOrRedefineAccessorProperty($RegExp, 'lastParen', GETTER,
470 %DefineAccessor($RegExp, '$+', GETTER, RegExpGetLastParen, 472 RegExpGetLastParen, DONT_DELETE);
471 DONT_ENUM | DONT_DELETE); 473 %DefineOrRedefineAccessorProperty($RegExp, 'lastParen', SETTER, NoOpSetter,
472 %DefineAccessor($RegExp, '$+', SETTER, NoOpSetter, DONT_ENUM | DONT_DELETE); 474 DONT_DELETE);
473 %DefineAccessor($RegExp, 'leftContext', GETTER, RegExpGetLeftContext, 475 %DefineOrRedefineAccessorProperty($RegExp, '$+', GETTER, RegExpGetLastParen,
474 DONT_DELETE); 476 DONT_ENUM | DONT_DELETE);
475 %DefineAccessor($RegExp, 'leftContext', SETTER, NoOpSetter, DONT_DELETE); 477 %DefineOrRedefineAccessorProperty($RegExp, '$+', SETTER, NoOpSetter,
476 %DefineAccessor($RegExp, '$`', GETTER, RegExpGetLeftContext, 478 DONT_ENUM | DONT_DELETE);
477 DONT_ENUM | DONT_DELETE); 479 %DefineOrRedefineAccessorProperty($RegExp, 'leftContext', GETTER,
478 %DefineAccessor($RegExp, '$`', SETTER, NoOpSetter, DONT_ENUM | DONT_DELETE); 480 RegExpGetLeftContext, DONT_DELETE);
479 %DefineAccessor($RegExp, 'rightContext', GETTER, RegExpGetRightContext, 481 %DefineOrRedefineAccessorProperty($RegExp, 'leftContext', SETTER, NoOpSetter,
480 DONT_DELETE); 482 DONT_DELETE);
481 %DefineAccessor($RegExp, 'rightContext', SETTER, NoOpSetter, DONT_DELETE); 483 %DefineOrRedefineAccessorProperty($RegExp, '$`', GETTER, RegExpGetLeftContext,
482 %DefineAccessor($RegExp, "$'", GETTER, RegExpGetRightContext, 484 DONT_ENUM | DONT_DELETE);
483 DONT_ENUM | DONT_DELETE); 485 %DefineOrRedefineAccessorProperty($RegExp, '$`', SETTER, NoOpSetter,
484 %DefineAccessor($RegExp, "$'", SETTER, NoOpSetter, DONT_ENUM | DONT_DELETE); 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);
485 496
486 for (var i = 1; i < 10; ++i) { 497 for (var i = 1; i < 10; ++i) {
487 %DefineAccessor($RegExp, '$' + i, GETTER, RegExpMakeCaptureGetter(i), 498 %DefineOrRedefineAccessorProperty($RegExp, '$' + i, GETTER,
488 DONT_DELETE); 499 RegExpMakeCaptureGetter(i), DONT_DELETE);
489 %DefineAccessor($RegExp, '$' + i, SETTER, NoOpSetter, DONT_DELETE); 500 %DefineOrRedefineAccessorProperty($RegExp, '$' + i, SETTER, NoOpSetter,
501 DONT_DELETE);
490 } 502 }
491 } 503 }
492 504
493 SetUpRegExp(); 505 SetUpRegExp();
OLDNEW
« no previous file with comments | « src/mips/full-codegen-mips.cc ('k') | src/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698