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

Unified Diff: src/preparser.h

Issue 1407633002: [es6] parse arrow ConciseBody with accept_IN flag (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 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
Index: src/preparser.h
diff --git a/src/preparser.h b/src/preparser.h
index d890ae5c216d7b497d0f3801288bd2fe7c4123fb..fc6294de833c7e06a978c98be281572c39b20f8f 100644
--- a/src/preparser.h
+++ b/src/preparser.h
@@ -714,9 +714,10 @@ class ParserBase : public Traits {
ExpressionT ParseMemberExpression(ExpressionClassifier* classifier, bool* ok);
ExpressionT ParseMemberExpressionContinuation(
ExpressionT expression, ExpressionClassifier* classifier, bool* ok);
- ExpressionT ParseArrowFunctionLiteral(
- const FormalParametersT& parameters,
- const ExpressionClassifier& classifier, bool* ok);
+ ExpressionT ParseArrowFunctionLiteral(bool accept_IN,
+ const FormalParametersT& parameters,
+ const ExpressionClassifier& classifier,
+ bool* ok);
ExpressionT ParseTemplateLiteral(ExpressionT tag, int start,
ExpressionClassifier* classifier, bool* ok);
void AddTemplateExpression(ExpressionT);
@@ -1074,6 +1075,9 @@ class PreParserExpression {
PreParserExpression AsFunctionLiteral() { return *this; }
+ // Only used by arrow functions with concise bodies, only for lazy parsing.
+ void set_accept_IN(bool value) {}
+
bool IsBinaryOperation() const {
return TypeField::decode(code_) == kBinaryOperationExpression;
}
@@ -2946,7 +2950,7 @@ ParserBase<Traits>::ParseAssignmentExpression(bool accept_IN,
duplicate_loc);
}
expression = this->ParseArrowFunctionLiteral(
- parameters, arrow_formals_classifier, CHECK_OK);
+ accept_IN, parameters, arrow_formals_classifier, CHECK_OK);
return expression;
}
@@ -3882,7 +3886,7 @@ bool ParserBase<Traits>::IsNextLetKeyword() {
template <class Traits>
typename ParserBase<Traits>::ExpressionT
ParserBase<Traits>::ParseArrowFunctionLiteral(
- const FormalParametersT& formal_parameters,
+ bool accept_IN, const FormalParametersT& formal_parameters,
const ExpressionClassifier& formals_classifier, bool* ok) {
if (peek() == Token::ARROW && scanner_->HasAnyLineTerminatorBeforeNext()) {
// ASI inserts `;` after arrow parameters if a line terminator is found.
@@ -3898,6 +3902,7 @@ ParserBase<Traits>::ParseArrowFunctionLiteral(
int materialized_literal_count = -1;
int expected_property_count = -1;
Scanner::Location super_loc;
+ bool concise = false;
adamk 2015/10/14 12:46:44 I don't see this used anywhere (other than it bein
caitp (gmail) 2015/10/14 13:20:18 probably left over from an older version of the pa
{
typename Traits::Type::Factory function_factory(ast_value_factory());
@@ -3936,11 +3941,12 @@ ParserBase<Traits>::ParseArrowFunctionLiteral(
}
} else {
// Single-expression body
+ concise = true;
int pos = position();
parenthesized_function_ = false;
ExpressionClassifier classifier;
ExpressionT expression =
- ParseAssignmentExpression(true, &classifier, CHECK_OK);
+ ParseAssignmentExpression(accept_IN, &classifier, CHECK_OK);
ValidateExpression(&classifier, CHECK_OK);
body = this->NewStatementList(1, zone());
this->AddParameterInitializationBlock(formal_parameters, body, CHECK_OK);
@@ -3983,6 +3989,8 @@ ParserBase<Traits>::ParseArrowFunctionLiteral(
formal_parameters.scope->start_position());
if (super_loc.IsValid()) function_state_->set_super_location(super_loc);
+ function_literal->set_accept_IN(accept_IN);
+
if (fni_ != NULL) this->InferFunctionName(fni_, function_literal);
return function_literal;
« src/parser.cc ('K') | « src/parser.cc ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698