Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(89)

Unified Diff: src/contexts.cc

Issue 384963002: ES6 Unscopables (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/contexts.h ('k') | src/flag-definitions.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/contexts.cc
diff --git a/src/contexts.cc b/src/contexts.cc
index aef58e601e906eb07fbcb35682686a8fb20209f0..769693513eb2941783a313aba0e9cfdc032ca569 100644
--- a/src/contexts.cc
+++ b/src/contexts.cc
@@ -71,6 +71,38 @@ void Context::set_global_proxy(JSObject* object) {
}
+/**
+ * Lookups a property in an object environment, taking the unscopables into
+ * account. This is used For HasBinding spec algorithms for ObjectEnvironment.
+ */
+static Maybe<PropertyAttributes> UnscopableLookup(LookupIterator* it) {
+ Isolate* isolate = it->isolate();
+
+ Maybe<PropertyAttributes> attrs = JSReceiver::GetPropertyAttributes(it);
+ DCHECK(attrs.has_value || isolate->has_pending_exception());
+ if (!attrs.has_value || attrs.value == ABSENT) return attrs;
+
+ Handle<Symbol> unscopables_symbol(
+ isolate->native_context()->unscopables_symbol(), isolate);
+ Handle<Object> receiver = it->GetReceiver();
+ Handle<Object> unscopables;
+ MaybeHandle<Object> maybe_unscopables =
+ Object::GetProperty(receiver, unscopables_symbol);
+ if (!maybe_unscopables.ToHandle(&unscopables)) {
+ return Maybe<PropertyAttributes>();
+ }
+ if (!unscopables->IsSpecObject()) return attrs;
+ Maybe<bool> blacklist = JSReceiver::HasProperty(
+ Handle<JSReceiver>::cast(unscopables), it->name());
+ if (!blacklist.has_value) {
+ DCHECK(isolate->has_pending_exception());
+ return Maybe<PropertyAttributes>();
+ }
+ if (blacklist.value) return maybe(ABSENT);
+ return attrs;
+}
+
+
Handle<Object> Context::Lookup(Handle<String> name,
ContextLookupFlags flags,
int* index,
@@ -110,9 +142,13 @@ Handle<Object> Context::Lookup(Handle<String> name,
if ((flags & FOLLOW_PROTOTYPE_CHAIN) == 0 ||
object->IsJSContextExtensionObject()) {
maybe = JSReceiver::GetOwnPropertyAttributes(object, name);
+ } else if (FLAG_harmony_unscopables && context->IsWithContext()) {
+ LookupIterator it(object, name);
+ maybe = UnscopableLookup(&it);
} else {
maybe = JSReceiver::GetPropertyAttributes(object, name);
}
+
if (!maybe.has_value) return Handle<Object>();
DCHECK(!isolate->has_pending_exception());
*attributes = maybe.value;
« no previous file with comments | « src/contexts.h ('k') | src/flag-definitions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698