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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 = it->GetHolder<JSReceiver>();
24 if (!JSReceiver::HasOwnProperty(object, unscopables_symbol)) return false;
25 Handle<Object> unscopables;
26 MaybeHandle<Object> maybe_unscopables =
27 Object::GetProperty(object, unscopables_symbol);
28 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
29 if (!unscopables->IsSpecObject()) return false;
30 return JSReceiver::HasOwnProperty(Handle<JSReceiver>::cast(unscopables),
Toon Verwaest 2014/07/25 10:09:41 This HasOwnProperty can cause an exception at leas
31 it->name());
32 }
33
34
35 /**
36 * Lookups a property in an object environment, taking the unscopables into
37 * account. This is used For HasBinding and GetBindingValue spec algorithms for
38 * ObjectEnvironment.
39 */
40 static PropertyAttributes UnscopableLookup(LookupIterator* it) {
41 PropertyAttributes attrs;
42 while ((attrs = JSReceiver::GetPropertyAttributes(it)) != ABSENT) {
Toon Verwaest 2014/07/25 10:09:41 At least GetPropertyAttributesWithHandler will ret
43 if (!BlockedByUnscopables(it)) {
44 return attrs;
45 }
46 it->Next();
47 }
48
49 return ABSENT;
50 }
51 }
52
53 } // namespace v8::internal
54
55 #endif // V8_UNSCOPABLES_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698