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

Unified Diff: src/unscopables.h

Issue 384963002: ES6 Unscopables (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Updated to reflect the July 2014 consensus 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
Index: src/unscopables.h
diff --git a/src/unscopables.h b/src/unscopables.h
new file mode 100644
index 0000000000000000000000000000000000000000..f6e18d5cf11f033c5598c426c345c1b727fe35d5
--- /dev/null
+++ b/src/unscopables.h
@@ -0,0 +1,52 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef V8_UNSCOPABLES_H_
rossberg 2014/08/06 09:53:02 I don't think it's worth putting this into an extr
arv (Not doing code reviews) 2014/08/06 15:08:28 Agreed. Now that it is only used in one place. I
+#define V8_UNSCOPABLES_H_
+
+#include "src/isolate.h"
+#include "src/lookup.h"
+#include "src/objects.h"
+#include "src/prototype.h"
+
+namespace v8 {
+namespace internal {
+
+/**
+ * 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();
+ PropertyAttributes attrs;
+ if (!JSReceiver::GetPropertyAttributes(it).ToValue(&attrs)) {
rossberg 2014/08/06 09:53:02 I think it's clearer and simpler to avoid ToValue
arv (Not doing code reviews) 2014/08/06 15:08:28 Done.
+ DCHECK(isolate->has_pending_exception());
+ return Maybe<PropertyAttributes>();
+ }
+ if (attrs == ABSENT) return maybe(ABSENT);
+
+ 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 maybe(attrs);
+ bool blacklist;
+ if (!JSReceiver::HasProperty(Handle<JSReceiver>::cast(unscopables),
+ it->name()).ToValue(&blacklist)) {
+ DCHECK(isolate->has_pending_exception());
+ return Maybe<PropertyAttributes>();
+ }
+ if (blacklist) return maybe(ABSENT);
+ return maybe(attrs);
+}
+}
+
+} // namespace v8::internal
+
+#endif // V8_UNSCOPABLES_H_
« include/v8.h ('K') | « src/flag-definitions.h ('k') | test/cctest/cctest.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698