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

Unified Diff: src/parsing/parser-base.h

Issue 1702063002: Non-pattern rewriting revisited (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix a bug I introduced when rebasing Created 4 years, 10 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/parser.cc ('k') | src/parsing/pattern-rewriter.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parsing/parser-base.h
diff --git a/src/parsing/parser-base.h b/src/parsing/parser-base.h
index d8cd60573090b21cdbe2c550d32b72d33f822b2d..f097456850a82d010851781558c3da219b957388 100644
--- a/src/parsing/parser-base.h
+++ b/src/parsing/parser-base.h
@@ -88,6 +88,7 @@ class ParserBase : public Traits {
typedef typename Traits::Type::Literal LiteralT;
typedef typename Traits::Type::ObjectLiteralProperty ObjectLiteralPropertyT;
typedef typename Traits::Type::StatementList StatementListT;
+ typedef typename Traits::Type::ExpressionClassifier ExpressionClassifier;
ParserBase(Zone* zone, Scanner* scanner, uintptr_t stack_limit,
v8::Extension* extension, AstValueFactory* ast_value_factory,
@@ -244,10 +245,6 @@ class ParserBase : public Traits {
return destructuring_assignments_to_rewrite_;
}
- void AddDestructuringAssignment(DestructuringAssignment pair) {
- destructuring_assignments_to_rewrite_.Add(pair);
- }
-
List<ExpressionT>& expressions_in_tail_position() {
return expressions_in_tail_position_;
}
@@ -264,7 +261,21 @@ class ParserBase : public Traits {
collect_expressions_in_tail_position_ = collect;
}
+ ZoneList<ExpressionT>* non_patterns_to_rewrite() {
+ return &non_patterns_to_rewrite_;
+ }
+
private:
+ void AddDestructuringAssignment(DestructuringAssignment pair) {
+ destructuring_assignments_to_rewrite_.Add(pair);
+ }
+
+ V8_INLINE Scope* scope() { return *scope_stack_; }
+
+ void AddNonPatternForRewriting(ExpressionT expr) {
+ non_patterns_to_rewrite_.Add(expr, (*scope_stack_)->zone());
+ }
+
// Used to assign an index to each literal that needs materialization in
// the function. Includes regexp literals, and boilerplate for object and
// array literals.
@@ -296,12 +307,12 @@ class ParserBase : public Traits {
List<DestructuringAssignment> destructuring_assignments_to_rewrite_;
List<ExpressionT> expressions_in_tail_position_;
bool collect_expressions_in_tail_position_;
-
- void RewriteDestructuringAssignments();
+ ZoneList<ExpressionT> non_patterns_to_rewrite_;
typename Traits::Type::Factory* factory_;
friend class ParserTraits;
+ friend class PreParserTraits;
friend class Checkpoint;
};
@@ -590,8 +601,8 @@ class ParserBase : public Traits {
Scanner::Location location, Token::Value token,
MessageTemplate::Template message = MessageTemplate::kUnexpectedToken);
-
- void ReportClassifierError(const ExpressionClassifier::Error& error) {
+ void ReportClassifierError(
+ const typename ExpressionClassifier::Error& error) {
Traits::ReportMessageAt(error.location, error.message, error.arg,
error.type);
}
@@ -669,7 +680,7 @@ class ParserBase : public Traits {
// neither a valid binding pattern nor a valid parenthesized formal
// parameter list, show the "arrow formal parameters" error if the formals
// started with a parenthesis, and the binding pattern error otherwise.
- const ExpressionClassifier::Error& error =
+ const typename ExpressionClassifier::Error& error =
parenthesized_formals ? classifier->arrow_formal_parameters_error()
: classifier->binding_pattern_error();
ReportClassifierError(error);
@@ -837,11 +848,6 @@ class ParserBase : public Traits {
return true;
}
- bool IsAssignmentExpression(ExpressionT expression) {
- return expression->IsAssignment() ||
- expression->IsRewritableAssignmentExpression();
- }
-
bool IsValidPattern(ExpressionT expression) {
return expression->IsObjectLiteral() || expression->IsArrayLiteral();
}
@@ -968,6 +974,7 @@ ParserBase<Traits>::FunctionState::FunctionState(
scope_stack_(scope_stack),
outer_scope_(*scope_stack),
collect_expressions_in_tail_position_(true),
+ non_patterns_to_rewrite_(0, scope->zone()),
factory_(factory) {
*scope_stack_ = scope;
*function_state_stack = this;
@@ -1054,7 +1061,7 @@ void ParserBase<Traits>::ReportUnexpectedTokenAt(
template <class Traits>
typename ParserBase<Traits>::IdentifierT ParserBase<Traits>::ParseIdentifier(
AllowRestrictedIdentifiers allow_restricted_identifiers, bool* ok) {
- ExpressionClassifier classifier;
+ ExpressionClassifier classifier(this);
auto result = ParseAndClassifyIdentifier(&classifier, ok);
if (!*ok) return Traits::EmptyIdentifier();
@@ -1425,9 +1432,9 @@ ParserBase<Traits>::ParsePrimaryExpression(ExpressionClassifier* classifier,
template <class Traits>
typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParseExpression(
bool accept_IN, bool* ok) {
- ExpressionClassifier classifier;
+ ExpressionClassifier classifier(this);
ExpressionT result = ParseExpression(accept_IN, &classifier, CHECK_OK);
- result = Traits::RewriteNonPattern(result, &classifier, CHECK_OK);
+ Traits::RewriteNonPattern(&classifier, CHECK_OK);
return result;
}
@@ -1439,10 +1446,10 @@ typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParseExpression(
// AssignmentExpression
// Expression ',' AssignmentExpression
- ExpressionClassifier binding_classifier;
+ ExpressionClassifier binding_classifier(this);
ExpressionT result =
this->ParseAssignmentExpression(accept_IN, &binding_classifier, CHECK_OK);
- classifier->Accumulate(binding_classifier,
+ classifier->Accumulate(&binding_classifier,
ExpressionClassifier::AllProductions);
bool is_simple_parameter_list = this->IsIdentifier(result);
bool seen_rest = false;
@@ -1467,6 +1474,8 @@ typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParseExpression(
int pos = position(), expr_pos = peek_position();
ExpressionT right = this->ParseAssignmentExpression(
accept_IN, &binding_classifier, CHECK_OK);
+ classifier->Accumulate(&binding_classifier,
+ ExpressionClassifier::AllProductions);
if (is_rest) {
if (!this->IsIdentifier(right) && !IsValidPattern(right)) {
classifier->RecordArrowFormalParametersError(
@@ -1477,8 +1486,6 @@ typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParseExpression(
}
is_simple_parameter_list =
is_simple_parameter_list && this->IsIdentifier(right);
- classifier->Accumulate(binding_classifier,
- ExpressionClassifier::AllProductions);
result = factory()->NewBinaryOperation(Token::COMMA, result, right, pos);
}
if (!is_simple_parameter_list || seen_rest) {
@@ -1522,7 +1529,7 @@ typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParseArrayLiteral(
first_spread_index = values->length();
}
- if (IsAssignmentExpression(argument)) {
+ if (argument->IsAssignment()) {
classifier->RecordPatternError(
Scanner::Location(start_pos, scanner()->location().end_pos),
MessageTemplate::kInvalidDestructuringTarget);
@@ -1552,8 +1559,14 @@ typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParseArrayLiteral(
// Update the scope information before the pre-parsing bailout.
int literal_index = function_state_->NextMaterializedLiteralIndex();
- return factory()->NewArrayLiteral(values, first_spread_index, literal_index,
- is_strong(language_mode()), pos);
+ ExpressionT result =
+ factory()->NewArrayLiteral(values, first_spread_index, literal_index,
+ is_strong(language_mode()), pos);
+ if (first_spread_index >= 0) {
+ result = factory()->NewRewritableExpression(result);
+ Traits::QueueNonPatternForRewriting(result);
+ }
+ return result;
}
@@ -1592,12 +1605,11 @@ typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParsePropertyName(
case Token::LBRACK: {
*is_computed_name = true;
Consume(Token::LBRACK);
- ExpressionClassifier computed_name_classifier;
+ ExpressionClassifier computed_name_classifier(this);
ExpressionT expression =
ParseAssignmentExpression(true, &computed_name_classifier, CHECK_OK);
- expression = Traits::RewriteNonPattern(
- expression, &computed_name_classifier, CHECK_OK);
- classifier->Accumulate(computed_name_classifier,
+ Traits::RewriteNonPattern(&computed_name_classifier, CHECK_OK);
+ classifier->Accumulate(&computed_name_classifier,
ExpressionClassifier::ExpressionProductions);
Expect(Token::RBRACK, CHECK_OK);
return expression;
@@ -1685,12 +1697,12 @@ ParserBase<Traits>::ParsePropertyDefinition(
if (peek() == Token::ASSIGN) {
Consume(Token::ASSIGN);
- ExpressionClassifier rhs_classifier;
+ ExpressionClassifier rhs_classifier(this);
ExpressionT rhs = this->ParseAssignmentExpression(
true, &rhs_classifier, CHECK_OK_CUSTOM(EmptyObjectLiteralProperty));
- rhs = Traits::RewriteNonPattern(
- rhs, &rhs_classifier, CHECK_OK_CUSTOM(EmptyObjectLiteralProperty));
- classifier->Accumulate(rhs_classifier,
+ Traits::RewriteNonPattern(&rhs_classifier,
+ CHECK_OK_CUSTOM(EmptyObjectLiteralProperty));
+ classifier->Accumulate(&rhs_classifier,
ExpressionClassifier::ExpressionProductions);
value = factory()->NewAssignment(Token::ASSIGN, lhs, rhs,
RelocInfo::kNoPosition);
@@ -1752,8 +1764,7 @@ ParserBase<Traits>::ParsePropertyDefinition(
ObjectLiteralPropertyT property = ParsePropertyDefinition(
checker, true, has_extends, true, is_computed_name, nullptr, classifier,
name, ok);
- property = Traits::RewriteNonPatternObjectLiteralProperty(property,
- classifier, ok);
+ Traits::RewriteNonPattern(classifier, ok);
return property;
}
@@ -1892,8 +1903,7 @@ typename Traits::Type::ExpressionList ParserBase<Traits>::ParseArguments(
ExpressionT argument = this->ParseAssignmentExpression(
true, classifier, CHECK_OK_CUSTOM(NullExpressionList));
- argument = Traits::RewriteNonPattern(argument, classifier,
- CHECK_OK_CUSTOM(NullExpressionList));
+ Traits::RewriteNonPattern(classifier, CHECK_OK_CUSTOM(NullExpressionList));
if (is_spread) {
if (!spread_arg.IsValid()) {
spread_arg.beg_pos = start_pos;
@@ -1960,7 +1970,8 @@ ParserBase<Traits>::ParseAssignmentExpression(bool accept_IN,
FuncNameInferrer::State fni_state(fni_);
ParserBase<Traits>::Checkpoint checkpoint(this);
- ExpressionClassifier arrow_formals_classifier(classifier->duplicate_finder());
+ ExpressionClassifier arrow_formals_classifier(this,
+ classifier->duplicate_finder());
bool parenthesized_formals = peek() == Token::LPAREN;
if (!parenthesized_formals) {
ArrowFormalParametersUnexpectedToken(&arrow_formals_classifier);
@@ -2010,17 +2021,24 @@ ParserBase<Traits>::ParseAssignmentExpression(bool accept_IN,
// "expression" was not itself an arrow function parameter list, but it might
// form part of one. Propagate speculative formal parameter error locations.
+ // Do not merge pending non-pattern expressions yet!
classifier->Accumulate(
- arrow_formals_classifier,
+ &arrow_formals_classifier,
ExpressionClassifier::StandardProductions |
- ExpressionClassifier::FormalParametersProductions |
- ExpressionClassifier::CoverInitializedNameProduction);
+ ExpressionClassifier::FormalParametersProductions |
+ ExpressionClassifier::CoverInitializedNameProduction,
+ false);
if (!Token::IsAssignmentOp(peek())) {
// Parsed conditional expression only (no assignment).
+ // Now pending non-pattern expressions must be merged.
+ classifier->MergeNonPatterns(&arrow_formals_classifier);
return expression;
}
+ // Now pending non-pattern expressions must be discarded.
+ arrow_formals_classifier.Discard();
+
if (!(allow_harmony_destructuring_bind() ||
allow_harmony_default_parameters())) {
BindingPatternUnexpectedToken(classifier);
@@ -2054,14 +2072,14 @@ ParserBase<Traits>::ParseAssignmentExpression(bool accept_IN,
}
int pos = position();
- ExpressionClassifier rhs_classifier;
+ ExpressionClassifier rhs_classifier(this);
ExpressionT right =
this->ParseAssignmentExpression(accept_IN, &rhs_classifier, CHECK_OK);
- right = Traits::RewriteNonPattern(right, &rhs_classifier, CHECK_OK);
+ Traits::RewriteNonPattern(&rhs_classifier, CHECK_OK);
classifier->Accumulate(
- rhs_classifier, ExpressionClassifier::ExpressionProductions |
- ExpressionClassifier::CoverInitializedNameProduction);
+ &rhs_classifier, ExpressionClassifier::ExpressionProductions |
+ ExpressionClassifier::CoverInitializedNameProduction);
// TODO(1231235): We try to estimate the set of properties set by
// constructors. We define a new property whenever there is an
@@ -2093,7 +2111,7 @@ ParserBase<Traits>::ParseAssignmentExpression(bool accept_IN,
ExpressionT result = factory()->NewAssignment(op, expression, right, pos);
if (is_destructuring_assignment) {
- result = factory()->NewRewritableAssignmentExpression(result);
+ result = factory()->NewRewritableExpression(result);
Traits::QueueDestructuringAssignmentForRewriting(result);
}
@@ -2135,8 +2153,7 @@ ParserBase<Traits>::ParseYieldExpression(ExpressionClassifier* classifier,
// Delegating yields require an RHS; fall through.
default:
expression = ParseAssignmentExpression(false, classifier, CHECK_OK);
- expression =
- Traits::RewriteNonPattern(expression, classifier, CHECK_OK);
+ Traits::RewriteNonPattern(classifier, CHECK_OK);
break;
}
}
@@ -2166,7 +2183,7 @@ ParserBase<Traits>::ParseConditionalExpression(bool accept_IN,
ExpressionT expression =
this->ParseBinaryExpression(4, accept_IN, classifier, CHECK_OK);
if (peek() != Token::CONDITIONAL) return expression;
- expression = Traits::RewriteNonPattern(expression, classifier, CHECK_OK);
+ Traits::RewriteNonPattern(classifier, CHECK_OK);
ArrowFormalParametersUnexpectedToken(classifier);
BindingPatternUnexpectedToken(classifier);
Consume(Token::CONDITIONAL);
@@ -2174,11 +2191,11 @@ ParserBase<Traits>::ParseConditionalExpression(bool accept_IN,
// expressions we always accept the 'in' keyword; see ECMA-262,
// section 11.12, page 58.
ExpressionT left = ParseAssignmentExpression(true, classifier, CHECK_OK);
- left = Traits::RewriteNonPattern(left, classifier, CHECK_OK);
+ Traits::RewriteNonPattern(classifier, CHECK_OK);
Expect(Token::COLON, CHECK_OK);
ExpressionT right =
ParseAssignmentExpression(accept_IN, classifier, CHECK_OK);
- right = Traits::RewriteNonPattern(right, classifier, CHECK_OK);
+ Traits::RewriteNonPattern(classifier, CHECK_OK);
return factory()->NewConditional(expression, left, right, pos);
}
@@ -2194,7 +2211,7 @@ ParserBase<Traits>::ParseBinaryExpression(int prec, bool accept_IN,
for (int prec1 = Precedence(peek(), accept_IN); prec1 >= prec; prec1--) {
// prec1 >= 4
while (Precedence(peek(), accept_IN) == prec1) {
- x = Traits::RewriteNonPattern(x, classifier, CHECK_OK);
+ Traits::RewriteNonPattern(classifier, CHECK_OK);
BindingPatternUnexpectedToken(classifier);
ArrowFormalParametersUnexpectedToken(classifier);
Token::Value op = Next();
@@ -2202,7 +2219,7 @@ ParserBase<Traits>::ParseBinaryExpression(int prec, bool accept_IN,
int pos = position();
ExpressionT y =
ParseBinaryExpression(prec1 + 1, accept_IN, classifier, CHECK_OK);
- y = Traits::RewriteNonPattern(y, classifier, CHECK_OK);
+ Traits::RewriteNonPattern(classifier, CHECK_OK);
if (this->ShortcutNumericLiteralBinaryExpression(&x, y, op, pos,
factory())) {
@@ -2265,7 +2282,7 @@ ParserBase<Traits>::ParseUnaryExpression(ExpressionClassifier* classifier,
op = Next();
int pos = position();
ExpressionT expression = ParseUnaryExpression(classifier, CHECK_OK);
- expression = Traits::RewriteNonPattern(expression, classifier, CHECK_OK);
+ Traits::RewriteNonPattern(classifier, CHECK_OK);
if (op == Token::DELETE && is_strict(language_mode())) {
if (is_strong(language_mode())) {
@@ -2292,7 +2309,7 @@ ParserBase<Traits>::ParseUnaryExpression(ExpressionClassifier* classifier,
expression, beg_pos, scanner()->location().end_pos,
MessageTemplate::kInvalidLhsInPrefixOp, CHECK_OK);
this->MarkExpressionAsAssigned(expression);
- expression = Traits::RewriteNonPattern(expression, classifier, CHECK_OK);
+ Traits::RewriteNonPattern(classifier, CHECK_OK);
return factory()->NewCountOperation(op,
true /* prefix */,
@@ -2324,7 +2341,7 @@ ParserBase<Traits>::ParsePostfixExpression(ExpressionClassifier* classifier,
expression, lhs_beg_pos, scanner()->location().end_pos,
MessageTemplate::kInvalidLhsInPostfixOp, CHECK_OK);
expression = this->MarkExpressionAsAssigned(expression);
- expression = Traits::RewriteNonPattern(expression, classifier, CHECK_OK);
+ Traits::RewriteNonPattern(classifier, CHECK_OK);
Token::Value next = Next();
expression =
@@ -2350,20 +2367,20 @@ ParserBase<Traits>::ParseLeftHandSideExpression(
while (true) {
switch (peek()) {
case Token::LBRACK: {
- result = Traits::RewriteNonPattern(result, classifier, CHECK_OK);
+ Traits::RewriteNonPattern(classifier, CHECK_OK);
BindingPatternUnexpectedToken(classifier);
ArrowFormalParametersUnexpectedToken(classifier);
Consume(Token::LBRACK);
int pos = position();
ExpressionT index = ParseExpression(true, classifier, CHECK_OK);
- index = Traits::RewriteNonPattern(index, classifier, CHECK_OK);
+ Traits::RewriteNonPattern(classifier, CHECK_OK);
result = factory()->NewProperty(result, index, pos);
Expect(Token::RBRACK, CHECK_OK);
break;
}
case Token::LPAREN: {
- result = Traits::RewriteNonPattern(result, classifier, CHECK_OK);
+ Traits::RewriteNonPattern(classifier, CHECK_OK);
BindingPatternUnexpectedToken(classifier);
ArrowFormalParametersUnexpectedToken(classifier);
@@ -2427,7 +2444,7 @@ ParserBase<Traits>::ParseLeftHandSideExpression(
}
case Token::PERIOD: {
- result = Traits::RewriteNonPattern(result, classifier, CHECK_OK);
+ Traits::RewriteNonPattern(classifier, CHECK_OK);
BindingPatternUnexpectedToken(classifier);
ArrowFormalParametersUnexpectedToken(classifier);
Consume(Token::PERIOD);
@@ -2441,7 +2458,7 @@ ParserBase<Traits>::ParseLeftHandSideExpression(
case Token::TEMPLATE_SPAN:
case Token::TEMPLATE_TAIL: {
- result = Traits::RewriteNonPattern(result, classifier, CHECK_OK);
+ Traits::RewriteNonPattern(classifier, CHECK_OK);
BindingPatternUnexpectedToken(classifier);
ArrowFormalParametersUnexpectedToken(classifier);
result = ParseTemplateLiteral(result, position(), classifier, CHECK_OK);
@@ -2493,7 +2510,7 @@ ParserBase<Traits>::ParseMemberWithNewPrefixesExpression(
} else {
result = this->ParseMemberWithNewPrefixesExpression(classifier, CHECK_OK);
}
- result = Traits::RewriteNonPattern(result, classifier, CHECK_OK);
+ Traits::RewriteNonPattern(classifier, CHECK_OK);
if (peek() == Token::LPAREN) {
// NewExpression with arguments.
Scanner::Location spread_pos;
@@ -2609,7 +2626,7 @@ ParserBase<Traits>::ParseStrongInitializationExpression(
Consume(Token::LBRACK);
int pos = position();
ExpressionT index = this->ParseExpression(true, classifier, CHECK_OK);
- index = Traits::RewriteNonPattern(index, classifier, CHECK_OK);
+ Traits::RewriteNonPattern(classifier, CHECK_OK);
left = factory()->NewProperty(this_expr, index, pos);
if (fni_ != NULL) {
this->PushPropertyName(fni_, index);
@@ -2645,7 +2662,7 @@ ParserBase<Traits>::ParseStrongInitializationExpression(
ExpressionT right =
this->ParseAssignmentExpression(true, classifier, CHECK_OK);
- right = Traits::RewriteNonPattern(right, classifier, CHECK_OK);
+ Traits::RewriteNonPattern(classifier, CHECK_OK);
this->CheckAssigningFunctionLiteralToProperty(left, right);
function_state_->AddProperty();
if (fni_ != NULL) {
@@ -2809,15 +2826,14 @@ ParserBase<Traits>::ParseMemberExpressionContinuation(
while (true) {
switch (peek()) {
case Token::LBRACK: {
- expression =
- Traits::RewriteNonPattern(expression, classifier, CHECK_OK);
+ Traits::RewriteNonPattern(classifier, CHECK_OK);
BindingPatternUnexpectedToken(classifier);
ArrowFormalParametersUnexpectedToken(classifier);
Consume(Token::LBRACK);
int pos = position();
ExpressionT index = this->ParseExpression(true, classifier, CHECK_OK);
- index = Traits::RewriteNonPattern(index, classifier, CHECK_OK);
+ Traits::RewriteNonPattern(classifier, CHECK_OK);
expression = factory()->NewProperty(expression, index, pos);
if (fni_ != NULL) {
this->PushPropertyName(fni_, index);
@@ -2826,8 +2842,7 @@ ParserBase<Traits>::ParseMemberExpressionContinuation(
break;
}
case Token::PERIOD: {
- expression =
- Traits::RewriteNonPattern(expression, classifier, CHECK_OK);
+ Traits::RewriteNonPattern(classifier, CHECK_OK);
BindingPatternUnexpectedToken(classifier);
ArrowFormalParametersUnexpectedToken(classifier);
@@ -2843,8 +2858,7 @@ ParserBase<Traits>::ParseMemberExpressionContinuation(
}
case Token::TEMPLATE_SPAN:
case Token::TEMPLATE_TAIL: {
- expression =
- Traits::RewriteNonPattern(expression, classifier, CHECK_OK);
+ Traits::RewriteNonPattern(classifier, CHECK_OK);
BindingPatternUnexpectedToken(classifier);
ArrowFormalParametersUnexpectedToken(classifier);
int pos;
@@ -2899,13 +2913,14 @@ void ParserBase<Traits>::ParseFormalParameter(
ExpressionT initializer = Traits::EmptyExpression();
if (!is_rest && allow_harmony_default_parameters() && Check(Token::ASSIGN)) {
- ExpressionClassifier init_classifier;
+ ExpressionClassifier init_classifier(this);
initializer = ParseAssignmentExpression(true, &init_classifier, ok);
if (!*ok) return;
- initializer = Traits::RewriteNonPattern(initializer, &init_classifier, ok);
+ Traits::RewriteNonPattern(&init_classifier, ok);
ValidateFormalParameterInitializer(&init_classifier, ok);
if (!*ok) return;
parameters->is_simple = false;
+ init_classifier.Discard();
classifier->RecordNonSimpleParameter();
if (allow_harmony_function_name()) {
@@ -3073,10 +3088,10 @@ ParserBase<Traits>::ParseArrowFunctionLiteral(
// Single-expression body
int pos = position();
parenthesized_function_ = false;
- ExpressionClassifier classifier;
+ ExpressionClassifier classifier(this);
ExpressionT expression =
ParseAssignmentExpression(accept_IN, &classifier, CHECK_OK);
- expression = Traits::RewriteNonPattern(expression, &classifier, CHECK_OK);
+ Traits::RewriteNonPattern(&classifier, CHECK_OK);
body = this->NewStatementList(1, zone());
this->AddParameterInitializationBlock(formal_parameters, body, CHECK_OK);
body->Add(factory()->NewReturnStatement(expression, pos), zone());
@@ -3182,7 +3197,7 @@ ParserBase<Traits>::ParseTemplateLiteral(ExpressionT tag, int start,
int expr_pos = peek_position();
ExpressionT expression = this->ParseExpression(true, classifier, CHECK_OK);
- expression = Traits::RewriteNonPattern(expression, classifier, CHECK_OK);
+ Traits::RewriteNonPattern(classifier, CHECK_OK);
Traits::AddTemplateExpression(&ts, expression);
if (peek() != Token::RBRACE) {
@@ -3236,7 +3251,7 @@ typename ParserBase<Traits>::ExpressionT
ParserBase<Traits>::CheckAndRewriteReferenceExpression(
ExpressionT expression, int beg_pos, int end_pos,
MessageTemplate::Template message, ParseErrorType type, bool* ok) {
- ExpressionClassifier classifier;
+ ExpressionClassifier classifier(this);
ExpressionT result = ClassifyAndRewriteReferenceExpression(
&classifier, expression, beg_pos, end_pos, message, type);
ValidateExpression(&classifier, ok);
@@ -3290,7 +3305,7 @@ template <typename Traits>
void ParserBase<Traits>::CheckDestructuringElement(
ExpressionT expression, ExpressionClassifier* classifier, int begin,
int end) {
- if (!IsValidPattern(expression) && !IsAssignmentExpression(expression) &&
+ if (!IsValidPattern(expression) && !expression->IsAssignment() &&
!IsValidReferenceExpression(expression)) {
classifier->RecordAssignmentPatternError(
Scanner::Location(begin, end),
@@ -3356,6 +3371,8 @@ void ParserBase<Traits>::ClassLiteralChecker::CheckProperty(
return;
}
}
+
+
} // namespace internal
} // namespace v8
« no previous file with comments | « src/parsing/parser.cc ('k') | src/parsing/pattern-rewriter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698