OLD | NEW |
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 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
579 (!desc.hasGetter() || | 579 (!desc.hasGetter() || |
580 SameValue(desc.getGet(), current.getGet())) && | 580 SameValue(desc.getGet(), current.getGet())) && |
581 (!desc.hasSetter() || | 581 (!desc.hasSetter() || |
582 SameValue(desc.getSet(), current.getSet()))) { | 582 SameValue(desc.getSet(), current.getSet()))) { |
583 return true; | 583 return true; |
584 } | 584 } |
585 if (!current.isConfigurable()) { | 585 if (!current.isConfigurable()) { |
586 // Step 7 | 586 // Step 7 |
587 if (desc.isConfigurable() || | 587 if (desc.isConfigurable() || |
588 (desc.hasEnumerable() && | 588 (desc.hasEnumerable() && |
589 desc.isEnumerable() != current.isEnumerable())) | 589 desc.isEnumerable() != current.isEnumerable())) { |
590 throw MakeTypeError("redefine_disallowed", ["defineProperty"]); | 590 throw MakeTypeError("redefine_disallowed", ["defineProperty"]); |
| 591 } |
591 // Step 8 | 592 // Step 8 |
592 if (!IsGenericDescriptor(desc)) { | 593 if (!IsGenericDescriptor(desc)) { |
593 // Step 9a | 594 // Step 9a |
594 if (IsDataDescriptor(current) != IsDataDescriptor(desc)) | 595 if (IsDataDescriptor(current) != IsDataDescriptor(desc)) { |
595 throw MakeTypeError("redefine_disallowed", ["defineProperty"]); | 596 throw MakeTypeError("redefine_disallowed", ["defineProperty"]); |
| 597 } |
596 // Step 10a | 598 // Step 10a |
597 if (IsDataDescriptor(current) && IsDataDescriptor(desc)) { | 599 if (IsDataDescriptor(current) && IsDataDescriptor(desc)) { |
598 if (!current.isWritable() && desc.isWritable()) | 600 if (!current.isWritable() && desc.isWritable()) { |
599 throw MakeTypeError("redefine_disallowed", ["defineProperty"]); | 601 throw MakeTypeError("redefine_disallowed", ["defineProperty"]); |
| 602 } |
600 if (!current.isWritable() && desc.hasValue() && | 603 if (!current.isWritable() && desc.hasValue() && |
601 !SameValue(desc.getValue(), current.getValue())) { | 604 !SameValue(desc.getValue(), current.getValue())) { |
602 throw MakeTypeError("redefine_disallowed", ["defineProperty"]); | 605 throw MakeTypeError("redefine_disallowed", ["defineProperty"]); |
603 } | 606 } |
604 } | 607 } |
605 // Step 11 | 608 // Step 11 |
606 if (IsAccessorDescriptor(desc) && IsAccessorDescriptor(current)) { | 609 if (IsAccessorDescriptor(desc) && IsAccessorDescriptor(current)) { |
607 if (desc.hasSetter() && !SameValue(desc.getSet(), current.getSet())){ | 610 if (desc.hasSetter() && !SameValue(desc.getSet(), current.getSet())) { |
608 throw MakeTypeError("redefine_disallowed", ["defineProperty"]); | 611 throw MakeTypeError("redefine_disallowed", ["defineProperty"]); |
609 } | 612 } |
610 if (desc.hasGetter() && !SameValue(desc.getGet(),current.getGet())) | 613 if (desc.hasGetter() && !SameValue(desc.getGet(),current.getGet())) { |
611 throw MakeTypeError("redefine_disallowed", ["defineProperty"]); | 614 throw MakeTypeError("redefine_disallowed", ["defineProperty"]); |
| 615 } |
612 } | 616 } |
613 } | 617 } |
614 } | 618 } |
615 } | 619 } |
616 | 620 |
617 // Send flags - enumerable and configurable are common - writable is | 621 // Send flags - enumerable and configurable are common - writable is |
618 // only send to the data descriptor. | 622 // only send to the data descriptor. |
619 // Take special care if enumerable and configurable is not defined on | 623 // Take special care if enumerable and configurable is not defined on |
620 // desc (we need to preserve the existing values from current). | 624 // desc (we need to preserve the existing values from current). |
621 var flag = NONE; | 625 var flag = NONE; |
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1239 // ---------------------------------------------------------------------------- | 1243 // ---------------------------------------------------------------------------- |
1240 | 1244 |
1241 function SetupFunction() { | 1245 function SetupFunction() { |
1242 InstallFunctions($Function.prototype, DONT_ENUM, $Array( | 1246 InstallFunctions($Function.prototype, DONT_ENUM, $Array( |
1243 "bind", FunctionBind, | 1247 "bind", FunctionBind, |
1244 "toString", FunctionToString | 1248 "toString", FunctionToString |
1245 )); | 1249 )); |
1246 } | 1250 } |
1247 | 1251 |
1248 SetupFunction(); | 1252 SetupFunction(); |
OLD | NEW |