Remove is_parenthesized bit from Expression and PreParserExpression
This bit was ostensibly being used to provide appropriate syntax errors for invalid destructuring assignment patterns, but adding a single call to RecordPatternError() (in place of BindingPatternUnexpectedToken()) seems to have replaced the need for it. Review URL: https://codereview.chromium.org/1665043002 Cr-Commit-Position: refs/heads/master@{#33750}
This commit is contained in:
parent
3d56b0d7c0
commit
1c318a9e4c
@ -376,14 +376,6 @@ class Expression : public AstNode {
|
||||
BailoutId id() const { return BailoutId(local_id(0)); }
|
||||
TypeFeedbackId test_id() const { return TypeFeedbackId(local_id(1)); }
|
||||
|
||||
// Parenthesized expressions in the form `( Expression )`.
|
||||
void set_is_parenthesized() {
|
||||
bit_field_ = ParenthesizedField::update(bit_field_, true);
|
||||
}
|
||||
bool is_parenthesized() const {
|
||||
return ParenthesizedField::decode(bit_field_);
|
||||
}
|
||||
|
||||
protected:
|
||||
Expression(Zone* zone, int pos)
|
||||
: AstNode(pos),
|
||||
@ -406,8 +398,6 @@ class Expression : public AstNode {
|
||||
int base_id_;
|
||||
Bounds bounds_;
|
||||
class ToBooleanTypesField : public BitField16<uint16_t, 0, 9> {};
|
||||
class ParenthesizedField
|
||||
: public BitField16<bool, ToBooleanTypesField::kNext, 1> {};
|
||||
uint16_t bit_field_;
|
||||
// Ends with 16-bit field; deriving classes in turn begin with
|
||||
// 16-bit fields for optimum packing efficiency.
|
||||
|
@ -1312,7 +1312,9 @@ ParserBase<Traits>::ParsePrimaryExpression(ExpressionClassifier* classifier,
|
||||
if (!classifier->is_valid_binding_pattern()) {
|
||||
ArrowFormalParametersUnexpectedToken(classifier);
|
||||
}
|
||||
BindingPatternUnexpectedToken(classifier);
|
||||
classifier->RecordPatternError(scanner()->peek_location(),
|
||||
MessageTemplate::kUnexpectedToken,
|
||||
Token::String(Token::LPAREN));
|
||||
Consume(Token::LPAREN);
|
||||
if (Check(Token::RPAREN)) {
|
||||
// ()=>x. The continuation that looks for the => is in
|
||||
@ -1356,9 +1358,6 @@ ParserBase<Traits>::ParsePrimaryExpression(ExpressionClassifier* classifier,
|
||||
ExpressionT expr = this->ParseExpression(true, kIsPossibleArrowFormals,
|
||||
classifier, CHECK_OK);
|
||||
Expect(Token::RPAREN, CHECK_OK);
|
||||
if (peek() != Token::ARROW) {
|
||||
expr->set_is_parenthesized();
|
||||
}
|
||||
return expr;
|
||||
}
|
||||
|
||||
@ -2025,8 +2024,7 @@ ParserBase<Traits>::ParseAssignmentExpression(bool accept_IN, int flags,
|
||||
ExpressionClassifier::CoverInitializedNameProduction);
|
||||
|
||||
bool maybe_pattern =
|
||||
(expression->IsObjectLiteral() || expression->IsArrayLiteral()) &&
|
||||
!expression->is_parenthesized();
|
||||
expression->IsObjectLiteral() || expression->IsArrayLiteral();
|
||||
|
||||
if (!Token::IsAssignmentOp(peek())) {
|
||||
// Parsed conditional expression only (no assignment).
|
||||
@ -3311,9 +3309,6 @@ void ParserBase<Traits>::CheckDestructuringElement(
|
||||
const Scanner::Location location(begin, end);
|
||||
if (expression->IsArrayLiteral() || expression->IsObjectLiteral() ||
|
||||
expression->IsAssignment()) {
|
||||
if (expression->is_parenthesized()) {
|
||||
classifier->RecordPatternError(location, message);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -279,12 +279,6 @@ class PreParserExpression {
|
||||
int position() const { return RelocInfo::kNoPosition; }
|
||||
void set_function_token_position(int position) {}
|
||||
|
||||
// Parenthesized expressions in the form `( Expression )`.
|
||||
void set_is_parenthesized() {
|
||||
code_ = ParenthesizedField::update(code_, true);
|
||||
}
|
||||
bool is_parenthesized() const { return ParenthesizedField::decode(code_); }
|
||||
|
||||
private:
|
||||
enum Type {
|
||||
kExpression,
|
||||
|
Loading…
Reference in New Issue
Block a user