summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore/runtime/PropertyDescriptor.cpp
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
commit1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch)
tree46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/JavaScriptCore/runtime/PropertyDescriptor.cpp
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/JavaScriptCore/runtime/PropertyDescriptor.cpp')
-rw-r--r--Source/JavaScriptCore/runtime/PropertyDescriptor.cpp55
1 files changed, 33 insertions, 22 deletions
diff --git a/Source/JavaScriptCore/runtime/PropertyDescriptor.cpp b/Source/JavaScriptCore/runtime/PropertyDescriptor.cpp
index 1dd35605c..16a3ffb50 100644
--- a/Source/JavaScriptCore/runtime/PropertyDescriptor.cpp
+++ b/Source/JavaScriptCore/runtime/PropertyDescriptor.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2009, 2016 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -30,7 +30,7 @@
#include "GetterSetter.h"
#include "JSObject.h"
-#include "Operations.h"
+#include "JSCInlines.h"
namespace JSC {
unsigned PropertyDescriptor::defaultAttributes = DontDelete | DontEnum | ReadOnly;
@@ -72,6 +72,22 @@ void PropertyDescriptor::setUndefined()
m_attributes = ReadOnly | DontDelete | DontEnum;
}
+GetterSetter* PropertyDescriptor::slowGetterSetter(ExecState* exec)
+{
+ VM& vm = exec->vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
+ JSGlobalObject* globalObject = exec->lexicalGlobalObject();
+ GetterSetter* getterSetter = GetterSetter::create(vm, globalObject);
+ RETURN_IF_EXCEPTION(scope, nullptr);
+ if (m_getter && !m_getter.isUndefined())
+ getterSetter->setGetter(vm, globalObject, jsCast<JSObject*>(m_getter));
+ if (m_setter && !m_setter.isUndefined())
+ getterSetter->setSetter(vm, globalObject, jsCast<JSObject*>(m_setter));
+
+ return getterSetter;
+}
+
JSValue PropertyDescriptor::getter() const
{
ASSERT(isAccessorDescriptor());
@@ -99,15 +115,14 @@ JSObject* PropertyDescriptor::setterObject() const
void PropertyDescriptor::setDescriptor(JSValue value, unsigned attributes)
{
ASSERT(value);
- ASSERT(value.isGetterSetter() == !!(attributes & Accessor));
m_attributes = attributes;
if (value.isGetterSetter()) {
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 +130,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;
}
@@ -167,20 +192,6 @@ void PropertyDescriptor::setGetter(JSValue getter)
m_attributes &= ~ReadOnly;
}
-// See ES5.1 9.12
-bool sameValue(ExecState* exec, JSValue a, JSValue b)
-{
- if (!a.isNumber())
- return JSValue::strictEqual(exec, a, b);
- if (!b.isNumber())
- return false;
- double x = a.asNumber();
- double y = b.asNumber();
- if (std::isnan(x))
- return std::isnan(y);
- return bitwise_cast<uint64_t>(x) == bitwise_cast<uint64_t>(y);
-}
-
bool PropertyDescriptor::equalTo(ExecState* exec, const PropertyDescriptor& other) const
{
if (other.m_value.isEmpty() != m_value.isEmpty()
@@ -220,7 +231,7 @@ unsigned PropertyDescriptor::attributesOverridingCurrent(const PropertyDescripto
overrideMask |= DontDelete;
if (isAccessorDescriptor())
overrideMask |= Accessor;
- return (m_attributes & overrideMask) | (currentAttributes & ~overrideMask);
+ return (m_attributes & overrideMask) | (currentAttributes & ~overrideMask & ~CustomAccessor);
}
}