X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/93a3786624b2768d89bfa27e46598dc64e2fb70a..ed1e77d3adeb83d26fd1dfb16dd84cabdcefd250:/runtime/PropertyDescriptor.cpp diff --git a/runtime/PropertyDescriptor.cpp b/runtime/PropertyDescriptor.cpp index 14b42fd..5722e88 100644 --- a/runtime/PropertyDescriptor.cpp +++ b/runtime/PropertyDescriptor.cpp @@ -30,10 +30,10 @@ #include "GetterSetter.h" #include "JSObject.h" -#include "Operations.h" +#include "JSCInlines.h" namespace JSC { -unsigned PropertyDescriptor::defaultAttributes = (DontDelete << 1) - 1; +unsigned PropertyDescriptor::defaultAttributes = DontDelete | DontEnum | ReadOnly; bool PropertyDescriptor::writable() const { @@ -106,8 +106,8 @@ void PropertyDescriptor::setDescriptor(JSValue value, unsigned attributes) m_attributes &= ~ReadOnly; // FIXME: we should be able to ASSERT this! GetterSetter* accessor = asGetterSetter(value); - m_getter = accessor->getter() ? accessor->getter() : jsUndefined(); - m_setter = accessor->setter() ? accessor->setter() : jsUndefined(); + m_getter = !accessor->isGetterNull() ? accessor->getter() : jsUndefined(); + m_setter = !accessor->isSetterNull() ? accessor->setter() : jsUndefined(); m_seenAttributes = EnumerablePresent | ConfigurablePresent; } else { m_value = value; @@ -115,14 +115,24 @@ void PropertyDescriptor::setDescriptor(JSValue value, unsigned attributes) } } +void PropertyDescriptor::setCustomDescriptor(unsigned attributes) +{ + m_attributes = attributes | Accessor | CustomAccessor; + m_attributes &= ~ReadOnly; + m_seenAttributes = EnumerablePresent | ConfigurablePresent; + setGetter(jsUndefined()); + setSetter(jsUndefined()); + m_value = JSValue(); +} + void PropertyDescriptor::setAccessorDescriptor(GetterSetter* accessor, unsigned attributes) { ASSERT(attributes & Accessor); attributes &= ~ReadOnly; // FIXME: we should be able to ASSERT this! m_attributes = attributes; - m_getter = accessor->getter() ? accessor->getter() : jsUndefined(); - m_setter = accessor->setter() ? accessor->setter() : jsUndefined(); + m_getter = !accessor->isGetterNull() ? accessor->getter() : jsUndefined(); + m_setter = !accessor->isSetterNull() ? accessor->setter() : jsUndefined(); m_seenAttributes = EnumerablePresent | ConfigurablePresent; } @@ -176,16 +186,18 @@ bool sameValue(ExecState* exec, JSValue a, JSValue b) return false; double x = a.asNumber(); double y = b.asNumber(); - if (std::isnan(x)) - return std::isnan(y); + bool xIsNaN = std::isnan(x); + bool yIsNaN = std::isnan(y); + if (xIsNaN || yIsNaN) + return xIsNaN && yIsNaN; return bitwise_cast(x) == bitwise_cast(y); } bool PropertyDescriptor::equalTo(ExecState* exec, const PropertyDescriptor& other) const { - if (!other.m_value == m_value || - !other.m_getter == m_getter || - !other.m_setter == m_setter) + if (other.m_value.isEmpty() != m_value.isEmpty() + || other.m_getter.isEmpty() != m_getter.isEmpty() + || other.m_setter.isEmpty() != m_setter.isEmpty()) return false; return (!m_value || sameValue(exec, other.m_value, m_value)) && (!m_getter || JSValue::strictEqual(exec, other.m_getter, m_getter))