• barraclough@apple.com's avatar
    Allow accessor get/set property to be set to undefined · c709a123
    barraclough@apple.com authored
    Reviewed by Oliver Hunt.
    AccessorDescriptor properties may have their get & set properties defined to reference a function
    (Callable object) or be set to undefined. Valid PropertyDescriptors created by toPropertyDescriptor
    (defined from JS code via Object.defineProperty, etc) have get and set properties that are in one of
    three states (1) nonexistent, (2) set to undefined, or (3) a function (any Callable object).
    On the PropertyDescriptor object these three states are represneted by JSValue(), jsUndefined(), and
    any JSObject* (with a constraint that this must be callable).
    Logically the get/set property of an accessor descriptor on an object might be in any of the three
    states above, but in practice there is no way to distinguish between the first two states. As such
    we stor the get/set values in property storage in a JSObject* field, with 0 indicating absent or
    undefined. When unboxing to a PropertyDescriptor, map this back to a JS undefined value.
    * runtime/GetterSetter.h:
        - Allow the getter/setter to be cleared.
    * runtime/JSArray.cpp:
        - Changed to call getterObject/setterObject.
        - Added ASSERT.
    * runtime/JSObject.cpp:
        - Changed to call getterObject/setterObject.
    * runtime/ObjectConstructor.cpp:
        - getter/setter values read from properties on object are never missing, they will now be set as undefined by 'setDescriptor'.
        - Do not translate undefined->empty, this loses an important distinction between a get/set property being absent, or being explicitly set to undefined.
    * runtime/PropertyDescriptor.cpp:
        - Accessors to convert the get/set property to an object pointer, converting undefined to 0.
        - Translate a getter/setter internally represented at 0 to undefined, indicating that it is present.
    * runtime/PropertyDescriptor.h:
        - Declare getterObject/setterObject.
    * fast/js/Object-defineProperty-expected.txt:
    * fast/js/script-tests/Object-defineProperty.js:
        - Update a couple of inaccurate tests (it is invalid for a property to have
          both a get: and value: field; AccessorDescritor properties do not have a
          writable property). Add more test cases.
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@104836 268f45cc-cd09-0410-ab3c-d52691b4dbfc
GetterSetter.h 2.86 KB