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

Unified Diff: src/unscopables.h

Issue 384963002: ES6 Unscopables (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Use new GetHolder 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
Index: src/unscopables.h
diff --git a/src/unscopables.h b/src/unscopables.h
new file mode 100644
index 0000000000000000000000000000000000000000..c57e7fa98a89b4089e6f47a778480deb73a32097
--- /dev/null
+++ b/src/unscopables.h
@@ -0,0 +1,55 @@
+// 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 = it->GetHolder<JSReceiver>();
+ 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;
Toon Verwaest 2014/07/25 10:09:41 Maybe add a comment here saying that you return fa
+ if (!unscopables->IsSpecObject()) return false;
+ return JSReceiver::HasOwnProperty(Handle<JSReceiver>::cast(unscopables),
Toon Verwaest 2014/07/25 10:09:41 This HasOwnProperty can cause an exception at leas
+ 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) {
Toon Verwaest 2014/07/25 10:09:41 At least GetPropertyAttributesWithHandler will ret
+ if (!BlockedByUnscopables(it)) {
+ return attrs;
+ }
+ it->Next();
+ }
+
+ return ABSENT;
+}
+}
+
+} // namespace v8::internal
+
+#endif // V8_UNSCOPABLES_H_

Powered by Google App Engine
This is Rietveld 408576698