Index: src/api.cc |
diff --git a/src/api.cc b/src/api.cc |
index 750d7df7ff9f46eb9527d967abb563956c7cfc9b..1fcb2392c791d3a08a517dbbfeea9b3a404231bc 100644 |
--- a/src/api.cc |
+++ b/src/api.cc |
@@ -3503,43 +3503,16 @@ Maybe<bool> v8::Object::CreateDataProperty(v8::Local<v8::Context> context, |
v8::Local<Value> value) { |
PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::CreateDataProperty()", |
bool); |
- auto self = Utils::OpenHandle(this); |
- auto key_obj = Utils::OpenHandle(*key); |
- auto value_obj = Utils::OpenHandle(*value); |
- |
- if (self->IsAccessCheckNeeded() && !isolate->MayAccess(self)) { |
- isolate->ReportFailedAccessCheck(self); |
- return Nothing<bool>(); |
- } |
- |
- if (!self->IsExtensible()) return Just(false); |
- |
- uint32_t index = 0; |
- if (key_obj->AsArrayIndex(&index)) { |
- return CreateDataProperty(context, index, value); |
- } |
- |
- // Special case for Array.length. |
- if (self->IsJSArray() && |
- key->StrictEquals(Utils::ToLocal(isolate->factory()->length_string()))) { |
- // Length is not configurable, however, CreateDataProperty always attempts |
- // to create a configurable property, so we just fail here. |
- return Just(false); |
- } |
- |
- i::LookupIterator it(self, key_obj, i::LookupIterator::OWN_SKIP_INTERCEPTOR); |
- if (it.IsFound() && it.state() == i::LookupIterator::ACCESS_CHECK) { |
- DCHECK(isolate->MayAccess(self)); |
- it.Next(); |
- } |
- |
- if (it.IsFound() && !it.IsConfigurable()) return Just(false); |
+ i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
Jakob Kummerow
2015/06/17 10:53:30
Yay! :-)
|
+ i::Handle<i::Name> key_obj = Utils::OpenHandle(*key); |
+ i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); |
- has_pending_exception = i::JSObject::SetOwnPropertyIgnoreAttributes( |
- self, key_obj, value_obj, NONE, |
- i::JSObject::DONT_FORCE_FIELD).is_null(); |
+ i::LookupIterator it = i::LookupIterator::PropertyOrElement( |
+ isolate, self, key_obj, i::LookupIterator::OWN); |
+ Maybe<bool> result = i::JSObject::CreateDataProperty(&it, value_obj); |
+ has_pending_exception = result.IsNothing(); |
RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
- return Just(true); |
+ return result; |
} |
@@ -3548,37 +3521,14 @@ Maybe<bool> v8::Object::CreateDataProperty(v8::Local<v8::Context> context, |
v8::Local<Value> value) { |
PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::CreateDataProperty()", |
bool); |
- auto self = Utils::OpenHandle(this); |
- auto value_obj = Utils::OpenHandle(*value); |
- |
- if (self->IsAccessCheckNeeded() && !isolate->MayAccess(self)) { |
- isolate->ReportFailedAccessCheck(self); |
- return Nothing<bool>(); |
- } |
- |
- if (!self->IsExtensible()) return Just(false); |
- |
- if (self->IsJSArray()) { |
- size_t length = |
- i::NumberToSize(isolate, i::Handle<i::JSArray>::cast(self)->length()); |
- if (index >= length) { |
- return DefineOwnProperty( |
- context, Utils::ToLocal(isolate->factory()->Uint32ToString(index)), |
- value, v8::None); |
- } |
- } |
- |
- Maybe<PropertyAttributes> attributes = |
- i::JSReceiver::GetOwnElementAttributes(self, index); |
- if (attributes.IsJust() && attributes.FromJust() & DONT_DELETE) { |
- return Just(false); |
- } |
+ i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
+ i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); |
- has_pending_exception = i::JSObject::SetOwnElementIgnoreAttributes( |
- self, index, value_obj, NONE, |
- i::JSObject::DONT_FORCE_FIELD).is_null(); |
+ i::LookupIterator it(isolate, self, index, i::LookupIterator::OWN); |
+ Maybe<bool> result = i::JSObject::CreateDataProperty(&it, value_obj); |
+ has_pending_exception = result.IsNothing(); |
RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
- return Just(true); |
+ return result; |
} |