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 #include "src/unscopables.h" |
10 | 11 |
11 namespace v8 { | 12 namespace v8 { |
12 namespace internal { | 13 namespace internal { |
13 | 14 |
14 Context* Context::declaration_context() { | 15 Context* Context::declaration_context() { |
15 Context* current = this; | 16 Context* current = this; |
16 while (!current->IsFunctionContext() && !current->IsNativeContext()) { | 17 while (!current->IsFunctionContext() && !current->IsNativeContext()) { |
17 current = current->previous(); | 18 current = current->previous(); |
18 ASSERT(current->closure() == closure()); | 19 ASSERT(current->closure() == closure()); |
19 } | 20 } |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 context->IsWithContext() || | 103 context->IsWithContext() || |
103 (context->IsFunctionContext() && context->has_extension())) { | 104 (context->IsFunctionContext() && context->has_extension())) { |
104 Handle<JSReceiver> object( | 105 Handle<JSReceiver> object( |
105 JSReceiver::cast(context->extension()), isolate); | 106 JSReceiver::cast(context->extension()), isolate); |
106 // Context extension objects needs to behave as if they have no | 107 // Context extension objects needs to behave as if they have no |
107 // prototype. So even if we want to follow prototype chains, we need | 108 // prototype. So even if we want to follow prototype chains, we need |
108 // to only do a local lookup for context extension objects. | 109 // to only do a local lookup for context extension objects. |
109 if ((flags & FOLLOW_PROTOTYPE_CHAIN) == 0 || | 110 if ((flags & FOLLOW_PROTOTYPE_CHAIN) == 0 || |
110 object->IsJSContextExtensionObject()) { | 111 object->IsJSContextExtensionObject()) { |
111 *attributes = JSReceiver::GetOwnPropertyAttributes(object, name); | 112 *attributes = JSReceiver::GetOwnPropertyAttributes(object, name); |
| 113 } else if (FLAG_harmony_unscopables && context->IsWithContext()) { |
| 114 bool ok; |
| 115 Handle<JSReceiver> holder; |
| 116 *attributes = UnscopableLookup(isolate, object, name, &holder, &ok); |
112 } else { | 117 } else { |
113 *attributes = JSReceiver::GetPropertyAttributes(object, name); | 118 *attributes = JSReceiver::GetPropertyAttributes(object, name); |
114 } | 119 } |
| 120 |
115 if (isolate->has_pending_exception()) return Handle<Object>(); | 121 if (isolate->has_pending_exception()) return Handle<Object>(); |
116 | 122 |
117 if (*attributes != ABSENT) { | 123 if (*attributes != ABSENT) { |
118 if (FLAG_trace_contexts) { | 124 if (FLAG_trace_contexts) { |
119 PrintF("=> found property in context object %p\n", | 125 PrintF("=> found property in context object %p\n", |
120 reinterpret_cast<void*>(*object)); | 126 reinterpret_cast<void*>(*object)); |
121 } | 127 } |
122 return object; | 128 return object; |
123 } | 129 } |
124 } | 130 } |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 bool Context::IsBootstrappingOrGlobalObject(Isolate* isolate, Object* object) { | 373 bool Context::IsBootstrappingOrGlobalObject(Isolate* isolate, Object* object) { |
368 // During bootstrapping we allow all objects to pass as global | 374 // During bootstrapping we allow all objects to pass as global |
369 // objects. This is necessary to fix circular dependencies. | 375 // objects. This is necessary to fix circular dependencies. |
370 return isolate->heap()->gc_state() != Heap::NOT_IN_GC || | 376 return isolate->heap()->gc_state() != Heap::NOT_IN_GC || |
371 isolate->bootstrapper()->IsActive() || | 377 isolate->bootstrapper()->IsActive() || |
372 object->IsGlobalObject(); | 378 object->IsGlobalObject(); |
373 } | 379 } |
374 #endif | 380 #endif |
375 | 381 |
376 } } // namespace v8::internal | 382 } } // namespace v8::internal |
OLD | NEW |