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

Unified Diff: src/parser.cc

Issue 1212473002: [destructuring] Re-index materialized literals in arrow function parameters. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: CR feedback Created 5 years, 6 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/parser.h ('k') | src/preparser.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parser.cc
diff --git a/src/parser.cc b/src/parser.cc
index f450608259a9ae845280f38a274eb103771deddc..9744252b3c7d904b6e8fff5935201453ae17025a 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -6,6 +6,7 @@
#include "src/api.h"
#include "src/ast.h"
+#include "src/ast-literal-reindexer.h"
#include "src/bailout-reason.h"
#include "src/base/platform/platform.h"
#include "src/bootstrapper.h"
@@ -1180,6 +1181,7 @@ FunctionLiteral* Parser::ParseLazy(Isolate* isolate, ParseInfo* info,
scope->set_start_position(shared_info->start_position());
ExpressionClassifier formals_classifier;
ParserFormalParameterParsingState parsing_state(scope);
+ Checkpoint checkpoint(this);
{
// Parsing patterns as variable reference expression creates
// NewUnresolved references in current scope. Entrer arrow function
@@ -1198,6 +1200,7 @@ FunctionLiteral* Parser::ParseLazy(Isolate* isolate, ParseInfo* info,
}
if (ok) {
+ checkpoint.Restore(&parsing_state.materialized_literals_count);
Expression* expression =
ParseArrowFunctionLiteral(parsing_state, formals_classifier, &ok);
if (ok) {
@@ -3854,6 +3857,20 @@ void ParserTraits::ParseArrowFunctionFormalParameters(
}
+void ParserTraits::ReindexLiterals(
+ const ParserFormalParameterParsingState& parsing_state) {
+ if (parser_->function_state_->materialized_literal_count() > 0) {
+ AstLiteralReindexer reindexer;
+
+ for (const auto p : parsing_state.params) {
+ if (p.pattern != nullptr) reindexer.Reindex(p.pattern);
+ }
+ DCHECK(reindexer.count() <=
+ parser_->function_state_->materialized_literal_count());
+ }
+}
+
+
FunctionLiteral* Parser::ParseFunctionLiteral(
const AstRawString* function_name, Scanner::Location function_name_location,
bool name_is_strict_reserved, FunctionKind kind, int function_token_pos,
« no previous file with comments | « src/parser.h ('k') | src/preparser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698