Merge ExpressionClassifier::ObjectLiteralProduction into ExpressionProduction

They are both accumulated at the same time, and either one already triggered
an error in ValidateExpression. Basically, there were no disjoint uses of
these two error types.

Review-Url: https://codereview.chromium.org/2268173005
Cr-Commit-Position: refs/heads/master@{#38922}
This commit is contained in:
adamk 2016-08-25 17:02:38 -07:00 committed by Commit bot
parent 1937d90085
commit 26fbac4b37
2 changed files with 7 additions and 33 deletions

View File

@ -23,9 +23,8 @@ class DuplicateFinder;
T(StrictModeFormalParametersProduction, 5) \
T(ArrowFormalParametersProduction, 6) \
T(LetPatternProduction, 7) \
T(ObjectLiteralProduction, 8) \
T(TailCallExpressionProduction, 9) \
T(AsyncArrowFormalParametersProduction, 10)
T(TailCallExpressionProduction, 8) \
T(AsyncArrowFormalParametersProduction, 9)
template <typename Traits>
class ExpressionClassifier {
@ -165,14 +164,6 @@ class ExpressionClassifier {
return reported_error(kLetPatternProduction);
}
V8_INLINE bool has_object_literal_error() const {
return !is_valid(ObjectLiteralProduction);
}
V8_INLINE const Error& object_literal_error() const {
return reported_error(kObjectLiteralProduction);
}
V8_INLINE bool has_tail_call_expression() const {
return !is_valid(TailCallExpressionProduction);
}
@ -281,14 +272,6 @@ class ExpressionClassifier {
Add(Error(loc, message, kLetPatternProduction, arg));
}
void RecordObjectLiteralError(const Scanner::Location& loc,
MessageTemplate::Template message,
const char* arg = nullptr) {
if (has_object_literal_error()) return;
invalid_productions_ |= ObjectLiteralProduction;
Add(Error(loc, message, kObjectLiteralProduction, arg));
}
void RecordTailCallExpressionError(const Scanner::Location& loc,
MessageTemplate::Template message,
const char* arg = nullptr) {

View File

@ -925,16 +925,8 @@ class ParserBase : public ParserBaseTraits<Impl> {
}
void ValidateExpression(const ExpressionClassifier* classifier, bool* ok) {
if (!classifier->is_valid_expression() ||
classifier->has_object_literal_error()) {
const Scanner::Location& a = classifier->expression_error().location;
const Scanner::Location& b =
classifier->object_literal_error().location;
if (a.beg_pos < 0 || (b.beg_pos >= 0 && a.beg_pos > b.beg_pos)) {
ReportClassifierError(classifier->object_literal_error());
} else {
if (!classifier->is_valid_expression()) {
ReportClassifierError(classifier->expression_error());
}
*ok = false;
}
}
@ -2035,7 +2027,7 @@ ParserBase<Impl>::ParsePropertyDefinition(
classifier->AccumulateFormalParameterContainmentErrors(&rhs_classifier);
value = factory()->NewAssignment(Token::ASSIGN, lhs, rhs,
kNoSourcePosition);
classifier->RecordObjectLiteralError(
classifier->RecordExpressionError(
Scanner::Location(next_beg_pos, scanner()->location().end_pos),
MessageTemplate::kInvalidCoverInitializedName);
@ -2416,7 +2408,6 @@ ParserBase<Impl>::ParseAssignmentExpression(bool accept_IN,
// This is definitely not an expression so don't accumulate
// expression-related errors.
productions &= ~(ExpressionClassifier::ExpressionProduction |
ExpressionClassifier::ObjectLiteralProduction |
ExpressionClassifier::TailCallExpressionProduction);
}
@ -3668,8 +3659,8 @@ void ParserBase<Impl>::ObjectLiteralChecker::CheckProperty(
if (type == kValueProperty && IsProto()) {
if (has_seen_proto_) {
classifier->RecordObjectLiteralError(
this->scanner()->location(), MessageTemplate::kDuplicateProto);
classifier->RecordExpressionError(this->scanner()->location(),
MessageTemplate::kDuplicateProto);
return;
}
has_seen_proto_ = true;