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

Unified Diff: src/expression-classifier.h

Issue 1320673007: Disallow yield in default parameter initializers (Closed) Base URL: https://chromium.googlesource.com/v8/v8@master
Patch Set: Rebase 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/preparser.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 80f5e66fd4fea08d2f648824b1caee9ff4ae65d6..fb45f41fa169368b998aacf33afdeaf33e44ec51 100644
--- a/src/expression-classifier.h
+++ b/src/expression-classifier.h
@@ -28,19 +28,22 @@ class ExpressionClassifier {
enum TargetProduction {
ExpressionProduction = 1 << 0,
- BindingPatternProduction = 1 << 1,
- AssignmentPatternProduction = 1 << 2,
- DistinctFormalParametersProduction = 1 << 3,
- StrictModeFormalParametersProduction = 1 << 4,
- StrongModeFormalParametersProduction = 1 << 5,
- ArrowFormalParametersProduction = 1 << 6,
-
+ FormalParameterInitializerProduction = 1 << 1,
+ BindingPatternProduction = 1 << 2,
+ AssignmentPatternProduction = 1 << 3,
+ DistinctFormalParametersProduction = 1 << 4,
+ StrictModeFormalParametersProduction = 1 << 5,
+ StrongModeFormalParametersProduction = 1 << 6,
+ ArrowFormalParametersProduction = 1 << 7,
+
+ ExpressionProductions =
+ (ExpressionProduction | FormalParameterInitializerProduction),
PatternProductions =
(BindingPatternProduction | AssignmentPatternProduction),
FormalParametersProductions = (DistinctFormalParametersProduction |
StrictModeFormalParametersProduction |
StrongModeFormalParametersProduction),
- StandardProductions = ExpressionProduction | PatternProductions,
+ StandardProductions = ExpressionProductions | PatternProductions,
AllProductions = (StandardProductions | FormalParametersProductions |
ArrowFormalParametersProduction)
};
@@ -65,6 +68,10 @@ class ExpressionClassifier {
bool is_valid_expression() const { return is_valid(ExpressionProduction); }
+ bool is_valid_formal_parameter_initializer() const {
+ return is_valid(FormalParameterInitializerProduction);
+ }
+
bool is_valid_binding_pattern() const {
return is_valid(BindingPatternProduction);
}
@@ -95,6 +102,10 @@ class ExpressionClassifier {
const Error& expression_error() const { return expression_error_; }
+ const Error& formal_parameter_initializer_error() const {
+ return formal_parameter_initializer_error_;
+ }
+
const Error& binding_pattern_error() const { return binding_pattern_error_; }
const Error& assignment_pattern_error() const {
@@ -135,6 +146,16 @@ class ExpressionClassifier {
expression_error_.arg = arg;
}
+ void RecordFormalParameterInitializerError(const Scanner::Location& loc,
+ MessageTemplate::Template message,
+ const char* arg = nullptr) {
+ if (!is_valid_formal_parameter_initializer()) return;
+ invalid_productions_ |= FormalParameterInitializerProduction;
+ formal_parameter_initializer_error_.location = loc;
+ formal_parameter_initializer_error_.message = message;
+ formal_parameter_initializer_error_.arg = arg;
+ }
+
void RecordBindingPatternError(const Scanner::Location& loc,
MessageTemplate::Template message,
const char* arg = nullptr) {
@@ -212,6 +233,9 @@ class ExpressionClassifier {
invalid_productions_ |= errors;
if (errors & ExpressionProduction)
expression_error_ = inner.expression_error_;
+ if (errors & FormalParameterInitializerProduction)
+ formal_parameter_initializer_error_ =
+ inner.formal_parameter_initializer_error_;
if (errors & BindingPatternProduction)
binding_pattern_error_ = inner.binding_pattern_error_;
if (errors & AssignmentPatternProduction)
@@ -246,6 +270,7 @@ class ExpressionClassifier {
unsigned invalid_productions_;
unsigned function_properties_;
Error expression_error_;
+ Error formal_parameter_initializer_error_;
Error binding_pattern_error_;
Error assignment_pattern_error_;
Error arrow_formal_parameters_error_;
« no previous file with comments | « no previous file | src/preparser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698