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_ |