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

Unified Diff: src/preparser.h

Issue 1272673003: [es6] Re-implement rest parameters via desugaring. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 4 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
« src/parser.cc ('K') | « src/parser.cc ('k') | src/runtime/runtime.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/preparser.h
diff --git a/src/preparser.h b/src/preparser.h
index d240db1b912955a87b75052b7cf6571b005f494f..938fd3f1620466e90d420d2b34b8a525909b6833 100644
--- a/src/preparser.h
+++ b/src/preparser.h
@@ -33,6 +33,7 @@ struct FormalParametersBase {
bool has_rest = false;
bool is_simple = true;
int materialized_literals_count = 0;
+ int rest_array_literal_index = 0;
};
@@ -3654,10 +3655,14 @@ void ParserBase<Traits>::ParseFormalParameter(
parameters->is_simple = !is_rest && Traits::IsIdentifier(pattern);
}
parameters->has_rest = is_rest;
- if (is_rest && !Traits::IsIdentifier(pattern)) {
- ReportUnexpectedToken(next);
- *ok = false;
- return;
+ if (is_rest) {
+ if (!Traits::IsIdentifier(pattern)) {
+ ReportUnexpectedToken(next);
+ *ok = false;
+ return;
+ }
+ parameters->rest_array_literal_index =
+ function_state_->NextMaterializedLiteralIndex();
}
Traits::AddFormalParameter(parameters, pattern, is_rest);
}
« src/parser.cc ('K') | « src/parser.cc ('k') | src/runtime/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698