Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef V8_UNSCOPABLES_H_ | |
| 6 #define V8_UNSCOPABLES_H_ | |
| 7 | |
| 8 #include "src/isolate.h" | |
| 9 #include "src/lookup.h" | |
| 10 #include "src/objects.h" | |
| 11 #include "src/prototype.h" | |
| 12 | |
| 13 namespace v8 { | |
| 14 namespace internal { | |
| 15 | |
| 16 | |
| 17 static bool BlockedByUnscopables(LookupIterator* it) { | |
| 18 Isolate* isolate = it->isolate(); | |
| 19 Handle<Symbol> unscopables_symbol( | |
| 20 isolate->native_context()->unscopables_symbol(), isolate); | |
| 21 | |
| 22 // TODO(arv): This should be GetNonHiddenHolder | |
| 23 Handle<JSReceiver> object; | |
| 24 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
| |
| 25 object = it->GetJSProxy(); | |
| 26 } else { | |
| 27 object = it->GetHolder(); | |
| 28 } | |
| 29 | |
| 30 if (!JSReceiver::HasOwnProperty(object, unscopables_symbol)) return false; | |
| 31 Handle<Object> unscopables; | |
| 32 MaybeHandle<Object> maybe_unscopables = | |
| 33 Object::GetProperty(object, unscopables_symbol); | |
| 34 if (!maybe_unscopables.ToHandle(&unscopables)) return false; | |
| 35 if (!unscopables->IsSpecObject()) return false; | |
| 36 return JSReceiver::HasOwnProperty(Handle<JSReceiver>::cast(unscopables), | |
| 37 it->name()); | |
| 38 } | |
| 39 | |
| 40 | |
| 41 /** | |
| 42 * Lookups a property in an object environment, taking the unscopables into | |
| 43 * account. This is used For HasBinding and GetBindingValue spec algorithms for | |
| 44 * ObjectEnvironment. | |
| 45 */ | |
| 46 static PropertyAttributes UnscopableLookup(LookupIterator* it) { | |
| 47 PropertyAttributes attrs; | |
| 48 while ((attrs = JSReceiver::GetPropertyAttributes(it)) != ABSENT) { | |
| 49 if (!BlockedByUnscopables(it)) { | |
| 50 return attrs; | |
| 51 } | |
| 52 it->Next(); | |
| 53 } | |
| 54 | |
| 55 return ABSENT; | |
| 56 } | |
| 57 } | |
| 58 | |
| 59 } // namespace v8::internal | |
| 60 | |
| 61 #endif // V8_UNSCOPABLES_H_ | |
| OLD | NEW |