Commit e2dd98a3 authored by jkummerow's avatar jkummerow Committed by Commit bot

[proxies] Fix "with" statements for proxies

BUG=v8:1543
LOG=n

Review URL: https://codereview.chromium.org/1510913005

Cr-Commit-Position: refs/heads/master@{#32756}
parent 989f44f1
...@@ -146,30 +146,24 @@ void Context::set_global_proxy(JSObject* object) { ...@@ -146,30 +146,24 @@ void Context::set_global_proxy(JSObject* object) {
* Lookups a property in an object environment, taking the unscopables into * Lookups a property in an object environment, taking the unscopables into
* account. This is used For HasBinding spec algorithms for ObjectEnvironment. * account. This is used For HasBinding spec algorithms for ObjectEnvironment.
*/ */
static Maybe<PropertyAttributes> UnscopableLookup(LookupIterator* it) { static Maybe<bool> UnscopableLookup(LookupIterator* it) {
Isolate* isolate = it->isolate(); Isolate* isolate = it->isolate();
Maybe<PropertyAttributes> attrs = JSReceiver::GetPropertyAttributes(it); Maybe<bool> found = JSReceiver::HasProperty(it);
DCHECK(attrs.IsJust() || isolate->has_pending_exception()); if (!found.IsJust() || !found.FromJust()) return found;
if (!attrs.IsJust() || attrs.FromJust() == ABSENT) return attrs;
Handle<Symbol> unscopables_symbol = isolate->factory()->unscopables_symbol();
Handle<Object> receiver = it->GetReceiver();
Handle<Object> unscopables; Handle<Object> unscopables;
MaybeHandle<Object> maybe_unscopables = ASSIGN_RETURN_ON_EXCEPTION_VALUE(
Object::GetProperty(receiver, unscopables_symbol); isolate, unscopables,
if (!maybe_unscopables.ToHandle(&unscopables)) { Object::GetProperty(it->GetReceiver(),
return Nothing<PropertyAttributes>(); isolate->factory()->unscopables_symbol()),
} Nothing<bool>());
if (!unscopables->IsJSReceiver()) return attrs; if (!unscopables->IsJSReceiver()) return Just(true);
Handle<Object> blacklist; Handle<Object> blacklist;
MaybeHandle<Object> maybe_blacklist = ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, blacklist,
Object::GetProperty(unscopables, it->name()); Object::GetProperty(unscopables, it->name()),
if (!maybe_blacklist.ToHandle(&blacklist)) { Nothing<bool>());
DCHECK(isolate->has_pending_exception()); return Just(!blacklist->BooleanValue());
return Nothing<PropertyAttributes>();
}
return blacklist->BooleanValue() ? Just(ABSENT) : attrs;
} }
static void GetAttributesAndBindingFlags(VariableMode mode, static void GetAttributesAndBindingFlags(VariableMode mode,
...@@ -289,7 +283,15 @@ Handle<Object> Context::Lookup(Handle<String> name, ...@@ -289,7 +283,15 @@ Handle<Object> Context::Lookup(Handle<String> name,
maybe = Just(ABSENT); maybe = Just(ABSENT);
} else { } else {
LookupIterator it(object, name); LookupIterator it(object, name);
maybe = UnscopableLookup(&it); Maybe<bool> found = UnscopableLookup(&it);
if (found.IsNothing()) {
maybe = Nothing<PropertyAttributes>();
} else {
// Luckily, consumers of |maybe| only care whether the property
// was absent or not, so we can return a dummy |NONE| value
// for its attributes when it was present.
maybe = Just(found.FromJust() ? NONE : ABSENT);
}
} }
} else { } else {
maybe = JSReceiver::GetPropertyAttributes(object, name); maybe = JSReceiver::GetPropertyAttributes(object, name);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment