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