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

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

Issue 2216563003: Remove redundant ParseInfo::scope_. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase. Created 4 years, 4 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 | src/compiler.cc » ('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 <set> 7 #include <set>
8 8
9 #include "src/accessors.h" 9 #include "src/accessors.h"
10 #include "src/bootstrapper.h" 10 #include "src/bootstrapper.h"
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 DCHECK(is_declaration_scope()); 361 DCHECK(is_declaration_scope());
362 return static_cast<const DeclarationScope*>(this); 362 return static_cast<const DeclarationScope*>(this);
363 } 363 }
364 364
365 int Scope::num_parameters() const { 365 int Scope::num_parameters() const {
366 return is_declaration_scope() ? AsDeclarationScope()->num_parameters() : 0; 366 return is_declaration_scope() ? AsDeclarationScope()->num_parameters() : 0;
367 } 367 }
368 368
369 bool Scope::Analyze(ParseInfo* info) { 369 bool Scope::Analyze(ParseInfo* info) {
370 DCHECK(info->literal() != NULL); 370 DCHECK(info->literal() != NULL);
371 DCHECK(info->scope() == NULL);
372 DeclarationScope* scope = info->literal()->scope(); 371 DeclarationScope* scope = info->literal()->scope();
373 DeclarationScope* top = scope; 372 DeclarationScope* top = scope;
374 373
375 // Traverse the scope tree up to the first unresolved scope or the global 374 // Traverse the scope tree up to the first unresolved scope or the global
376 // scope and start scope resolution and variable allocation from that scope. 375 // scope and start scope resolution and variable allocation from that scope.
377 // Such a scope is always a closure-scope, so always skip to the next closure 376 // Such a scope is always a closure-scope, so always skip to the next closure
378 // scope. 377 // scope.
379 while (!top->is_script_scope() && 378 while (!top->is_script_scope() &&
380 !top->outer_scope()->already_resolved()) { 379 !top->outer_scope()->already_resolved()) {
381 top = top->outer_scope()->GetClosureScope(); 380 top = top->outer_scope()->GetClosureScope();
382 } 381 }
383 382
384 // Allocate the variables. 383 // Allocate the variables.
385 { 384 {
386 AstNodeFactory ast_node_factory(info->ast_value_factory()); 385 AstNodeFactory ast_node_factory(info->ast_value_factory());
387 if (!top->AllocateVariables(info, &ast_node_factory)) return false; 386 if (!top->AllocateVariables(info, &ast_node_factory)) return false;
388 } 387 }
389 388
390 #ifdef DEBUG 389 #ifdef DEBUG
391 if (info->script_is_native() ? FLAG_print_builtin_scopes 390 if (info->script_is_native() ? FLAG_print_builtin_scopes
392 : FLAG_print_scopes) { 391 : FLAG_print_scopes) {
393 scope->Print(); 392 scope->Print();
394 } 393 }
395 scope->CheckScopePositions(); 394 scope->CheckScopePositions();
396 scope->CheckZones(); 395 scope->CheckZones();
397 #endif 396 #endif
398 397
399 info->set_scope(scope);
400 return true; 398 return true;
401 } 399 }
402 400
403 void DeclarationScope::DeclareThis(AstValueFactory* ast_value_factory) { 401 void DeclarationScope::DeclareThis(AstValueFactory* ast_value_factory) {
404 DCHECK(!already_resolved()); 402 DCHECK(!already_resolved());
405 DCHECK(is_declaration_scope()); 403 DCHECK(is_declaration_scope());
406 DCHECK(has_this_declaration()); 404 DCHECK(has_this_declaration());
407 405
408 bool subclass_constructor = IsSubclassConstructor(function_kind_); 406 bool subclass_constructor = IsSubclassConstructor(function_kind_);
409 Variable* var = variables_.Declare( 407 Variable* var = variables_.Declare(
(...skipping 1371 matching lines...) Expand 10 before | Expand all | Expand 10 after
1781 function != NULL && function->proxy()->var()->IsContextSlot(); 1779 function != NULL && function->proxy()->var()->IsContextSlot();
1782 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - num_global_slots() - 1780 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - num_global_slots() -
1783 (is_function_var_in_context ? 1 : 0); 1781 (is_function_var_in_context ? 1 : 0);
1784 } 1782 }
1785 1783
1786 1784
1787 int Scope::ContextGlobalCount() const { return num_global_slots(); } 1785 int Scope::ContextGlobalCount() const { return num_global_slots(); }
1788 1786
1789 } // namespace internal 1787 } // namespace internal
1790 } // namespace v8 1788 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698