Commit 166c9077 authored by barraclough@apple.com's avatar barraclough@apple.com

https://bugs.webkit.org/show_bug.cgi?id=75789

defineOwnProperty not implemented for Array objects

Reviewed by Sam Weinig.

Source/JavaScriptCore: 

Implements support for getter/setter & non-default attribute properties on arrays,
by forcing them into a dictionary-like 'SparseMode'. This fixes ~300 test-262
test failures.

* JavaScriptCore.exp:
    - Updated exports.
* dfg/DFGOperations.cpp:
    - JSArray::pop now requires an exec state.
* runtime/ArrayPrototype.cpp:
(JSC::arrayProtoFuncPop):
    - JSArray::pop now requires an exec state.
* runtime/JSArray.cpp:
(JSC::SparseArrayValueMap::add):
    - Add a potentially empty entry into the map.
(JSC::SparseArrayValueMap::put):
    - Changed to call setter.
(JSC::SparseArrayEntry::get):
    - calls getters.
(JSC::SparseArrayEntry::getNonSparseMode):
    - does not call getters.
(JSC::JSArray::enterSparseMode):
    - Convert into 'SparseMode' - removes the vectors, don't allow it to be recreated.
(JSC::JSArray::putDescriptor):
    - Create a numeric property based on a descriptor.
(JSC::sameValue):
    - See ES5.1 9.12.
(JSC::reject):
    - Helper for the [[DefineOwnProperty]] algorithm.
(JSC::JSArray::defineOwnNumericProperty):
    - Define an indexed property on an array object.
(JSC::JSArray::setLengthWritable):
    - Marks the length read-only, enters SparseMode as necessary.
(JSC::JSArray::defineOwnProperty):
    - Defines either an indexed property or 'length' on an array object.
(JSC::JSArray::getOwnPropertySlotByIndex):
    - Updated to correctly handle accessor descriptors & attributes.
(JSC::JSArray::getOwnPropertyDescriptor):
    - Updated to correctly handle accessor descriptors & attributes.
(JSC::JSArray::put):
    - Pass strict mode flag to setLength.
(JSC::JSArray::putByIndex):
    - putByIndexBeyondVectorLength requires an ExecState* rather than a JSGloablData&.
(JSC::JSArray::putByIndexBeyondVectorLength):
    - Pass exec to SparseArrayValueMap::put.
(JSC::JSArray::deletePropertyByIndex):
    - Do not allow deletion of non-configurable properties.
(JSC::compareKeysForQSort):
    - used in implementation of getOwnPropertyNames.
(JSC::JSArray::getOwnPropertyNames):
    - Properties in the sparse map should be iterated in order.
(JSC::JSArray::setLength):
    - Updated to take a 'shouldThrow' flag, return a result indicating error.
(JSC::JSArray::pop):
    - pop should throw an error if length is not writable, even if the array is empty.
(JSC::JSArray::push):
    - putByIndexBeyondVectorLength requires an ExecState* rather than a JSGloablData&.
(JSC::JSArray::sort):
    - Changed 'get' to 'getNonSparseMode' (can't be getters to call).
(JSC::JSArray::compactForSorting):
    - Changed 'get' to 'getNonSparseMode' (can't be getters to call).
* runtime/JSArray.h:
(JSC::SparseArrayValueMap::lengthIsReadOnly):
    - Check if the length is read only.
(JSC::SparseArrayValueMap::setLengthIsReadOnly):
    - Mark the length as read only.
(JSC::SparseArrayValueMap::find):
    - Moved into header.
(JSC::JSArray::isLengthWritable):
    - Wraps SparseArrayValueMap::lengthIsReadOnly.
* runtime/JSObject.cpp:
(JSC::JSObject::defineOwnProperty):
    - Should be returning the result of putDescriptor.
* runtime/PropertyDescriptor.cpp:
(JSC::PropertyDescriptor::attributesOverridingCurrent):
    - Added attributesOverridingCurrent - this should probably be merged with attributesWithOverride.
* runtime/PropertyDescriptor.h:
    - Added attributesOverridingCurrent.

LayoutTests: 

* fast/js/array-defineOwnProperty-expected.txt: Added.
* fast/js/array-defineOwnProperty.html: Added.
* fast/js/script-tests/array-defineOwnProperty.js: Added.
    - Added tests for array properties with accessors & non-defulat attributes.
* fast/js/mozilla/strict/15.4.4.6-expected.txt:
* fast/js/mozilla/strict/8.12.5-expected.txt:
* ietestcenter/Javascript/15.4.4.14-9-a-12-expected.txt:
* ietestcenter/Javascript/15.4.4.15-8-a-12-expected.txt:
    - Check in passing results.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@104488 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 63d6700c
2012-01-09 Gavin Barraclough <barraclough@apple.com>
https://bugs.webkit.org/show_bug.cgi?id=75789
defineOwnProperty not implemented for Array objects
Reviewed by Sam Weinig.
* fast/js/array-defineOwnProperty-expected.txt: Added.
* fast/js/array-defineOwnProperty.html: Added.
* fast/js/script-tests/array-defineOwnProperty.js: Added.
- Added tests for array properties with accessors & non-defulat attributes.
* fast/js/mozilla/strict/15.4.4.6-expected.txt:
* fast/js/mozilla/strict/8.12.5-expected.txt:
* ietestcenter/Javascript/15.4.4.14-9-a-12-expected.txt:
* ietestcenter/Javascript/15.4.4.15-8-a-12-expected.txt:
- Check in passing results.
2012-01-09 Tom Sepez <tsepez@chromium.org>
Treat code="" attribute in embed tags similarly to applet tags.
......@@ -58652,7 +58669,7 @@
[Chromium] Layout Test compositing/video-page-visibility.html is failing on GPU linux
https://bugs.webkit.org/show_bug.cgi?id=68882
Unreviewed rebaseline.
Unreviewed rebaseline.
* platform/chromium-gpu-linux/compositing/video-page-visibility-expected.png: Added.
* platform/chromium/test_expectations.txt:
......@@ -59207,11 +59224,11 @@
Reviewed by Sam Weinig.
Update Mac results to use the new repaint rects. Differences from old results:
* There are no longer invalidates from scrolling.
* We no longer see the effects of AppKit rect coalescing.
* Composting tests show the overlay now, but repaints in compositing layers do not show.
Bad results in a couple of tests are covered by bugs 68830 and 68829.
* There are no longer invalidates from scrolling.
* We no longer see the effects of AppKit rect coalescing.
* Composting tests show the overlay now, but repaints in compositing layers do not show.
Bad results in a couple of tests are covered by bugs 68830 and 68829.
* platform/mac/fast/repaint/4774354-expected.png:
* platform/mac/fast/repaint/block-layout-inline-children-float-positioned-expected.png:
......@@ -61786,7 +61803,7 @@ gh@apple.com>
2011-09-19 Dmitry Lomov <dslomov@google.com>
[Chromium] Rebaseline expectations due to r95402.
[Chromium] Rebaseline expectations due to r95402.
* platform/chromium-win-vista/fast/dom/navigator-detached-no-crash-expected.txt: Removed.
This test checks the behavior of [[DefineOwnProperty]] applied to Array objects (see ES5.1 15.4.5.1).
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS Object.defineProperty([], 'x', { get:function(){return true;} }).x is true
PASS Object.defineProperty([], 'length', { value: 1 }).length is 1
PASS var a = Object.defineProperty([], 'length', { writable: false }); a[1] = 1; a.length is 0
PASS Object.defineProperty([], 'length', { get:function(){return true;} }) threw exception TypeError: Attempting to change access mechanism for an unconfigurable property..
PASS Object.defineProperty([], 'length', { enumerable: true }) threw exception TypeError: Attempting to change enumerable attribute of unconfigurable property..
PASS Object.defineProperty([], 'length', { configurable: true }) threw exception TypeError: Attempting to change configurable attribute of unconfigurable property..
PASS Object.defineProperty(Object.defineProperty([], 'length', { writable: false }), 'length', { writable: true }) threw exception TypeError: Attempting to change writable attribute of unconfigurable property..
PASS var a = Object.defineProperty([], '0', { value: 42 }); a[0] is 42
PASS var a = Object.defineProperty([42], '0', { writable: false }); a[0] = 1; a[0] is 42
PASS var a = Object.defineProperty([42], '0', { enumerable: false }); a[0] + Object.keys(a).length is 42
FAIL var a = Object.defineProperty([42], '0', { configurable: false }); a.length = 0; a[0] should be 42 (of type number). Was undefined (of type undefined).
PASS var foo = 0; Object.defineProperty([], '0', { set:function(x){foo = x;} })[0] = 42; foo is 42
PASS Object.defineProperty([], '0', { get:function(){return true;} })[0] is true
PASS Object.defineProperty(Object.defineProperty([true], '0', { configurable:true, writable: false }), '0', { writable: true })[0] is true
PASS Object.defineProperty(Object.defineProperty([true], '0', { configurable:false, writable: false }), '0', { writable: true })[0] threw exception TypeError: Attempting to change configurable attribute of unconfigurable property..
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="resources/js-test-pre.js"></script>
</head>
<body>
<script src="script-tests/array-defineOwnProperty.js"></script>
<script src="resources/js-test-post.js"></script>
</body>
</html>
FAIL 'use strict'; var a = arr(); [a.pop(), a] should throw an instance of TypeError
FAIL var a = arr(); [a.pop(), a] should throw an instance of TypeError
PASS 'use strict'; var a = arr(); [a.pop(), a] threw exception of type TypeError.
PASS var a = arr(); [a.pop(), a] threw exception of type TypeError.
PASS true === true
FAIL 'use strict'; var o = obj(); [Array.prototype.pop.call(o), o] should throw an instance of TypeError
FAIL var o = obj(); [Array.prototype.pop.call(o), o] should throw an instance of TypeError
......
......@@ -26,13 +26,13 @@ PASS 'use strict'; var a = arr(); a[0] = 2; a[0] is 2
PASS var a = arr(); a[0] = 2; a[0] is 2
PASS true === true
FAIL 'use strict'; var a = arr(); a[1] = 2; a[1] should throw an instance of TypeError
FAIL var a = arr(); a[1] = 2; a[1] should be 1. Was 2.
PASS var a = arr(); a[1] = 2; a[1] is 1
PASS true === true
PASS 'use strict'; var a = arr(); a[2] = 2; a[2] is 2
PASS var a = arr(); a[2] = 2; a[2] is 2
PASS true === true
FAIL 'use strict'; var a = arr(); a[3] = 2; a[3] should throw an instance of TypeError
FAIL var a = arr(); a[3] = 2; a[3] should be 1. Was 2.
PASS var a = arr(); a[3] = 2; a[3] is 1
PASS true === true
FAIL 'use strict'; arr()[1]++ should throw an instance of TypeError
PASS arr()[1]++ is 1
......
description("This test checks the behavior of [[DefineOwnProperty]] applied to Array objects (see ES5.1 15.4.5.1).");
// Test that properties other than length, array indices are handled as normal.
shouldBeTrue("Object.defineProperty([], 'x', { get:function(){return true;} }).x");
// The length property can be set, and can be made read-only.
shouldBe("Object.defineProperty([], 'length', { value: 1 }).length", '1');
shouldBe("var a = Object.defineProperty([], 'length', { writable: false }); a[1] = 1; a.length", '0');
// The length property can be replaced with an accessor, or made either enumerable or configurable.
shouldThrow("Object.defineProperty([], 'length', { get:function(){return true;} })");
shouldThrow("Object.defineProperty([], 'length', { enumerable: true })");
shouldThrow("Object.defineProperty([], 'length', { configurable: true })");
shouldThrow("Object.defineProperty(Object.defineProperty([], 'length', { writable: false }), 'length', { writable: true })");
//
shouldBe("var a = Object.defineProperty([], '0', { value: 42 }); a[0]", '42');
//
shouldBe("var a = Object.defineProperty([42], '0', { writable: false }); a[0] = 1; a[0]", '42');
//
shouldBe("var a = Object.defineProperty([42], '0', { enumerable: false }); a[0] + Object.keys(a).length", '42');
// FIXME: this doesn't yet work. Reducing the length should not work if it contains non-configurable properties.
shouldBe("var a = Object.defineProperty([42], '0', { configurable: false }); a.length = 0; a[0]", '42');
//
shouldBe("var foo = 0; Object.defineProperty([], '0', { set:function(x){foo = x;} })[0] = 42; foo", '42');
//
shouldBeTrue("Object.defineProperty([], '0', { get:function(){return true;} })[0]")
//
shouldBeTrue("Object.defineProperty(Object.defineProperty([true], '0', { configurable:true, writable: false }), '0', { writable: true })[0]");
//
shouldThrow("Object.defineProperty(Object.defineProperty([true], '0', { configurable:false, writable: false }), '0', { writable: true })[0]");
successfullyParsed = true;
......@@ -4,7 +4,7 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
PASS ES5Harness.preconditionPassed is true
FAIL ES5Harness.testPassed should be true. Was false.
PASS ES5Harness.testPassed is true
PASS successfullyParsed is true
TEST COMPLETE
......
......@@ -4,7 +4,7 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
PASS ES5Harness.preconditionPassed is true
FAIL ES5Harness.testPassed should be true. Was false.
PASS ES5Harness.testPassed is true
PASS successfullyParsed is true
TEST COMPLETE
......
2012-01-09 Gavin Barraclough <barraclough@apple.com>
https://bugs.webkit.org/show_bug.cgi?id=75789
defineOwnProperty not implemented for Array objects
Reviewed by Sam Weinig.
Implements support for getter/setter & non-default attribute properties on arrays,
by forcing them into a dictionary-like 'SparseMode'. This fixes ~300 test-262
test failures.
* JavaScriptCore.exp:
- Updated exports.
* dfg/DFGOperations.cpp:
- JSArray::pop now requires an exec state.
* runtime/ArrayPrototype.cpp:
(JSC::arrayProtoFuncPop):
- JSArray::pop now requires an exec state.
* runtime/JSArray.cpp:
(JSC::SparseArrayValueMap::add):
- Add a potentially empty entry into the map.
(JSC::SparseArrayValueMap::put):
- Changed to call setter.
(JSC::SparseArrayEntry::get):
- calls getters.
(JSC::SparseArrayEntry::getNonSparseMode):
- does not call getters.
(JSC::JSArray::enterSparseMode):
- Convert into 'SparseMode' - removes the vectors, don't allow it to be recreated.
(JSC::JSArray::putDescriptor):
- Create a numeric property based on a descriptor.
(JSC::sameValue):
- See ES5.1 9.12.
(JSC::reject):
- Helper for the [[DefineOwnProperty]] algorithm.
(JSC::JSArray::defineOwnNumericProperty):
- Define an indexed property on an array object.
(JSC::JSArray::setLengthWritable):
- Marks the length read-only, enters SparseMode as necessary.
(JSC::JSArray::defineOwnProperty):
- Defines either an indexed property or 'length' on an array object.
(JSC::JSArray::getOwnPropertySlotByIndex):
- Updated to correctly handle accessor descriptors & attributes.
(JSC::JSArray::getOwnPropertyDescriptor):
- Updated to correctly handle accessor descriptors & attributes.
(JSC::JSArray::put):
- Pass strict mode flag to setLength.
(JSC::JSArray::putByIndex):
- putByIndexBeyondVectorLength requires an ExecState* rather than a JSGloablData&.
(JSC::JSArray::putByIndexBeyondVectorLength):
- Pass exec to SparseArrayValueMap::put.
(JSC::JSArray::deletePropertyByIndex):
- Do not allow deletion of non-configurable properties.
(JSC::compareKeysForQSort):
- used in implementation of getOwnPropertyNames.
(JSC::JSArray::getOwnPropertyNames):
- Properties in the sparse map should be iterated in order.
(JSC::JSArray::setLength):
- Updated to take a 'shouldThrow' flag, return a result indicating error.
(JSC::JSArray::pop):
- pop should throw an error if length is not writable, even if the array is empty.
(JSC::JSArray::push):
- putByIndexBeyondVectorLength requires an ExecState* rather than a JSGloablData&.
(JSC::JSArray::sort):
- Changed 'get' to 'getNonSparseMode' (can't be getters to call).
(JSC::JSArray::compactForSorting):
- Changed 'get' to 'getNonSparseMode' (can't be getters to call).
* runtime/JSArray.h:
(JSC::SparseArrayValueMap::lengthIsReadOnly):
- Check if the length is read only.
(JSC::SparseArrayValueMap::setLengthIsReadOnly):
- Mark the length as read only.
(JSC::SparseArrayValueMap::find):
- Moved into header.
(JSC::JSArray::isLengthWritable):
- Wraps SparseArrayValueMap::lengthIsReadOnly.
* runtime/JSObject.cpp:
(JSC::JSObject::defineOwnProperty):
- Should be returning the result of putDescriptor.
* runtime/PropertyDescriptor.cpp:
(JSC::PropertyDescriptor::attributesOverridingCurrent):
- Added attributesOverridingCurrent - this should probably be merged with attributesWithOverride.
* runtime/PropertyDescriptor.h:
- Added attributesOverridingCurrent.
2012-01-09 Pavel Heimlich <tropikhajma@gmail.com>
There is no support for fastcall in Solaris Studio.
......@@ -281,11 +281,12 @@ __ZN3JSC6RegExp6createERNS_12JSGlobalDataERKNS_7UStringENS_11RegExpFlagsE
__ZN3JSC7JSArray13visitChildrenEPNS_6JSCellERNS_11SlotVisitorE
__ZN3JSC7JSArray14finishCreationERNS_12JSGlobalDataEj
__ZN3JSC7JSArray15setSubclassDataEPv
__ZN3JSC7JSArray17defineOwnPropertyEPNS_8JSObjectEPNS_9ExecStateERKNS_10IdentifierERNS_18PropertyDescriptorEb
__ZN3JSC7JSArray25getOwnPropertySlotByIndexEPNS_6JSCellEPNS_9ExecStateEjRNS_12PropertySlotE
__ZN3JSC7JSArray30tryFinishCreationUninitializedERNS_12JSGlobalDataEj
__ZN3JSC7JSArray6s_infoE
__ZN3JSC7JSArray7destroyEPNS_6JSCellE
__ZN3JSC7JSArray9setLengthEj
__ZN3JSC7JSArray9setLengthEjb
__ZN3JSC7JSArrayC1ERNS_12JSGlobalDataEPNS_9StructureE
__ZN3JSC7JSArrayC2ERNS_12JSGlobalDataEPNS_9StructureE
__ZN3JSC7JSArrayD2Ev
......
......@@ -411,9 +411,9 @@ EncodedJSValue DFG_OPERATION operationArrayPush(ExecState* exec, EncodedJSValue
return JSValue::encode(jsNumber(array->length()));
}
EncodedJSValue DFG_OPERATION operationArrayPop(ExecState*, JSArray* array)
EncodedJSValue DFG_OPERATION operationArrayPop(ExecState* exec, JSArray* array)
{
return JSValue::encode(array->pop());
return JSValue::encode(array->pop(exec));
}
void DFG_OPERATION operationPutByIdStrict(ExecState* exec, EncodedJSValue encodedValue, JSCell* base, Identifier* propertyName)
......
......@@ -389,7 +389,7 @@ EncodedJSValue JSC_HOST_CALL arrayProtoFuncPop(ExecState* exec)
JSValue thisValue = exec->hostThisValue();
if (isJSArray(thisValue))
return JSValue::encode(asArray(thisValue)->pop());
return JSValue::encode(asArray(thisValue)->pop(exec));
JSObject* thisObj = thisValue.toObject(exec);
unsigned length = thisObj->get(exec, exec->propertyNames().length).toUInt32(exec);
......
This diff is collapsed.
......@@ -30,16 +30,25 @@ namespace JSC {
class JSArray;
struct SparseArrayEntry : public WriteBarrier<Unknown> {
typedef WriteBarrier<Unknown> Base;
SparseArrayEntry() : attributes(0) {}
JSValue get(ExecState*, JSArray*) const;
void get(PropertySlot&) const;
void get(PropertyDescriptor&) const;
JSValue getNonSparseMode() const;
unsigned attributes;
};
class SparseArrayValueMap {
typedef HashMap<unsigned, SparseArrayEntry> Map;
typedef HashMap<uint64_t, SparseArrayEntry, WTF::IntHash<uint64_t>, WTF::UnsignedWithZeroKeyHashTraits<uint64_t> > Map;
enum Flags {
Normal = 0,
SparseMode = 1
SparseMode = 1,
LengthIsReadOnly = 2,
};
public:
......@@ -61,12 +70,23 @@ namespace JSC {
void setSparseMode()
{
m_flags = (Flags)(m_flags | SparseMode);
m_flags = static_cast<Flags>(m_flags | SparseMode);
}
bool lengthIsReadOnly()
{
return m_flags & LengthIsReadOnly;
}
void setLengthIsReadOnly()
{
m_flags = static_cast<Flags>(m_flags | LengthIsReadOnly);
}
// These methods may mutate the contents of the map
void put(JSGlobalData&, JSArray*, unsigned, JSValue);
iterator find(unsigned);
void put(ExecState*, JSArray*, unsigned, JSValue);
std::pair<iterator, bool> add(JSArray*, unsigned);
iterator find(unsigned i) { return m_map.find(i); }
// This should ASSERT the remove is valid (check the result of the find).
void remove(iterator it) { m_map.remove(it); }
void remove(unsigned i) { m_map.remove(i); }
......@@ -136,7 +156,9 @@ namespace JSC {
return array->tryFinishCreationUninitialized(globalData, initialLength);
}
static bool getOwnPropertySlot(JSCell*, ExecState*, const Identifier& propertyName, PropertySlot&);
static bool defineOwnProperty(JSObject*, ExecState*, const Identifier&, PropertyDescriptor&, bool throwException);
static bool getOwnPropertySlot(JSCell*, ExecState*, const Identifier&, PropertySlot&);
static bool getOwnPropertySlotByIndex(JSCell*, ExecState*, unsigned propertyName, PropertySlot&);
static bool getOwnPropertyDescriptor(JSObject*, ExecState*, const Identifier&, PropertyDescriptor&);
static void putByIndex(JSCell*, ExecState*, unsigned propertyName, JSValue);
......@@ -144,14 +166,14 @@ namespace JSC {
static JS_EXPORTDATA const ClassInfo s_info;
unsigned length() const { return m_storage->m_length; }
void setLength(unsigned); // OK to use on new arrays, but not if it might be a RegExpMatchArray.
bool setLength(unsigned, bool throwException = false); // OK to use on new arrays, but not if it might be a RegExpMatchArray.
void sort(ExecState*);
void sort(ExecState*, JSValue compareFunction, CallType, const CallData&);
void sortNumeric(ExecState*, JSValue compareFunction, CallType, const CallData&);
void push(ExecState*, JSValue);
JSValue pop();
JSValue pop(ExecState*);
void shiftCount(ExecState*, unsigned count);
void unshiftCount(ExecState*, unsigned count);
......@@ -245,8 +267,19 @@ namespace JSC {
void setSubclassData(void*);
private:
bool isLengthWritable()
{
SparseArrayValueMap* map = m_storage->m_sparseValueMap;
return !map || !map->lengthIsReadOnly();
}
void setLengthWritable(ExecState*, bool writable);
void putDescriptor(ExecState*, SparseArrayEntry*, PropertyDescriptor&, PropertyDescriptor& old);
bool defineOwnNumericProperty(ExecState*, unsigned, PropertyDescriptor&, bool throwException);
void enterSparseMode(JSGlobalData&);
bool getOwnPropertySlotSlowCase(ExecState*, unsigned propertyName, PropertySlot&);
void putByIndexBeyondVectorLength(JSGlobalData&, unsigned propertyName, JSValue);
void putByIndexBeyondVectorLength(ExecState*, unsigned propertyName, JSValue);
unsigned getNewVectorLength(unsigned desiredLength);
bool increaseVectorLength(unsigned newLength);
......
......@@ -761,7 +761,7 @@ bool JSObject::defineOwnProperty(JSObject* object, ExecState* exec, const Identi
if (descriptor.isGenericDescriptor()) {
if (!current.attributesEqual(descriptor)) {
object->methodTable()->deleteProperty(object, exec, propertyName);
putDescriptor(exec, object, propertyName, descriptor, current.attributesWithOverride(descriptor), current);
return putDescriptor(exec, object, propertyName, descriptor, current.attributesWithOverride(descriptor), current);
}
return true;
}
......
......@@ -201,4 +201,18 @@ unsigned PropertyDescriptor::attributesWithOverride(const PropertyDescriptor& ot
return newAttributes;
}
unsigned PropertyDescriptor::attributesOverridingCurrent(const PropertyDescriptor& current) const
{
unsigned overrideMask = 0;
if (writablePresent())
overrideMask |= ReadOnly;
if (enumerablePresent())
overrideMask |= DontEnum;
if (configurablePresent())
overrideMask |= DontDelete;
if (isAccessorDescriptor())
overrideMask |= (Getter | Setter);
return (m_attributes & overrideMask) | (current.m_attributes & ~overrideMask);
}
}
......@@ -66,6 +66,8 @@ namespace JSC {
bool equalTo(ExecState* exec, const PropertyDescriptor& other) const;
bool attributesEqual(const PropertyDescriptor& other) const;
unsigned attributesWithOverride(const PropertyDescriptor& other) const;
unsigned attributesOverridingCurrent(const PropertyDescriptor& current) const;
private:
static unsigned defaultAttributes;
bool operator==(const PropertyDescriptor&){ return false; }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment