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

Unified Diff: src/expression-classifier.h

Issue 1300103005: [parser] disallow language mode directive in body of function with non-simple parameters (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: flag implications don't work in test suite? 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 17a377890add55a9d427a509ab5fdd205d5e833b..80f5e66fd4fea08d2f648824b1caee9ff4ae65d6 100644
--- a/src/expression-classifier.h
+++ b/src/expression-classifier.h
@@ -45,11 +45,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;
@@ -111,6 +117,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) {
@@ -216,15 +230,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