| Index: src/unscopables.h
|
| diff --git a/src/unscopables.h b/src/unscopables.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..19815abc76083d9b8ac577538caf212d3d1550bf
|
| --- /dev/null
|
| +++ b/src/unscopables.h
|
| @@ -0,0 +1,69 @@
|
| +// 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/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 and GetBindingValue spec algorithms for
|
| + * ObjectEnvironment.
|
| + */
|
| +static PropertyAttributes UnscopableLookup(Isolate* isolate,
|
| + Handle<JSReceiver> object,
|
| + Handle<String> name,
|
| + Handle<JSReceiver>* holder,
|
| + bool* ok) {
|
| + Handle<Symbol> unscopables_symbol(
|
| + isolate->native_context()->unscopables_symbol(), isolate);
|
| + *ok = true;
|
| +
|
| + for (PrototypeIterator iter(isolate, object,
|
| + PrototypeIterator::START_AT_RECEIVER);
|
| + !iter.IsAtEnd(); iter.Advance()) {
|
| + Handle<JSReceiver> object =
|
| + Handle<JSReceiver>::cast(PrototypeIterator::GetCurrent(iter));
|
| +
|
| + PropertyAttributes name_attrs =
|
| + JSReceiver::GetOwnPropertyAttributes(object, name);
|
| + if (name_attrs != ABSENT) {
|
| + bool has_unscopables =
|
| + JSReceiver::HasOwnProperty(object, unscopables_symbol);
|
| + bool blocked = false;
|
| + if (has_unscopables) {
|
| + MaybeHandle<Object> maybe_unscopables_object =
|
| + Object::GetProperty(object, unscopables_symbol);
|
| + Handle<Object> unscopables_object;
|
| + if (!maybe_unscopables_object.ToHandle(&unscopables_object)) {
|
| + ASSERT(isolate->has_pending_exception());
|
| + *ok = false;
|
| + return ABSENT;
|
| + }
|
| + if (unscopables_object->IsSpecObject()) {
|
| + blocked = JSReceiver::HasOwnProperty(
|
| + Handle<JSReceiver>::cast(unscopables_object), name);
|
| + }
|
| + }
|
| +
|
| + if (!blocked) {
|
| + *holder = object;
|
| + return name_attrs;
|
| + }
|
| + }
|
| + }
|
| + return ABSENT;
|
| +}
|
| +
|
| +
|
| +} } // namespace v8::internal
|
| +
|
| +#endif // V8_UNSCOPABLES_H_
|
|
|