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

Unified Diff: src/expression-classifier.h

Issue 1309813007: [es6] implement destructuring assignment (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: An implementation Created 5 years, 1 month 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
Index: src/expression-classifier.h
diff --git a/src/expression-classifier.h b/src/expression-classifier.h
index 7392a7add8bd3c6ff63a8aba043c66cbfdb52ce8..1bd0b6303a1e7deeb7b2ba733667bc9ef356456f 100644
--- a/src/expression-classifier.h
+++ b/src/expression-classifier.h
@@ -36,6 +36,7 @@ class ExpressionClassifier {
StrongModeFormalParametersProduction = 1 << 6,
ArrowFormalParametersProduction = 1 << 7,
LetPatternProduction = 1 << 8,
+ CoverInitializedNameProduction = 1 << 9,
ExpressionProductions =
(ExpressionProduction | FormalParameterInitializerProduction),
@@ -45,8 +46,9 @@ class ExpressionClassifier {
StrictModeFormalParametersProduction |
StrongModeFormalParametersProduction),
StandardProductions = ExpressionProductions | PatternProductions,
- AllProductions = (StandardProductions | FormalParametersProductions |
- ArrowFormalParametersProduction)
+ AllProductions =
+ (StandardProductions | FormalParametersProductions |
+ ArrowFormalParametersProduction | CoverInitializedNameProduction)
};
enum FunctionProperties { NonSimpleParameter = 1 << 0 };
@@ -133,6 +135,13 @@ class ExpressionClassifier {
const Error& let_pattern_error() const { return let_pattern_error_; }
+ bool has_cover_initialized_name() const {
+ return !is_valid(CoverInitializedNameProduction);
+ }
+ const Error& cover_initialized_name_error() const {
+ return cover_initialized_name_error_;
+ }
+
bool is_simple_parameter_list() const {
return !(function_properties_ & NonSimpleParameter);
}
@@ -181,6 +190,13 @@ class ExpressionClassifier {
assignment_pattern_error_.arg = arg;
}
+ void RecordPatternError(const Scanner::Location& loc,
+ MessageTemplate::Template message,
+ const char* arg = nullptr) {
+ RecordBindingPatternError(loc, message, arg);
+ RecordAssignmentPatternError(loc, message, arg);
+ }
+
void RecordArrowFormalParametersError(const Scanner::Location& loc,
MessageTemplate::Template message,
const char* arg = nullptr) {
@@ -232,6 +248,26 @@ class ExpressionClassifier {
let_pattern_error_.arg = arg;
}
+ void RecordCoverInitializedNameError(const Scanner::Location& loc,
+ MessageTemplate::Template message,
+ const char* arg = nullptr) {
+ if (has_cover_initialized_name()) return;
+ invalid_productions_ |= CoverInitializedNameProduction;
+ cover_initialized_name_error_.location = loc;
+ cover_initialized_name_error_.message = message;
+ cover_initialized_name_error_.arg = arg;
+ }
+
+ void ForgiveCoverInitializedNameError() {
+ invalid_productions_ &= ~CoverInitializedNameProduction;
+ cover_initialized_name_error_ = Error();
+ }
+
+ void ForgiveAssignmentPatternError() {
+ invalid_productions_ &= ~AssignmentPatternProduction;
+ assignment_pattern_error_ = Error();
+ }
+
void Accumulate(const ExpressionClassifier& inner,
unsigned productions = StandardProductions) {
// Propagate errors from inner, but don't overwrite already recorded
@@ -266,6 +302,8 @@ class ExpressionClassifier {
inner.strong_mode_formal_parameter_error_;
if (errors & LetPatternProduction)
let_pattern_error_ = inner.let_pattern_error_;
+ if (errors & CoverInitializedNameProduction)
+ cover_initialized_name_error_ = inner.cover_initialized_name_error_;
}
// As an exception to the above, the result continues to be a valid arrow
@@ -295,6 +333,7 @@ class ExpressionClassifier {
Error strict_mode_formal_parameter_error_;
Error strong_mode_formal_parameter_error_;
Error let_pattern_error_;
+ Error cover_initialized_name_error_;
DuplicateFinder* duplicate_finder_;
};

Powered by Google App Engine
This is Rietveld 408576698