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

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

Issue 1834633003: [debugger] allow debug-evaluate to change stack and context values. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: address comments Created 4 years, 8 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/contexts.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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 } 201 }
202 } 202 }
203 203
204 204
205 Scope* Scope::DeserializeScopeChain(Isolate* isolate, Zone* zone, 205 Scope* Scope::DeserializeScopeChain(Isolate* isolate, Zone* zone,
206 Context* context, Scope* script_scope) { 206 Context* context, Scope* script_scope) {
207 // Reconstruct the outer scope chain from a closure's context chain. 207 // Reconstruct the outer scope chain from a closure's context chain.
208 Scope* current_scope = NULL; 208 Scope* current_scope = NULL;
209 Scope* innermost_scope = NULL; 209 Scope* innermost_scope = NULL;
210 while (!context->IsNativeContext()) { 210 while (!context->IsNativeContext()) {
211 if (context->IsWithContext()) { 211 if (context->IsWithContext() || context->IsDebugEvaluateContext()) {
212 // For scope analysis, debug-evaluate is equivalent to a with scope.
212 Scope* with_scope = new (zone) 213 Scope* with_scope = new (zone)
213 Scope(zone, current_scope, WITH_SCOPE, Handle<ScopeInfo>::null(), 214 Scope(zone, current_scope, WITH_SCOPE, Handle<ScopeInfo>::null(),
214 script_scope->ast_value_factory_); 215 script_scope->ast_value_factory_);
215 current_scope = with_scope; 216 current_scope = with_scope;
216 // All the inner scopes are inside a with. 217 // All the inner scopes are inside a with.
217 for (Scope* s = innermost_scope; s != NULL; s = s->outer_scope()) { 218 for (Scope* s = innermost_scope; s != NULL; s = s->outer_scope()) {
218 s->scope_inside_with_ = true; 219 s->scope_inside_with_ = true;
219 } 220 }
220 } else if (context->IsScriptContext()) { 221 } else if (context->IsScriptContext()) {
221 ScopeInfo* scope_info = context->scope_info(); 222 ScopeInfo* scope_info = context->scope_info();
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after
783 784
784 785
785 786
786 Handle<ScopeInfo> Scope::GetScopeInfo(Isolate* isolate) { 787 Handle<ScopeInfo> Scope::GetScopeInfo(Isolate* isolate) {
787 if (scope_info_.is_null()) { 788 if (scope_info_.is_null()) {
788 scope_info_ = ScopeInfo::Create(isolate, zone(), this); 789 scope_info_ = ScopeInfo::Create(isolate, zone(), this);
789 } 790 }
790 return scope_info_; 791 return scope_info_;
791 } 792 }
792 793
793 794 Handle<StringSet> Scope::CollectNonLocals(Handle<StringSet> non_locals) {
794 void Scope::CollectNonLocals(HashMap* non_locals) {
795 // Collect non-local variables referenced in the scope. 795 // Collect non-local variables referenced in the scope.
796 // TODO(yangguo): store non-local variables explicitly if we can no longer 796 // TODO(yangguo): store non-local variables explicitly if we can no longer
797 // rely on unresolved_ to find them. 797 // rely on unresolved_ to find them.
798 for (int i = 0; i < unresolved_.length(); i++) { 798 for (int i = 0; i < unresolved_.length(); i++) {
799 VariableProxy* proxy = unresolved_[i]; 799 VariableProxy* proxy = unresolved_[i];
800 if (proxy->is_resolved() && proxy->var()->IsStackAllocated()) continue; 800 if (proxy->is_resolved() && proxy->var()->IsStackAllocated()) continue;
801 Handle<String> name = proxy->name(); 801 Handle<String> name = proxy->name();
802 void* key = reinterpret_cast<void*>(name.location()); 802 non_locals = StringSet::Add(non_locals, name);
803 HashMap::Entry* entry = non_locals->LookupOrInsert(key, name->Hash());
804 entry->value = key;
805 } 803 }
806 for (int i = 0; i < inner_scopes_.length(); i++) { 804 for (int i = 0; i < inner_scopes_.length(); i++) {
807 inner_scopes_[i]->CollectNonLocals(non_locals); 805 non_locals = inner_scopes_[i]->CollectNonLocals(non_locals);
808 } 806 }
807 return non_locals;
809 } 808 }
810 809
811 810
812 void Scope::ReportMessage(int start_position, int end_position, 811 void Scope::ReportMessage(int start_position, int end_position,
813 MessageTemplate::Template message, 812 MessageTemplate::Template message,
814 const AstRawString* arg) { 813 const AstRawString* arg) {
815 // Propagate the error to the topmost scope targeted by this scope analysis 814 // Propagate the error to the topmost scope targeted by this scope analysis
816 // phase. 815 // phase.
817 Scope* top = this; 816 Scope* top = this;
818 while (!top->is_script_scope() && !top->outer_scope()->already_resolved()) { 817 while (!top->is_script_scope() && !top->outer_scope()->already_resolved()) {
(...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after
1500 function_ != NULL && function_->proxy()->var()->IsContextSlot(); 1499 function_ != NULL && function_->proxy()->var()->IsContextSlot();
1501 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - num_global_slots() - 1500 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - num_global_slots() -
1502 (is_function_var_in_context ? 1 : 0); 1501 (is_function_var_in_context ? 1 : 0);
1503 } 1502 }
1504 1503
1505 1504
1506 int Scope::ContextGlobalCount() const { return num_global_slots(); } 1505 int Scope::ContextGlobalCount() const { return num_global_slots(); }
1507 1506
1508 } // namespace internal 1507 } // namespace internal
1509 } // namespace v8 1508 } // namespace v8
OLDNEW
« no previous file with comments | « src/ast/scopes.h ('k') | src/contexts.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698