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

Unified Diff: src/parsing/parser.cc

Issue 2168563002: Implicitly pass 'scope()' as parent scope for function scopes (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/parsing/parser.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/parsing/parser.cc
diff --git a/src/parsing/parser.cc b/src/parsing/parser.cc
index 6b4848dc4074cd46a9ffe00c635b2eb1fcffd2d6..37e62c30907a9ce5d3905706c1474220b59e8ed3 100644
--- a/src/parsing/parser.cc
+++ b/src/parsing/parser.cc
@@ -200,8 +200,8 @@ void Parser::SetCachedData(ParseInfo* info) {
}
FunctionLiteral* Parser::DefaultConstructor(const AstRawString* name,
- bool call_super, Scope* scope,
- int pos, int end_pos,
+ bool call_super, int pos,
+ int end_pos,
LanguageMode language_mode) {
int materialized_literal_count = -1;
int expected_property_count = -1;
@@ -210,7 +210,7 @@ FunctionLiteral* Parser::DefaultConstructor(const AstRawString* name,
FunctionKind kind = call_super ? FunctionKind::kDefaultSubclassConstructor
: FunctionKind::kDefaultBaseConstructor;
- Scope* function_scope = NewFunctionScope(scope, kind);
+ Scope* function_scope = NewFunctionScope(kind);
SetLanguageMode(function_scope,
static_cast<LanguageMode>(language_mode | STRICT));
// Set start and end position to the same value
@@ -1138,8 +1138,7 @@ FunctionLiteral* Parser::ParseLazy(Isolate* isolate, ParseInfo* info,
}
// TODO(adamk): We should construct this scope from the ScopeInfo.
- Scope* scope =
- NewFunctionScope(this->scope(), FunctionKind::kArrowFunction);
+ Scope* scope = NewFunctionScope(FunctionKind::kArrowFunction);
// These two bits only need to be explicitly set because we're
// not passing the ScopeInfo to the Scope constructor.
@@ -1197,8 +1196,9 @@ FunctionLiteral* Parser::ParseLazy(Isolate* isolate, ParseInfo* info,
}
}
} else if (shared_info->is_default_constructor()) {
+ DCHECK_EQ(this->scope(), scope);
result = DefaultConstructor(
- raw_name, IsSubclassConstructor(shared_info->kind()), scope,
+ raw_name, IsSubclassConstructor(shared_info->kind()),
shared_info->start_position(), shared_info->end_position(),
shared_info->language_mode());
} else {
@@ -4294,7 +4294,7 @@ FunctionLiteral* Parser::ParseFunctionLiteral(
function_name = ast_value_factory()->empty_string();
}
- Scope* scope = NewFunctionScope(this->scope(), kind);
+ Scope* scope = NewFunctionScope(kind);
SetLanguageMode(scope, language_mode);
ZoneList<Statement*>* body = NULL;
int arity = -1;
@@ -5091,8 +5091,9 @@ ClassLiteral* Parser::ParseClassLiteral(ExpressionClassifier* classifier,
int end_pos = scanner()->location().end_pos;
if (constructor == NULL) {
- constructor = DefaultConstructor(name, has_extends, block_scope, pos,
- end_pos, block_scope->language_mode());
+ DCHECK_EQ(this->scope(), block_scope);
+ constructor = DefaultConstructor(name, has_extends, pos, end_pos,
+ block_scope->language_mode());
}
// Note that we do not finalize this block scope because it is
« no previous file with comments | « src/parsing/parser.h ('k') | src/parsing/parser-base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698