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

Side by Side Diff: src/v8natives.js

Issue 5861006: Change Object.defineProperty to accept undefined as getters and setters and t... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years 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
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 (!desc.hasValue() || 556 (!desc.hasValue() ||
557 SameValue(desc.getValue(), current.getValue())) && 557 SameValue(desc.getValue(), current.getValue())) &&
558 (!desc.hasGetter() || 558 (!desc.hasGetter() ||
559 SameValue(desc.getGet(), current.getGet())) && 559 SameValue(desc.getGet(), current.getGet())) &&
560 (!desc.hasSetter() || 560 (!desc.hasSetter() ||
561 SameValue(desc.getSet(), current.getSet()))) { 561 SameValue(desc.getSet(), current.getSet()))) {
562 return true; 562 return true;
563 } 563 }
564 564
565 // Step 7 565 // Step 7
566 if (desc.isConfigurable() || desc.isEnumerable() != current.isEnumerable()) 566 if (desc.isConfigurable() || desc.isEnumerable() != current.isEnumerable())
567 throw MakeTypeError("redefine_disallowed", ["defineProperty"]); 567 throw MakeTypeError("redefine_disallowed", ["defineProperty"]);
568 // Step 9 568 // Step 9
569 if (IsDataDescriptor(current) != IsDataDescriptor(desc)) 569 if (IsDataDescriptor(current) != IsDataDescriptor(desc))
570 throw MakeTypeError("redefine_disallowed", ["defineProperty"]); 570 throw MakeTypeError("redefine_disallowed", ["defineProperty"]);
571 // Step 10 571 // Step 10
572 if (IsDataDescriptor(current) && IsDataDescriptor(desc)) { 572 if (IsDataDescriptor(current) && IsDataDescriptor(desc)) {
573 if (!current.isWritable() && desc.isWritable()) 573 if (!current.isWritable() && desc.isWritable())
574 throw MakeTypeError("redefine_disallowed", ["defineProperty"]); 574 throw MakeTypeError("redefine_disallowed", ["defineProperty"]);
575 if (!current.isWritable() && desc.hasValue() && 575 if (!current.isWritable() && desc.hasValue() &&
576 !SameValue(desc.getValue(), current.getValue())) { 576 !SameValue(desc.getValue(), current.getValue())) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 flag |= READ_ONLY; 616 flag |= READ_ONLY;
617 } 617 }
618 var value = void 0; // Default value is undefined. 618 var value = void 0; // Default value is undefined.
619 if (desc.hasValue()) { 619 if (desc.hasValue()) {
620 value = desc.getValue(); 620 value = desc.getValue();
621 } else if (!IS_UNDEFINED(current)) { 621 } else if (!IS_UNDEFINED(current)) {
622 value = current.getValue(); 622 value = current.getValue();
623 } 623 }
624 %DefineOrRedefineDataProperty(obj, p, value, flag); 624 %DefineOrRedefineDataProperty(obj, p, value, flag);
625 } else { 625 } else {
626 if (desc.hasGetter() && IS_FUNCTION(desc.getGet())) { 626 if (desc.hasGetter() &&
Lasse Reichstein 2010/12/16 09:43:34 How about putting desc.getGet() in a variable (and
Rico 2010/12/16 12:17:55 Well, we don't know if desc has a getter, intuitiv
627 (IS_FUNCTION(desc.getGet()) || IS_UNDEFINED(desc.getGet()))) {
627 %DefineOrRedefineAccessorProperty(obj, p, GETTER, desc.getGet(), flag); 628 %DefineOrRedefineAccessorProperty(obj, p, GETTER, desc.getGet(), flag);
628 } 629 }
629 if (desc.hasSetter() && IS_FUNCTION(desc.getSet())) { 630 if (desc.hasSetter() &&
631 (IS_FUNCTION(desc.getSet()) || IS_UNDEFINED(desc.getSet()))) {
630 %DefineOrRedefineAccessorProperty(obj, p, SETTER, desc.getSet(), flag); 632 %DefineOrRedefineAccessorProperty(obj, p, SETTER, desc.getSet(), flag);
631 } 633 }
632 } 634 }
633 return true; 635 return true;
634 } 636 }
635 637
636 638
637 // ES5 section 15.2.3.2. 639 // ES5 section 15.2.3.2.
638 function ObjectGetPrototypeOf(obj) { 640 function ObjectGetPrototypeOf(obj) {
639 if (!IS_SPEC_OBJECT(obj)) 641 if (!IS_SPEC_OBJECT(obj))
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after
1193 // ---------------------------------------------------------------------------- 1195 // ----------------------------------------------------------------------------
1194 1196
1195 function SetupFunction() { 1197 function SetupFunction() {
1196 InstallFunctions($Function.prototype, DONT_ENUM, $Array( 1198 InstallFunctions($Function.prototype, DONT_ENUM, $Array(
1197 "bind", FunctionBind, 1199 "bind", FunctionBind,
1198 "toString", FunctionToString 1200 "toString", FunctionToString
1199 )); 1201 ));
1200 } 1202 }
1201 1203
1202 SetupFunction(); 1204 SetupFunction();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698