[parser] Clean up dead or overly general code in ExpressionClassifier
ParseErrorType is never passed to ExpressionClassifier, so there's no need to store it in the Error struct (we can always use the Parser's default of SyntaxError). Also simplify the handling of non-simple parameter detection, which was stored in a two-bit function_properties_ field that was only being used for this purpose. Bug: v8:8015 Change-Id: I198e8285cbafee650614d1ff5bb434fe9fd2a338 Reviewed-on: https://chromium-review.googlesource.com/1180525 Reviewed-by: Marja Hölttä <marja@chromium.org> Commit-Queue: Adam Klein <adamk@chromium.org> Cr-Commit-Position: refs/heads/master@{#55234}
This commit is contained in:
parent
8fa7f9ed93
commit
e0d77f3ec4
@ -61,18 +61,15 @@ class ExpressionClassifier {
|
||||
: location(Scanner::Location::invalid()),
|
||||
message(MessageTemplate::kNone),
|
||||
kind(kUnusedError),
|
||||
type(kSyntaxError),
|
||||
arg(nullptr) {}
|
||||
V8_INLINE explicit Error(Scanner::Location loc,
|
||||
MessageTemplate::Template msg, ErrorKind k,
|
||||
const char* a = nullptr,
|
||||
ParseErrorType t = kSyntaxError)
|
||||
: location(loc), message(msg), kind(k), type(t), arg(a) {}
|
||||
const char* a = nullptr)
|
||||
: location(loc), message(msg), kind(k), arg(a) {}
|
||||
|
||||
Scanner::Location location;
|
||||
MessageTemplate::Template message : 26;
|
||||
MessageTemplate::Template message : 28;
|
||||
unsigned kind : 4;
|
||||
ParseErrorType type : 2;
|
||||
const char* arg;
|
||||
};
|
||||
|
||||
@ -88,10 +85,6 @@ class ExpressionClassifier {
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
enum FunctionProperties : unsigned {
|
||||
NonSimpleParameter = 1 << 0
|
||||
};
|
||||
|
||||
explicit ExpressionClassifier(typename Types::Base* base,
|
||||
DuplicateFinder* duplicate_finder = nullptr)
|
||||
: base_(base),
|
||||
@ -100,7 +93,7 @@ class ExpressionClassifier {
|
||||
reported_errors_(base->impl()->GetReportedErrorList()),
|
||||
duplicate_finder_(duplicate_finder),
|
||||
invalid_productions_(0),
|
||||
function_properties_(0) {
|
||||
is_non_simple_parameter_list_(0) {
|
||||
base->classifier_ = this;
|
||||
reported_errors_begin_ = reported_errors_end_ = reported_errors_->length();
|
||||
}
|
||||
@ -193,11 +186,11 @@ class ExpressionClassifier {
|
||||
}
|
||||
|
||||
V8_INLINE bool is_simple_parameter_list() const {
|
||||
return !(function_properties_ & NonSimpleParameter);
|
||||
return !is_non_simple_parameter_list_;
|
||||
}
|
||||
|
||||
V8_INLINE void RecordNonSimpleParameter() {
|
||||
function_properties_ |= NonSimpleParameter;
|
||||
is_non_simple_parameter_list_ = 1;
|
||||
}
|
||||
|
||||
void RecordExpressionError(const Scanner::Location& loc,
|
||||
@ -208,14 +201,6 @@ class ExpressionClassifier {
|
||||
Add(Error(loc, message, kExpressionProduction, arg));
|
||||
}
|
||||
|
||||
void RecordExpressionError(const Scanner::Location& loc,
|
||||
MessageTemplate::Template message,
|
||||
ParseErrorType type, const char* arg = nullptr) {
|
||||
if (!is_valid_expression()) return;
|
||||
invalid_productions_ |= ExpressionProduction;
|
||||
Add(Error(loc, message, kExpressionProduction, arg, type));
|
||||
}
|
||||
|
||||
void RecordFormalParameterInitializerError(const Scanner::Location& loc,
|
||||
MessageTemplate::Template message,
|
||||
const char* arg = nullptr) {
|
||||
@ -305,9 +290,9 @@ class ExpressionClassifier {
|
||||
bool copy_BP_to_AFP = false;
|
||||
if (productions & ArrowFormalParametersProduction &&
|
||||
is_valid_arrow_formal_parameters()) {
|
||||
// Also copy function properties if expecting an arrow function
|
||||
// parameter.
|
||||
function_properties_ |= inner->function_properties_;
|
||||
// Also whether we've seen any non-simple parameters
|
||||
// if expecting an arrow function parameter.
|
||||
is_non_simple_parameter_list_ |= inner->is_non_simple_parameter_list_;
|
||||
if (!inner->is_valid_binding_pattern()) {
|
||||
copy_BP_to_AFP = true;
|
||||
invalid_productions_ |= ArrowFormalParametersProduction;
|
||||
@ -411,8 +396,8 @@ class ExpressionClassifier {
|
||||
Zone* zone_;
|
||||
ZoneList<Error>* reported_errors_;
|
||||
DuplicateFinder* duplicate_finder_;
|
||||
unsigned invalid_productions_ : 14;
|
||||
unsigned function_properties_ : 2;
|
||||
unsigned invalid_productions_ : 15;
|
||||
unsigned is_non_simple_parameter_list_ : 1;
|
||||
// The uint16_t for reported_errors_begin_ and reported_errors_end_ will
|
||||
// not be enough in the case of a long series of expressions using nested
|
||||
// classifiers, e.g., a long sequence of assignments, as in:
|
||||
|
@ -962,8 +962,7 @@ class ParserBase {
|
||||
|
||||
void ReportClassifierError(
|
||||
const typename ExpressionClassifier::Error& error) {
|
||||
impl()->ReportMessageAt(error.location, error.message, error.arg,
|
||||
error.type);
|
||||
impl()->ReportMessageAt(error.location, error.message, error.arg);
|
||||
}
|
||||
|
||||
void ValidateExpression(bool* ok) {
|
||||
|
Loading…
Reference in New Issue
Block a user