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

Unified Diff: src/parsing/preparser.cc

Issue 2623583004: PreParser scope analysis: simplify DeclareAndInitializeVariables. (Closed)
Patch Set: Created 3 years, 11 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 | « no previous file | test/cctest/test-parsing.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parsing/preparser.cc
diff --git a/src/parsing/preparser.cc b/src/parsing/preparser.cc
index cc7f9f52bdf4dc73528ff0683fca60d74cec8f3f..7f859d2bbe8cc741a734600041d11f8f47a3e0c1 100644
--- a/src/parsing/preparser.cc
+++ b/src/parsing/preparser.cc
@@ -297,26 +297,12 @@ void PreParser::DeclareAndInitializeVariables(
ZoneList<const AstRawString*>* names, bool* ok) {
if (declaration->pattern.variables_ != nullptr) {
DCHECK(FLAG_lazy_inner_functions);
- /* Mimic what Parser does when declaring variables (see
- Parser::PatternRewriter::VisitVariableProxy).
-
- var + no initializer -> RemoveUnresolved
- let / const + no initializer -> RemoveUnresolved
- var + initializer -> RemoveUnresolved followed by NewUnresolved
- let / const + initializer -> RemoveUnresolved
- */
Scope* scope = declaration_descriptor->hoist_scope;
if (scope == nullptr) {
scope = this->scope();
}
- if (declaration->initializer.IsEmpty() ||
- (declaration_descriptor->mode == VariableMode::LET ||
- declaration_descriptor->mode == VariableMode::CONST)) {
- for (auto variable : *(declaration->pattern.variables_)) {
- declaration_descriptor->scope->RemoveUnresolved(variable);
- }
- }
for (auto variable : *(declaration->pattern.variables_)) {
+ declaration_descriptor->scope->RemoveUnresolved(variable);
scope->DeclareVariableName(variable->raw_name(),
declaration_descriptor->mode);
}
« no previous file with comments | « no previous file | test/cctest/test-parsing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698