Index: src/parsing/parser-base.h |
diff --git a/src/parsing/parser-base.h b/src/parsing/parser-base.h |
index ff6b738bf57b97eaebfc5259a71b1fb0cf205b6d..a1e707983011dee10643311f9faa34914a515732 100644 |
--- a/src/parsing/parser-base.h |
+++ b/src/parsing/parser-base.h |
@@ -238,17 +238,21 @@ class ParserBase : public Traits { |
typename Traits::Type::Factory* factory() { return factory_; } |
- const List<DestructuringAssignment>& destructuring_assignments_to_rewrite() |
- const { |
+ const ZoneList<DestructuringAssignment>& |
+ destructuring_assignments_to_rewrite() const { |
return destructuring_assignments_to_rewrite_; |
} |
- List<ExpressionT>& expressions_in_tail_position() { |
+ ZoneList<typename ExpressionClassifier::Error>* GetReportedErrorList() { |
+ return &reported_errors_; |
+ } |
+ |
+ ZoneList<ExpressionT>& expressions_in_tail_position() { |
return expressions_in_tail_position_; |
} |
void AddExpressionInTailPosition(ExpressionT expression) { |
if (collect_expressions_in_tail_position_) { |
- expressions_in_tail_position_.Add(expression); |
+ expressions_in_tail_position_.Add(expression, scope()->zone()); |
} |
} |
@@ -265,13 +269,13 @@ class ParserBase : public Traits { |
private: |
void AddDestructuringAssignment(DestructuringAssignment pair) { |
- destructuring_assignments_to_rewrite_.Add(pair); |
+ destructuring_assignments_to_rewrite_.Add(pair, scope()->zone()); |
} |
V8_INLINE Scope* scope() { return *scope_stack_; } |
void AddNonPatternForRewriting(ExpressionT expr) { |
- non_patterns_to_rewrite_.Add(expr, (*scope_stack_)->zone()); |
+ non_patterns_to_rewrite_.Add(expr, scope()->zone()); |
} |
// Used to assign an index to each literal that needs materialization in |
@@ -302,10 +306,11 @@ class ParserBase : public Traits { |
Scope** scope_stack_; |
Scope* outer_scope_; |
- List<DestructuringAssignment> destructuring_assignments_to_rewrite_; |
- List<ExpressionT> expressions_in_tail_position_; |
- bool collect_expressions_in_tail_position_; |
+ ZoneList<DestructuringAssignment> destructuring_assignments_to_rewrite_; |
ZoneList<ExpressionT> non_patterns_to_rewrite_; |
+ ZoneList<typename ExpressionClassifier::Error> reported_errors_; |
+ ZoneList<ExpressionT> expressions_in_tail_position_; |
+ bool collect_expressions_in_tail_position_; |
typename Traits::Type::Factory* factory_; |
@@ -967,8 +972,11 @@ ParserBase<Traits>::FunctionState::FunctionState( |
outer_function_state_(*function_state_stack), |
scope_stack_(scope_stack), |
outer_scope_(*scope_stack), |
- collect_expressions_in_tail_position_(true), |
+ destructuring_assignments_to_rewrite_(16, scope->zone()), |
non_patterns_to_rewrite_(0, scope->zone()), |
+ reported_errors_(16, scope->zone()), |
+ expressions_in_tail_position_(4, scope->zone()), |
+ collect_expressions_in_tail_position_(true), |
factory_(factory) { |
*scope_stack_ = scope; |
*function_state_stack = this; |
@@ -1466,6 +1474,7 @@ typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParseExpression( |
seen_rest = is_rest = true; |
} |
int pos = position(), expr_pos = peek_position(); |
+ ExpressionClassifier binding_classifier(this); |
ExpressionT right = this->ParseAssignmentExpression( |
accept_IN, &binding_classifier, CHECK_OK); |
classifier->Accumulate(&binding_classifier, |
@@ -1978,9 +1987,14 @@ ParserBase<Traits>::ParseAssignmentExpression(bool accept_IN, |
ExpressionT expression = this->ParseConditionalExpression( |
accept_IN, &arrow_formals_classifier, CHECK_OK); |
if (peek() == Token::ARROW) { |
- classifier->RecordPatternError(scanner()->peek_location(), |
- MessageTemplate::kUnexpectedToken, |
- Token::String(Token::ARROW)); |
+ typename ExpressionClassifier::Error e1 = |
+ ExpressionClassifier::BindingPatternError( |
caitp (gmail)
2016/02/18 17:04:09
A thought I had on this duplication:
A BindingPat
nickie
2016/02/19 08:56:31
I'm sorry, I'm not confident enough to talk about
|
+ scanner()->peek_location(), MessageTemplate::kUnexpectedToken, |
+ Token::String(Token::ARROW)); |
+ typename ExpressionClassifier::Error e2 = |
+ ExpressionClassifier::AssignmentPatternError( |
+ scanner()->peek_location(), MessageTemplate::kUnexpectedToken, |
+ Token::String(Token::ARROW)); |
ValidateArrowFormalParameters(&arrow_formals_classifier, expression, |
parenthesized_formals, CHECK_OK); |
Scanner::Location loc(lhs_beg_pos, scanner()->location().end_pos); |
@@ -2008,6 +2022,9 @@ ParserBase<Traits>::ParseAssignmentExpression(bool accept_IN, |
} |
expression = this->ParseArrowFunctionLiteral( |
accept_IN, parameters, arrow_formals_classifier, CHECK_OK); |
+ arrow_formals_classifier.Discard(); |
+ classifier->RecordBindingPatternError(e1); |
+ classifier->RecordAssignmentPatternError(e2); |
if (fni_ != nullptr) fni_->Infer(); |