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

Side by Side Diff: src/ast/scopes.cc

Issue 1653083002: Devtools: expose scopes source location to debugger (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Address comments Created 4 years, 10 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 | « src/ast/scopes.h ('k') | src/debug/debug-scopes.h » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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/ast/scopes.h" 5 #include "src/ast/scopes.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/ast/scopeinfo.h" 8 #include "src/ast/scopeinfo.h"
9 #include "src/bootstrapper.h" 9 #include "src/bootstrapper.h"
10 #include "src/messages.h" 10 #include "src/messages.h"
(...skipping 800 matching lines...) Expand 10 before | Expand all | Expand 10 after
811 811
812 812
813 Handle<ScopeInfo> Scope::GetScopeInfo(Isolate* isolate) { 813 Handle<ScopeInfo> Scope::GetScopeInfo(Isolate* isolate) {
814 if (scope_info_.is_null()) { 814 if (scope_info_.is_null()) {
815 scope_info_ = ScopeInfo::Create(isolate, zone(), this); 815 scope_info_ = ScopeInfo::Create(isolate, zone(), this);
816 } 816 }
817 return scope_info_; 817 return scope_info_;
818 } 818 }
819 819
820 820
821 void Scope::GetNestedScopeChain(Isolate* isolate,
822 List<Handle<ScopeInfo> >* chain, int position) {
823 if (!is_eval_scope()) chain->Add(Handle<ScopeInfo>(GetScopeInfo(isolate)));
824
825 for (int i = 0; i < inner_scopes_.length(); i++) {
826 Scope* scope = inner_scopes_[i];
827 int beg_pos = scope->start_position();
828 int end_pos = scope->end_position();
829 DCHECK(beg_pos >= 0 && end_pos >= 0);
830 if (beg_pos <= position && position < end_pos) {
831 scope->GetNestedScopeChain(isolate, chain, position);
832 return;
833 }
834 }
835 }
836
837
838 void Scope::CollectNonLocals(HashMap* non_locals) { 821 void Scope::CollectNonLocals(HashMap* non_locals) {
839 // Collect non-local variables referenced in the scope. 822 // Collect non-local variables referenced in the scope.
840 // TODO(yangguo): store non-local variables explicitly if we can no longer 823 // TODO(yangguo): store non-local variables explicitly if we can no longer
841 // rely on unresolved_ to find them. 824 // rely on unresolved_ to find them.
842 for (int i = 0; i < unresolved_.length(); i++) { 825 for (int i = 0; i < unresolved_.length(); i++) {
843 VariableProxy* proxy = unresolved_[i]; 826 VariableProxy* proxy = unresolved_[i];
844 if (proxy->is_resolved() && proxy->var()->IsStackAllocated()) continue; 827 if (proxy->is_resolved() && proxy->var()->IsStackAllocated()) continue;
845 Handle<String> name = proxy->name(); 828 Handle<String> name = proxy->name();
846 void* key = reinterpret_cast<void*>(name.location()); 829 void* key = reinterpret_cast<void*>(name.location());
847 HashMap::Entry* entry = non_locals->LookupOrInsert(key, name->Hash()); 830 HashMap::Entry* entry = non_locals->LookupOrInsert(key, name->Hash());
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after
1547 function_ != NULL && function_->proxy()->var()->IsContextSlot(); 1530 function_ != NULL && function_->proxy()->var()->IsContextSlot();
1548 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - num_global_slots() - 1531 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - num_global_slots() -
1549 (is_function_var_in_context ? 1 : 0); 1532 (is_function_var_in_context ? 1 : 0);
1550 } 1533 }
1551 1534
1552 1535
1553 int Scope::ContextGlobalCount() const { return num_global_slots(); } 1536 int Scope::ContextGlobalCount() const { return num_global_slots(); }
1554 1537
1555 } // namespace internal 1538 } // namespace internal
1556 } // namespace v8 1539 } // namespace v8
OLDNEW
« no previous file with comments | « src/ast/scopes.h ('k') | src/debug/debug-scopes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698