OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/debug/debug-scopes.h" | 5 #include "src/debug/debug-scopes.h" |
6 | 6 |
7 #include "src/ast/scopes.h" | 7 #include "src/ast/scopes.h" |
8 #include "src/debug/debug.h" | 8 #include "src/debug/debug.h" |
9 #include "src/frames-inl.h" | 9 #include "src/frames-inl.h" |
10 #include "src/globals.h" | 10 #include "src/globals.h" |
(...skipping 783 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
794 } | 794 } |
795 | 795 |
796 | 796 |
797 void ScopeIterator::CopyContextLocalsToScopeObject( | 797 void ScopeIterator::CopyContextLocalsToScopeObject( |
798 Handle<ScopeInfo> scope_info, Handle<Context> context, | 798 Handle<ScopeInfo> scope_info, Handle<Context> context, |
799 Handle<JSObject> scope_object) { | 799 Handle<JSObject> scope_object) { |
800 Isolate* isolate = scope_info->GetIsolate(); | 800 Isolate* isolate = scope_info->GetIsolate(); |
801 int local_count = scope_info->ContextLocalCount(); | 801 int local_count = scope_info->ContextLocalCount(); |
802 if (local_count == 0) return; | 802 if (local_count == 0) return; |
803 // Fill all context locals to the context extension. | 803 // Fill all context locals to the context extension. |
804 int first_context_var = scope_info->StackLocalCount(); | |
805 int start = scope_info->ContextLocalNameEntriesIndex(); | |
806 for (int i = 0; i < local_count; ++i) { | 804 for (int i = 0; i < local_count; ++i) { |
807 if (scope_info->LocalIsSynthetic(first_context_var + i)) continue; | 805 Handle<String> name(scope_info->ContextLocalName(i)); |
| 806 if (ScopeInfo::VariableIsSynthetic(*name)) continue; |
808 int context_index = Context::MIN_CONTEXT_SLOTS + i; | 807 int context_index = Context::MIN_CONTEXT_SLOTS + i; |
809 Handle<Object> value = Handle<Object>(context->get(context_index), isolate); | 808 Handle<Object> value = Handle<Object>(context->get(context_index), isolate); |
810 // Reflect variables under TDZ as undefined in scope object. | 809 // Reflect variables under TDZ as undefined in scope object. |
811 if (value->IsTheHole()) continue; | 810 if (value->IsTheHole()) continue; |
812 // This should always succeed. | 811 // This should always succeed. |
813 // TODO(verwaest): Use AddDataProperty instead. | 812 // TODO(verwaest): Use AddDataProperty instead. |
814 JSObject::SetOwnPropertyIgnoreAttributes( | 813 JSObject::SetOwnPropertyIgnoreAttributes(scope_object, name, value, NONE) |
815 scope_object, handle(String::cast(scope_info->get(i + start))), value, | |
816 NONE) | |
817 .Check(); | 814 .Check(); |
818 } | 815 } |
819 } | 816 } |
820 | 817 |
821 bool ScopeIterator::CopyContextExtensionToScopeObject( | 818 bool ScopeIterator::CopyContextExtensionToScopeObject( |
822 Handle<JSObject> extension, Handle<JSObject> scope_object, | 819 Handle<JSObject> extension, Handle<JSObject> scope_object, |
823 KeyCollectionType type) { | 820 KeyCollectionType type) { |
824 Handle<FixedArray> keys; | 821 Handle<FixedArray> keys; |
825 ASSIGN_RETURN_ON_EXCEPTION_VALUE( | 822 ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
826 isolate_, keys, JSReceiver::GetKeys(extension, type, ENUMERABLE_STRINGS), | 823 isolate_, keys, JSReceiver::GetKeys(extension, type, ENUMERABLE_STRINGS), |
(...skipping 27 matching lines...) Expand all Loading... |
854 DCHECK((beg_pos >= 0 && end_pos >= 0) || inner_scope->is_hidden()); | 851 DCHECK((beg_pos >= 0 && end_pos >= 0) || inner_scope->is_hidden()); |
855 if (beg_pos <= position && position < end_pos) { | 852 if (beg_pos <= position && position < end_pos) { |
856 GetNestedScopeChain(isolate, inner_scope, position); | 853 GetNestedScopeChain(isolate, inner_scope, position); |
857 return; | 854 return; |
858 } | 855 } |
859 } | 856 } |
860 } | 857 } |
861 | 858 |
862 } // namespace internal | 859 } // namespace internal |
863 } // namespace v8 | 860 } // namespace v8 |
OLD | NEW |