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

Side by Side Diff: src/unscopables.h

Issue 384963002: ES6 Unscopables (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: 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
« no previous file with comments | « src/runtime.cc ('k') | test/cctest/cctest.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #define RETURN_ON_NO_VALUE_TYPE(isolate, type, name, __value__, return_type) \
17 type name; \
18 do { \
19 Maybe<type> __maybe__ = __value__; \
20 if (!__maybe__.has_value) { \
21 ASSERT((isolate)->has_pending_exception()); \
22 return Maybe<return_type>(); \
23 } \
24 name = __maybe__.value; \
25 } while (false)
Toon Verwaest 2014/07/29 15:12:39 Can you please move these macros next to the other
arv (Not doing code reviews) 2014/07/30 15:39:38 It feels kind of wrong to assume that all usages o
26
27 #define RETURN_ON_NO_VALUE(isolate, type, name, __value__) \
28 RETURN_ON_NO_VALUE_TYPE(isolate, type, name, __value__, type)
29
30 static Maybe<bool> BlockedByUnscopables(LookupIterator* it) {
31 Isolate* isolate = it->isolate();
32 Handle<Symbol> unscopables_symbol(
33 isolate->native_context()->unscopables_symbol(), isolate);
34
35 // TODO(arv): This should be GetNonHiddenHolder
36 Handle<JSReceiver> object = it->GetHolder<JSReceiver>();
37 RETURN_ON_NO_VALUE(isolate, bool, has_own,
38 JSReceiver::HasOwnProperty(object, unscopables_symbol));
39 if (!has_own) return Maybe<bool>(false);
40
41 Handle<Object> unscopables;
42 MaybeHandle<Object> maybe_unscopables =
43 Object::GetProperty(object, unscopables_symbol);
44 if (!maybe_unscopables.ToHandle(&unscopables)) {
45 return Maybe<bool>();
46 }
47 if (!unscopables->IsSpecObject()) return Maybe<bool>(false);
48 return JSReceiver::HasOwnProperty(Handle<JSReceiver>::cast(unscopables),
49 it->name());
50 }
51
52
53 /**
54 * Lookups a property in an object environment, taking the unscopables into
55 * account. This is used For HasBinding and GetBindingValue spec algorithms for
56 * ObjectEnvironment.
57 */
58 static Maybe<PropertyAttributes> UnscopableLookup(LookupIterator* it) {
59 Isolate* isolate = it->isolate();
60 while (true) {
61 RETURN_ON_NO_VALUE(isolate, PropertyAttributes, attrs,
62 JSReceiver::GetPropertyAttributes(it));
63 if (attrs == ABSENT) break;
64 RETURN_ON_NO_VALUE_TYPE(isolate, bool, blocked, BlockedByUnscopables(it),
65 PropertyAttributes);
66 if (!blocked) return Maybe<PropertyAttributes>(attrs);
67 it->Next();
68 }
69
70 return Maybe<PropertyAttributes>(ABSENT);
71 }
72
73
74 #undef RETURN_ON_NO_VALUE
75 #undef RETURN_ON_NO_VALUE_TYPE
76 }
77 } // namespace v8::internal
78
79 #endif // V8_UNSCOPABLES_H_
OLDNEW
« no previous file with comments | « src/runtime.cc ('k') | test/cctest/cctest.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698