Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/objects.h" | 5 #include "src/objects.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 #include <iomanip> | 8 #include <iomanip> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <sstream> | 10 #include <sstream> |
| (...skipping 7329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7340 Handle<Object> key, | 7340 Handle<Object> key, |
| 7341 PropertyDescriptor* desc) { | 7341 PropertyDescriptor* desc) { |
| 7342 bool success = false; | 7342 bool success = false; |
| 7343 DCHECK(key->IsName() || key->IsNumber()); // |key| is a PropertyKey... | 7343 DCHECK(key->IsName() || key->IsNumber()); // |key| is a PropertyKey... |
| 7344 LookupIterator it = LookupIterator::PropertyOrElement( | 7344 LookupIterator it = LookupIterator::PropertyOrElement( |
| 7345 isolate, object, key, &success, LookupIterator::OWN); | 7345 isolate, object, key, &success, LookupIterator::OWN); |
| 7346 DCHECK(success); // ...so creating a LookupIterator can't fail. | 7346 DCHECK(success); // ...so creating a LookupIterator can't fail. |
| 7347 return GetOwnPropertyDescriptor(&it, desc); | 7347 return GetOwnPropertyDescriptor(&it, desc); |
| 7348 } | 7348 } |
| 7349 | 7349 |
| 7350 namespace { | |
| 7351 | |
| 7352 Maybe<bool> GetPropertyDescriptorWithInterceptor(LookupIterator* it, | |
| 7353 PropertyDescriptor* desc) { | |
| 7354 if (it->state() == LookupIterator::INTERCEPTOR) { | |
| 7355 Isolate* isolate = it->isolate(); | |
| 7356 Handle<InterceptorInfo> interceptor = it->GetInterceptor(); | |
| 7357 if (!interceptor->descriptor()->IsUndefined(isolate)) { | |
| 7358 Handle<Object> result; | |
| 7359 Handle<JSObject> holder = it->GetHolder<JSObject>(); | |
| 7360 Handle<Object> receiver = it->GetReceiver(); | |
|
jochen (gone - plz use gerrit)
2016/09/06 16:02:34
all our API methods are sloppy, i.e., you need to
Franzi
2016/09/06 16:45:37
Done. Thanks!
| |
| 7361 | |
| 7362 PropertyCallbackArguments args(isolate, interceptor->data(), *receiver, | |
| 7363 *holder, Object::DONT_THROW); | |
| 7364 if (it->IsElement()) { | |
| 7365 uint32_t index = it->index(); | |
| 7366 v8::IndexedPropertyDescriptorCallback descriptorCallback = | |
| 7367 v8::ToCData<v8::IndexedPropertyDescriptorCallback>( | |
| 7368 interceptor->descriptor()); | |
| 7369 | |
| 7370 result = args.Call(descriptorCallback, index); | |
| 7371 } else { | |
| 7372 Handle<Name> name = it->name(); | |
| 7373 DCHECK(!name->IsPrivate()); | |
| 7374 v8::GenericNamedPropertyDescriptorCallback descriptorCallback = | |
| 7375 v8::ToCData<v8::GenericNamedPropertyDescriptorCallback>( | |
| 7376 interceptor->descriptor()); | |
| 7377 result = args.Call(descriptorCallback, name); | |
| 7378 } | |
| 7379 if (!result.is_null()) { | |
| 7380 // Request successfully intercepted, try to set the property | |
| 7381 // descriptor. | |
| 7382 if (!PropertyDescriptor::ToPropertyDescriptor(isolate, result, desc)) { | |
| 7383 return Nothing<bool>(); | |
|
jochen (gone - plz use gerrit)
2016/09/06 16:02:34
returning Nothing<> usually implies a pending exce
Franzi
2016/09/06 16:45:37
From what I understand, that's the case. I added a
| |
| 7384 } | |
| 7385 return Just(true); | |
| 7386 } | |
| 7387 } | |
| 7388 } | |
| 7389 return Just(false); | |
| 7390 } | |
| 7391 } // namespace | |
| 7350 | 7392 |
| 7351 // ES6 9.1.5.1 | 7393 // ES6 9.1.5.1 |
| 7352 // Returns true on success, false if the property didn't exist, nothing if | 7394 // Returns true on success, false if the property didn't exist, nothing if |
| 7353 // an exception was thrown. | 7395 // an exception was thrown. |
| 7354 // static | 7396 // static |
| 7355 Maybe<bool> JSReceiver::GetOwnPropertyDescriptor(LookupIterator* it, | 7397 Maybe<bool> JSReceiver::GetOwnPropertyDescriptor(LookupIterator* it, |
| 7356 PropertyDescriptor* desc) { | 7398 PropertyDescriptor* desc) { |
| 7357 Isolate* isolate = it->isolate(); | 7399 Isolate* isolate = it->isolate(); |
| 7358 // "Virtual" dispatch. | 7400 // "Virtual" dispatch. |
| 7359 if (it->IsFound() && it->GetHolder<JSReceiver>()->IsJSProxy()) { | 7401 if (it->IsFound() && it->GetHolder<JSReceiver>()->IsJSProxy()) { |
| 7360 return JSProxy::GetOwnPropertyDescriptor(isolate, it->GetHolder<JSProxy>(), | 7402 return JSProxy::GetOwnPropertyDescriptor(isolate, it->GetHolder<JSProxy>(), |
| 7361 it->GetName(), desc); | 7403 it->GetName(), desc); |
| 7362 } | 7404 } |
| 7363 | 7405 |
| 7406 Maybe<bool> intercepted = GetPropertyDescriptorWithInterceptor(it, desc); | |
| 7407 MAYBE_RETURN(intercepted, Nothing<bool>()); | |
| 7408 if (intercepted.FromJust()) { | |
| 7409 return Just(true); | |
| 7410 } | |
| 7411 | |
| 7412 // Request was not intercepted, continue as normal. | |
| 7364 // 1. (Assert) | 7413 // 1. (Assert) |
| 7365 // 2. If O does not have an own property with key P, return undefined. | 7414 // 2. If O does not have an own property with key P, return undefined. |
| 7366 Maybe<PropertyAttributes> maybe = JSObject::GetPropertyAttributes(it); | 7415 Maybe<PropertyAttributes> maybe = JSObject::GetPropertyAttributes(it); |
| 7367 MAYBE_RETURN(maybe, Nothing<bool>()); | 7416 MAYBE_RETURN(maybe, Nothing<bool>()); |
| 7368 PropertyAttributes attrs = maybe.FromJust(); | 7417 PropertyAttributes attrs = maybe.FromJust(); |
| 7369 if (attrs == ABSENT) return Just(false); | 7418 if (attrs == ABSENT) return Just(false); |
| 7370 DCHECK(!isolate->has_pending_exception()); | 7419 DCHECK(!isolate->has_pending_exception()); |
| 7371 | 7420 |
| 7372 // 3. Let D be a newly created Property Descriptor with no fields. | 7421 // 3. Let D be a newly created Property Descriptor with no fields. |
| 7373 DCHECK(desc->is_empty()); | 7422 DCHECK(desc->is_empty()); |
| (...skipping 12057 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 19431 for (PrototypeIterator iter(isolate, this, kStartAtReceiver, | 19480 for (PrototypeIterator iter(isolate, this, kStartAtReceiver, |
| 19432 PrototypeIterator::END_AT_NULL); | 19481 PrototypeIterator::END_AT_NULL); |
| 19433 !iter.IsAtEnd(); iter.AdvanceIgnoringProxies()) { | 19482 !iter.IsAtEnd(); iter.AdvanceIgnoringProxies()) { |
| 19434 if (iter.GetCurrent<Object>()->IsJSProxy()) return true; | 19483 if (iter.GetCurrent<Object>()->IsJSProxy()) return true; |
| 19435 } | 19484 } |
| 19436 return false; | 19485 return false; |
| 19437 } | 19486 } |
| 19438 | 19487 |
| 19439 } // namespace internal | 19488 } // namespace internal |
| 19440 } // namespace v8 | 19489 } // namespace v8 |
| OLD | NEW |