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

Unified Diff: src/expression-classifier.h

Issue 1411203002: [es6] implement destructuring assignment [clean diff] (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rename `recorded_first()` to `FirstRecorded()` because non-accessor Created 5 years, 2 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 | « src/bootstrapper.cc ('k') | src/flag-definitions.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 7392a7add8bd3c6ff63a8aba043c66cbfdb52ce8..4ed47156572ae013b0e6f8bc7f087b98ee19cc87 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,21 @@ 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_.location = Scanner::Location::invalid();
+ }
+
void Accumulate(const ExpressionClassifier& inner,
unsigned productions = StandardProductions) {
// Propagate errors from inner, but don't overwrite already recorded
@@ -266,6 +297,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
@@ -283,6 +316,17 @@ class ExpressionClassifier {
}
}
+ static const Error& FirdRecorded(const Error& a, const Error& b) {
+ // Determine message which occurred earlier in source. Used by
+ // ParserBase::ValidateExpression()
+ DCHECK(a.location.IsValid() || b.location.IsValid());
+ if (a.location.beg_pos < 0) return b;
+ if (b.location.beg_pos < 0 || b.location.beg_pos >= a.location.beg_pos) {
+ return a;
+ }
+ return b;
+ }
+
private:
unsigned invalid_productions_;
unsigned function_properties_;
@@ -295,6 +339,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_;
};
« no previous file with comments | « src/bootstrapper.cc ('k') | src/flag-definitions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698