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

Unified Diff: src/ast/scopes.cc

Issue 2165923002: Inline Scope::Initialize into the only constructor that's always called right before (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/ast/scopes.h ('k') | src/parsing/parser-base.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ast/scopes.cc
diff --git a/src/ast/scopes.cc b/src/ast/scopes.cc
index b01c2ff5f6d55c71401e92fc44fa06920bedba14..27ea35986a5fcb37eeac8ea2a944a4ab36a39c18 100644
--- a/src/ast/scopes.cc
+++ b/src/ast/scopes.cc
@@ -98,17 +98,20 @@ Scope::Scope(Zone* zone, Scope* outer_scope, ScopeType scope_type,
sloppy_block_function_map_(zone),
already_resolved_(false) {
SetDefaults();
- if (outer_scope != nullptr) {
+ if (outer_scope == nullptr) {
+ // If the outer scope is null, this cannot be a with scope. The outermost
+ // scope must be a script scope.
+ DCHECK_EQ(SCRIPT_SCOPE, scope_type);
+ } else {
asm_function_ = outer_scope_->asm_module_;
// Inherit the language mode from the parent scope unless we're a module
// scope.
if (!is_module_scope()) language_mode_ = outer_scope->language_mode_;
force_context_allocation_ =
!is_function_scope() && outer_scope->has_forced_context_allocation();
+ outer_scope_->inner_scopes_.Add(this, zone);
+ scope_inside_with_ = outer_scope_->scope_inside_with_ || is_with_scope();
}
-
- // The outermost scope must be a script scope.
- DCHECK(scope_type == SCRIPT_SCOPE || outer_scope != nullptr);
}
Scope::Scope(Zone* zone, Scope* inner_scope, ScopeType scope_type,
@@ -284,17 +287,6 @@ bool Scope::Analyze(ParseInfo* info) {
return true;
}
-
-void Scope::Initialize() {
- DCHECK(!already_resolved());
- if (outer_scope_ == nullptr) {
- scope_inside_with_ = is_with_scope();
- } else {
- outer_scope_->inner_scopes_.Add(this, zone());
- scope_inside_with_ = outer_scope_->scope_inside_with_ || is_with_scope();
- }
-}
-
void Scope::DeclareThis(AstValueFactory* ast_value_factory) {
DCHECK(!already_resolved());
DCHECK(is_declaration_scope());
« no previous file with comments | « src/ast/scopes.h ('k') | src/parsing/parser-base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698