OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/bootstrapper.h" | 7 #include "src/bootstrapper.h" |
8 #include "src/debug.h" | 8 #include "src/debug.h" |
9 #include "src/scopeinfo.h" | 9 #include "src/scopeinfo.h" |
10 | 10 |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 Maybe<PropertyAttributes> attrs = JSReceiver::GetPropertyAttributes(it); | 124 Maybe<PropertyAttributes> attrs = JSReceiver::GetPropertyAttributes(it); |
125 DCHECK(attrs.has_value || isolate->has_pending_exception()); | 125 DCHECK(attrs.has_value || isolate->has_pending_exception()); |
126 if (!attrs.has_value || attrs.value == ABSENT) return attrs; | 126 if (!attrs.has_value || attrs.value == ABSENT) return attrs; |
127 | 127 |
128 Handle<Symbol> unscopables_symbol = isolate->factory()->unscopables_symbol(); | 128 Handle<Symbol> unscopables_symbol = isolate->factory()->unscopables_symbol(); |
129 Handle<Object> receiver = it->GetReceiver(); | 129 Handle<Object> receiver = it->GetReceiver(); |
130 Handle<Object> unscopables; | 130 Handle<Object> unscopables; |
131 MaybeHandle<Object> maybe_unscopables = | 131 MaybeHandle<Object> maybe_unscopables = |
132 Object::GetProperty(receiver, unscopables_symbol); | 132 Object::GetProperty(receiver, unscopables_symbol); |
133 if (!maybe_unscopables.ToHandle(&unscopables)) { | 133 if (!maybe_unscopables.ToHandle(&unscopables)) { |
134 return Maybe<PropertyAttributes>(); | 134 return Nothing<PropertyAttributes>(); |
135 } | 135 } |
136 if (!unscopables->IsSpecObject()) return attrs; | 136 if (!unscopables->IsSpecObject()) return attrs; |
137 Handle<Object> blacklist; | 137 Handle<Object> blacklist; |
138 MaybeHandle<Object> maybe_blacklist = | 138 MaybeHandle<Object> maybe_blacklist = |
139 Object::GetProperty(unscopables, it->name()); | 139 Object::GetProperty(unscopables, it->name()); |
140 if (!maybe_blacklist.ToHandle(&blacklist)) { | 140 if (!maybe_blacklist.ToHandle(&blacklist)) { |
141 DCHECK(isolate->has_pending_exception()); | 141 DCHECK(isolate->has_pending_exception()); |
142 return Maybe<PropertyAttributes>(); | 142 return Nothing<PropertyAttributes>(); |
143 } | 143 } |
144 if (!blacklist->IsUndefined()) return maybe(ABSENT); | 144 return blacklist->IsUndefined() ? attrs : Just(ABSENT); |
145 return attrs; | |
146 } | 145 } |
147 | 146 |
148 static void GetAttributesAndBindingFlags(VariableMode mode, | 147 static void GetAttributesAndBindingFlags(VariableMode mode, |
149 InitializationFlag init_flag, | 148 InitializationFlag init_flag, |
150 PropertyAttributes* attributes, | 149 PropertyAttributes* attributes, |
151 BindingFlags* binding_flags) { | 150 BindingFlags* binding_flags) { |
152 switch (mode) { | 151 switch (mode) { |
153 case INTERNAL: // Fall through. | 152 case INTERNAL: // Fall through. |
154 case VAR: | 153 case VAR: |
155 *attributes = NONE; | 154 *attributes = NONE; |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 GetAttributesAndBindingFlags(r.mode, r.init_flag, attributes, | 246 GetAttributesAndBindingFlags(r.mode, r.init_flag, attributes, |
248 binding_flags); | 247 binding_flags); |
249 return ScriptContextTable::GetContext(script_contexts, | 248 return ScriptContextTable::GetContext(script_contexts, |
250 r.context_index); | 249 r.context_index); |
251 } | 250 } |
252 } | 251 } |
253 | 252 |
254 // Context extension objects needs to behave as if they have no | 253 // Context extension objects needs to behave as if they have no |
255 // prototype. So even if we want to follow prototype chains, we need | 254 // prototype. So even if we want to follow prototype chains, we need |
256 // to only do a local lookup for context extension objects. | 255 // to only do a local lookup for context extension objects. |
257 Maybe<PropertyAttributes> maybe; | 256 Maybe<PropertyAttributes> maybe = Nothing<PropertyAttributes>(); |
258 if ((flags & FOLLOW_PROTOTYPE_CHAIN) == 0 || | 257 if ((flags & FOLLOW_PROTOTYPE_CHAIN) == 0 || |
259 object->IsJSContextExtensionObject()) { | 258 object->IsJSContextExtensionObject()) { |
260 maybe = JSReceiver::GetOwnPropertyAttributes(object, name); | 259 maybe = JSReceiver::GetOwnPropertyAttributes(object, name); |
261 } else if (context->IsWithContext()) { | 260 } else if (context->IsWithContext()) { |
262 LookupIterator it(object, name); | 261 LookupIterator it(object, name); |
263 maybe = UnscopableLookup(&it); | 262 maybe = UnscopableLookup(&it); |
264 } else { | 263 } else { |
265 maybe = JSReceiver::GetPropertyAttributes(object, name); | 264 maybe = JSReceiver::GetPropertyAttributes(object, name); |
266 } | 265 } |
267 | 266 |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 bool Context::IsBootstrappingOrGlobalObject(Isolate* isolate, Object* object) { | 488 bool Context::IsBootstrappingOrGlobalObject(Isolate* isolate, Object* object) { |
490 // During bootstrapping we allow all objects to pass as global | 489 // During bootstrapping we allow all objects to pass as global |
491 // objects. This is necessary to fix circular dependencies. | 490 // objects. This is necessary to fix circular dependencies. |
492 return isolate->heap()->gc_state() != Heap::NOT_IN_GC || | 491 return isolate->heap()->gc_state() != Heap::NOT_IN_GC || |
493 isolate->bootstrapper()->IsActive() || | 492 isolate->bootstrapper()->IsActive() || |
494 object->IsGlobalObject(); | 493 object->IsGlobalObject(); |
495 } | 494 } |
496 #endif | 495 #endif |
497 | 496 |
498 } } // namespace v8::internal | 497 } } // namespace v8::internal |
OLD | NEW |