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

Side by Side Diff: src/debug/debug-scopes.cc

Issue 2751573003: [debugger] correctly find inner function scope. (Closed)
Patch Set: Created 3 years, 9 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
« no previous file with comments | « no previous file | test/inspector/debugger/step-into-nested-arrow.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/ast.h" 9 #include "src/ast/ast.h"
10 #include "src/ast/scopes.h" 10 #include "src/ast/scopes.h"
(...skipping 820 matching lines...) Expand 10 before | Expand all | Expand 10 after
831 Object::GetPropertyOrElement(extension, key).ToHandleChecked(); 831 Object::GetPropertyOrElement(extension, key).ToHandleChecked();
832 JSObject::SetOwnPropertyIgnoreAttributes(scope_object, key, value, NONE) 832 JSObject::SetOwnPropertyIgnoreAttributes(scope_object, key, value, NONE)
833 .Check(); 833 .Check();
834 } 834 }
835 } 835 }
836 836
837 void ScopeIterator::GetNestedScopeChain(Isolate* isolate, Scope* scope, 837 void ScopeIterator::GetNestedScopeChain(Isolate* isolate, Scope* scope,
838 int position) { 838 int position) {
839 if (scope->is_function_scope()) { 839 if (scope->is_function_scope()) {
840 // Do not collect scopes of nested inner functions inside the current one. 840 // Do not collect scopes of nested inner functions inside the current one.
841 // Nested arrow functions could have the same end positions.
841 Handle<JSFunction> function = frame_inspector_->GetFunction(); 842 Handle<JSFunction> function = frame_inspector_->GetFunction();
842 if (scope->end_position() < function->shared()->end_position()) return; 843 if (scope->start_position() > function->shared()->start_position() &&
844 scope->end_position() <= function->shared()->end_position()) {
845 return;
846 }
843 } 847 }
844 if (scope->is_hidden()) { 848 if (scope->is_hidden()) {
845 // We need to add this chain element in case the scope has a context 849 // We need to add this chain element in case the scope has a context
846 // associated. We need to keep the scope chain and context chain in sync. 850 // associated. We need to keep the scope chain and context chain in sync.
847 nested_scope_chain_.Add(ExtendedScopeInfo(scope->scope_info())); 851 nested_scope_chain_.Add(ExtendedScopeInfo(scope->scope_info()));
848 } else { 852 } else {
849 nested_scope_chain_.Add(ExtendedScopeInfo( 853 nested_scope_chain_.Add(ExtendedScopeInfo(
850 scope->scope_info(), scope->start_position(), scope->end_position())); 854 scope->scope_info(), scope->start_position(), scope->end_position()));
851 } 855 }
852 for (Scope* inner_scope = scope->inner_scope(); inner_scope != nullptr; 856 for (Scope* inner_scope = scope->inner_scope(); inner_scope != nullptr;
853 inner_scope = inner_scope->sibling()) { 857 inner_scope = inner_scope->sibling()) {
854 int beg_pos = inner_scope->start_position(); 858 int beg_pos = inner_scope->start_position();
855 int end_pos = inner_scope->end_position(); 859 int end_pos = inner_scope->end_position();
856 DCHECK((beg_pos >= 0 && end_pos >= 0) || inner_scope->is_hidden()); 860 DCHECK((beg_pos >= 0 && end_pos >= 0) || inner_scope->is_hidden());
857 if (beg_pos <= position && position < end_pos) { 861 if (beg_pos <= position && position < end_pos) {
858 GetNestedScopeChain(isolate, inner_scope, position); 862 GetNestedScopeChain(isolate, inner_scope, position);
859 return; 863 return;
860 } 864 }
861 } 865 }
862 } 866 }
863 867
864 } // namespace internal 868 } // namespace internal
865 } // namespace v8 869 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/inspector/debugger/step-into-nested-arrow.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698