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 <memory> | 7 #include <memory> |
8 | 8 |
9 #include "src/ast/scopes.h" | 9 #include "src/ast/scopes.h" |
10 #include "src/compiler.h" | 10 #include "src/compiler.h" |
(...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
785 Handle<String> key(String::cast(keys->get(i))); | 785 Handle<String> key(String::cast(keys->get(i))); |
786 Handle<Object> value = | 786 Handle<Object> value = |
787 Object::GetPropertyOrElement(extension, key).ToHandleChecked(); | 787 Object::GetPropertyOrElement(extension, key).ToHandleChecked(); |
788 JSObject::SetOwnPropertyIgnoreAttributes(scope_object, key, value, NONE) | 788 JSObject::SetOwnPropertyIgnoreAttributes(scope_object, key, value, NONE) |
789 .Check(); | 789 .Check(); |
790 } | 790 } |
791 } | 791 } |
792 | 792 |
793 void ScopeIterator::GetNestedScopeChain(Isolate* isolate, Scope* scope, | 793 void ScopeIterator::GetNestedScopeChain(Isolate* isolate, Scope* scope, |
794 int position) { | 794 int position) { |
| 795 if (scope->is_function_scope()) { |
| 796 // Do not collect scopes of nested inner functions inside the current one. |
| 797 Handle<JSFunction> function = frame_inspector_->GetFunction(); |
| 798 if (scope->end_position() < function->shared()->end_position()) return; |
| 799 } |
795 if (scope->is_hidden()) { | 800 if (scope->is_hidden()) { |
796 // We need to add this chain element in case the scope has a context | 801 // We need to add this chain element in case the scope has a context |
797 // associated. We need to keep the scope chain and context chain in sync. | 802 // associated. We need to keep the scope chain and context chain in sync. |
798 nested_scope_chain_.Add(ExtendedScopeInfo(scope->GetScopeInfo(isolate))); | 803 nested_scope_chain_.Add(ExtendedScopeInfo(scope->GetScopeInfo(isolate))); |
799 } else { | 804 } else { |
800 nested_scope_chain_.Add(ExtendedScopeInfo(scope->GetScopeInfo(isolate), | 805 nested_scope_chain_.Add(ExtendedScopeInfo(scope->GetScopeInfo(isolate), |
801 scope->start_position(), | 806 scope->start_position(), |
802 scope->end_position())); | 807 scope->end_position())); |
803 } | 808 } |
804 for (Scope* inner_scope = scope->inner_scope(); inner_scope != nullptr; | 809 for (Scope* inner_scope = scope->inner_scope(); inner_scope != nullptr; |
805 inner_scope = inner_scope->sibling()) { | 810 inner_scope = inner_scope->sibling()) { |
806 int beg_pos = inner_scope->start_position(); | 811 int beg_pos = inner_scope->start_position(); |
807 int end_pos = inner_scope->end_position(); | 812 int end_pos = inner_scope->end_position(); |
808 DCHECK((beg_pos >= 0 && end_pos >= 0) || inner_scope->is_hidden()); | 813 DCHECK((beg_pos >= 0 && end_pos >= 0) || inner_scope->is_hidden()); |
809 if (beg_pos <= position && position < end_pos) { | 814 if (beg_pos <= position && position < end_pos) { |
810 GetNestedScopeChain(isolate, inner_scope, position); | 815 GetNestedScopeChain(isolate, inner_scope, position); |
811 return; | 816 return; |
812 } | 817 } |
813 } | 818 } |
814 } | 819 } |
815 | 820 |
816 } // namespace internal | 821 } // namespace internal |
817 } // namespace v8 | 822 } // namespace v8 |
OLD | NEW |