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

Unified Diff: src/unscopables.h

Issue 384963002: ES6 Unscopables (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Cleanup code using LookupIterator Created 6 years, 5 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/runtime.cc ('k') | test/mjsunit/harmony/proxies-with-unscopables.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/unscopables.h
diff --git a/src/unscopables.h b/src/unscopables.h
new file mode 100644
index 0000000000000000000000000000000000000000..f96d0212a5fe9ae7087350e25ded26c968903e16
--- /dev/null
+++ b/src/unscopables.h
@@ -0,0 +1,61 @@
+// 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_
+#define V8_UNSCOPABLES_H_
+
+#include "src/isolate.h"
+#include "src/lookup.h"
+#include "src/objects.h"
+#include "src/prototype.h"
+
+namespace v8 {
+namespace internal {
+
+
+static bool BlockedByUnscopables(LookupIterator* it) {
+ Isolate* isolate = it->isolate();
+ Handle<Symbol> unscopables_symbol(
+ isolate->native_context()->unscopables_symbol(), isolate);
+
+ // TODO(arv): This should be GetNonHiddenHolder
+ Handle<JSReceiver> object;
+ if (it->state() == LookupIterator::JSPROXY) {
arv (Not doing code reviews) 2014/07/23 23:10:40 Toon, this is a bit ugly. I was considering adding
+ object = it->GetJSProxy();
+ } else {
+ object = it->GetHolder();
+ }
+
+ if (!JSReceiver::HasOwnProperty(object, unscopables_symbol)) return false;
+ Handle<Object> unscopables;
+ MaybeHandle<Object> maybe_unscopables =
+ Object::GetProperty(object, unscopables_symbol);
+ if (!maybe_unscopables.ToHandle(&unscopables)) return false;
+ if (!unscopables->IsSpecObject()) return false;
+ return JSReceiver::HasOwnProperty(Handle<JSReceiver>::cast(unscopables),
+ it->name());
+}
+
+
+/**
+ * Lookups a property in an object environment, taking the unscopables into
+ * account. This is used For HasBinding and GetBindingValue spec algorithms for
+ * ObjectEnvironment.
+ */
+static PropertyAttributes UnscopableLookup(LookupIterator* it) {
+ PropertyAttributes attrs;
+ while ((attrs = JSReceiver::GetPropertyAttributes(it)) != ABSENT) {
+ if (!BlockedByUnscopables(it)) {
+ return attrs;
+ }
+ it->Next();
+ }
+
+ return ABSENT;
+}
+}
+
+} // namespace v8::internal
+
+#endif // V8_UNSCOPABLES_H_
« no previous file with comments | « src/runtime.cc ('k') | test/mjsunit/harmony/proxies-with-unscopables.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698