[parser] Eliminate ExpressionClassifier::MergeNonPatterns

A minor change in the logic of expression classifiers that
eliminates the use for MergeNonPatterns.

R=adamk@chromium.org, littledan@chromium.org
BUG=
LOG=N

Review-Url: https://codereview.chromium.org/2275313002
Cr-Commit-Position: refs/heads/master@{#38934}
This commit is contained in:
nikolaos 2016-08-26 01:57:36 -07:00 committed by Commit bot
parent fc6425c56a
commit 8ce4475103
2 changed files with 13 additions and 14 deletions

View File

@ -285,7 +285,14 @@ class ExpressionClassifier {
DCHECK_EQ(inner->reported_errors_, reported_errors_);
DCHECK_EQ(inner->reported_errors_begin_, reported_errors_end_);
DCHECK_EQ(inner->reported_errors_end_, reported_errors_->length());
if (merge_non_patterns) MergeNonPatterns(inner);
DCHECK_EQ(inner->non_patterns_to_rewrite_, non_patterns_to_rewrite_);
DCHECK_LE(non_pattern_begin_, inner->non_pattern_begin_);
DCHECK_LE(inner->non_pattern_begin_, non_patterns_to_rewrite_->length());
// Merge non-patterns from the inner classifier, or discard them.
if (merge_non_patterns)
inner->non_pattern_begin_ = non_patterns_to_rewrite_->length();
else
non_patterns_to_rewrite_->Rewind(inner->non_pattern_begin_);
// Propagate errors from inner, but don't overwrite already recorded
// errors.
unsigned non_arrow_inner_invalid_productions =
@ -376,11 +383,6 @@ class ExpressionClassifier {
non_patterns_to_rewrite_->Rewind(non_pattern_begin_);
}
V8_INLINE void MergeNonPatterns(ExpressionClassifier* inner) {
DCHECK_LE(non_pattern_begin_, inner->non_pattern_begin_);
inner->non_pattern_begin_ = inner->non_patterns_to_rewrite_->length();
}
private:
V8_INLINE const Error& reported_error(ErrorKind kind) const {
if (invalid_productions_ & (1 << kind)) {

View File

@ -2381,7 +2381,6 @@ ParserBase<Impl>::ParseAssignmentExpression(bool accept_IN,
// form part of one. Propagate speculative formal parameter error locations
// (including those for binding patterns, since formal parameters can
// themselves contain binding patterns).
// Do not merge pending non-pattern expressions yet!
unsigned productions = ExpressionClassifier::AllProductions &
~ExpressionClassifier::ArrowFormalParametersProduction;
@ -2402,18 +2401,16 @@ ParserBase<Impl>::ParseAssignmentExpression(bool accept_IN,
ExpressionClassifier::TailCallExpressionProduction);
}
classifier->Accumulate(&arrow_formals_classifier, productions, false);
if (!Token::IsAssignmentOp(peek())) {
// Parsed conditional expression only (no assignment).
// Now pending non-pattern expressions must be merged.
classifier->MergeNonPatterns(&arrow_formals_classifier);
// Pending non-pattern expressions must be merged.
classifier->Accumulate(&arrow_formals_classifier, productions);
return expression;
} else {
// Pending non-pattern expressions must be discarded.
classifier->Accumulate(&arrow_formals_classifier, productions, false);
}
// Now pending non-pattern expressions must be discarded.
arrow_formals_classifier.Discard();
CheckNoTailCallExpressions(classifier, CHECK_OK);
if (is_destructuring_assignment) {