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

Unified Diff: src/parsing/preparser.cc

Issue 2388183003: PreParsing inner functions: Fix declaration-only variables. (Closed)
Patch Set: flag off Created 4 years, 2 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/preparser.h ('k') | test/mjsunit/fixed-context-shapes-when-recompiling.js » ('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 963edcc7ab0c6bb15cbcf6873803c31ff012053d..88470f7fa91b66374738d402ff557cb7028eae12 100644
--- a/src/parsing/preparser.cc
+++ b/src/parsing/preparser.cc
@@ -231,6 +231,29 @@ PreParserExpression PreParser::ExpressionFromIdentifier(
return PreParserExpression::FromIdentifier(name);
}
+void PreParser::DeclareAndInitializeVariables(
+ PreParserStatement block,
+ const DeclarationDescriptor* declaration_descriptor,
+ const DeclarationParsingResult::Declaration* declaration,
+ ZoneList<const AstRawString*>* names, bool* ok) {
+ if (declaration->pattern.string_) {
+ /* Mimic what Parser does when declaring variables (see
+ Parser::PatternRewriter::VisitVariableProxy).
+
+ var + no initializer -> RemoveUnresolved
+ let + no initializer -> RemoveUnresolved
+ var + initializer -> RemoveUnresolved followed by NewUnresolved
+ let + initializer -> RemoveUnresolved
+ */
+
+ if (declaration->initializer.IsEmpty() ||
+ declaration_descriptor->mode == VariableMode::LET) {
+ declaration_descriptor->scope->RemoveUnresolved(
+ declaration->pattern.string_);
+ }
+ }
+}
+
#undef CHECK_OK
#undef CHECK_OK_CUSTOM
« no previous file with comments | « src/parsing/preparser.h ('k') | test/mjsunit/fixed-context-shapes-when-recompiling.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698