 Chromium Code Reviews
 Chromium Code Reviews Issue 384963002:
  ES6 Unscopables  (Closed) 
  Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge
    
  
    Issue 384963002:
  ES6 Unscopables  (Closed) 
  Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge| Index: src/contexts.cc | 
| diff --git a/src/contexts.cc b/src/contexts.cc | 
| index cb5e852d7d669c07c8d8b950016defff1572f49c..53851db7b61dc0bfd1ff95af04934f9761dc679b 100644 | 
| --- a/src/contexts.cc | 
| +++ b/src/contexts.cc | 
| @@ -71,6 +71,50 @@ void Context::set_global_proxy(JSObject* object) { | 
| } | 
| +static PropertyAttributes GetWithContextAttributes(Isolate* isolate, | 
| + Handle<String> name, | 
| + Handle<JSReceiver> object) { | 
| + Handle<Symbol> unscopables_symbol( | 
| + isolate->native_context()->unscopables_symbol(), isolate); | 
| + | 
| + while (true) { | 
| 
arv (Not doing code reviews)
2014/07/10 23:13:11
I'll switch to use the new PrototypeIterator.
 
rossberg
2014/07/11 11:59:06
Yes, that would be better.
 
arv (Not doing code reviews)
2014/07/11 21:47:28
Waiting for that CL to land...
 | 
| + PropertyAttributes name_attrs = | 
| + JSReceiver::GetOwnPropertyAttributes(object, name); | 
| + | 
| + if (name_attrs != ABSENT) { | 
| + PropertyAttributes unscopables_attrs = | 
| + JSReceiver::GetOwnPropertyAttributes(object, unscopables_symbol); | 
| + PropertyAttributes blocked_attrs = ABSENT; | 
| + if (unscopables_attrs != ABSENT) { | 
| + Handle<Object> unscopables_object; | 
| + ASSIGN_RETURN_ON_EXCEPTION_VALUE( | 
| + isolate, unscopables_object, | 
| + Object::GetProperty(object, unscopables_symbol), name_attrs); | 
| + | 
| + if (unscopables_object->IsSpecObject()) { | 
| + blocked_attrs = JSReceiver::GetOwnPropertyAttributes( | 
| + Handle<JSReceiver>::cast(unscopables_object), name); | 
| + } | 
| + } | 
| + | 
| + if (blocked_attrs == ABSENT) { | 
| + return name_attrs; | 
| + } | 
| + } | 
| + | 
| + Object* prototype = object->GetPrototype(); | 
| + if (prototype->IsNull()) { | 
| + return ABSENT; | 
| + } | 
| + ASSERT(prototype->IsSpecObject()); | 
| + object = handle(JSReceiver::cast(prototype), isolate); | 
| + } | 
| + | 
| + UNREACHABLE(); | 
| + return ABSENT; | 
| +} | 
| + | 
| + | 
| Handle<Object> Context::Lookup(Handle<String> name, | 
| ContextLookupFlags flags, | 
| int* index, | 
| @@ -109,9 +153,12 @@ Handle<Object> Context::Lookup(Handle<String> name, | 
| if ((flags & FOLLOW_PROTOTYPE_CHAIN) == 0 || | 
| object->IsJSContextExtensionObject()) { | 
| *attributes = JSReceiver::GetOwnPropertyAttributes(object, name); | 
| + } else if (FLAG_harmony_unscopables && context->IsWithContext()) { | 
| + *attributes = GetWithContextAttributes(isolate, name, object); | 
| } else { | 
| *attributes = JSReceiver::GetPropertyAttributes(object, name); | 
| } | 
| + | 
| if (isolate->has_pending_exception()) return Handle<Object>(); | 
| if (*attributes != ABSENT) { |