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

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

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