Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(188)

Unified Diff: src/expression-classifier.h

Issue 1281163002: [parser] partially revert "use-strict directives in function body affect init block" Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/messages.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/expression-classifier.h
diff --git a/src/expression-classifier.h b/src/expression-classifier.h
index 716d4c7a3f29c24d2da337721c9089c4c3273616..7dba150b990b98195ddc72efb76cf233e7a7db17 100644
--- a/src/expression-classifier.h
+++ b/src/expression-classifier.h
@@ -47,11 +47,17 @@ class ExpressionClassifier {
ArrowFormalParametersProduction)
};
+ enum FunctionProperties { NonSimpleParameter = 1 << 0 };
+
ExpressionClassifier()
- : invalid_productions_(0), duplicate_finder_(nullptr) {}
+ : invalid_productions_(0),
+ function_properties_(0),
+ duplicate_finder_(nullptr) {}
explicit ExpressionClassifier(DuplicateFinder* duplicate_finder)
- : invalid_productions_(0), duplicate_finder_(duplicate_finder) {}
+ : invalid_productions_(0),
+ function_properties_(0),
+ duplicate_finder_(duplicate_finder) {}
bool is_valid(unsigned productions) const {
return (invalid_productions_ & productions) == 0;
@@ -113,6 +119,14 @@ class ExpressionClassifier {
return strong_mode_formal_parameter_error_;
}
+ bool is_simple_parameter_list() const {
+ return !(function_properties_ & NonSimpleParameter);
+ }
+
+ void RecordNonSimpleParameter() {
+ function_properties_ |= NonSimpleParameter;
+ }
+
void RecordExpressionError(const Scanner::Location& loc,
MessageTemplate::Template message,
const char* arg = nullptr) {
@@ -218,15 +232,21 @@ class ExpressionClassifier {
// As an exception to the above, the result continues to be a valid arrow
// formal parameters if the inner expression is a valid binding pattern.
if (productions & ArrowFormalParametersProduction &&
- is_valid_arrow_formal_parameters() &&
- !inner.is_valid_binding_pattern()) {
- invalid_productions_ |= ArrowFormalParametersProduction;
- arrow_formal_parameters_error_ = inner.binding_pattern_error_;
+ is_valid_arrow_formal_parameters()) {
+ // Also copy function properties if expecting an arrow function
+ // parameter
+ function_properties_ |= inner.function_properties_;
+
+ if (!inner.is_valid_binding_pattern()) {
+ invalid_productions_ |= ArrowFormalParametersProduction;
+ arrow_formal_parameters_error_ = inner.binding_pattern_error_;
+ }
}
}
private:
unsigned invalid_productions_;
+ unsigned function_properties_;
Error expression_error_;
Error binding_pattern_error_;
Error assignment_pattern_error_;
« no previous file with comments | « no previous file | src/messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698