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

Unified Diff: src/parser.h

Issue 1170153003: [destructuring] Refactor duplicate parameter name detection. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebased Created 5 years, 6 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/expression-classifier.h ('k') | src/parser.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parser.h
diff --git a/src/parser.h b/src/parser.h
index 0d663b84e6206d516d851b9d7fd85b98cefa2763..d092403e7af1fb01e3298d6b53bcaa1c9b4090d9 100644
--- a/src/parser.h
+++ b/src/parser.h
@@ -754,19 +754,9 @@ class ParserTraits {
V8_INLINE Scope* NewScope(Scope* parent_scope, ScopeType scope_type,
FunctionKind kind = kNormalFunction);
- bool DeclareFormalParameter(Scope* scope, const AstRawString* name,
- bool is_rest) {
- bool is_duplicate = false;
- Variable* var = scope->DeclareParameter(name, VAR, is_rest, &is_duplicate);
- if (is_sloppy(scope->language_mode())) {
- // TODO(sigurds) Mark every parameter as maybe assigned. This is a
- // conservative approximation necessary to account for parameters
- // that are assigned via the arguments array.
- var->set_maybe_assigned();
- }
- return is_duplicate;
- }
-
+ V8_INLINE void DeclareFormalParameter(Scope* scope, const AstRawString* name,
+ ExpressionClassifier* classifier,
+ bool is_rest);
void DeclareArrowFunctionParameters(Scope* scope, Expression* expr,
const Scanner::Location& params_loc,
Scanner::Location* duplicate_loc,
@@ -1282,6 +1272,25 @@ Expression* ParserTraits::SpreadCallNew(
Expression* function, ZoneList<v8::internal::Expression*>* args, int pos) {
return parser_->SpreadCallNew(function, args, pos);
}
+
+
+void ParserTraits::DeclareFormalParameter(Scope* scope,
+ const AstRawString* name,
+ ExpressionClassifier* classifier,
+ bool is_rest) {
+ bool is_duplicate = false;
+ Variable* var = scope->DeclareParameter(name, VAR, is_rest, &is_duplicate);
+ if (is_sloppy(scope->language_mode())) {
+ // TODO(sigurds) Mark every parameter as maybe assigned. This is a
+ // conservative approximation necessary to account for parameters
+ // that are assigned via the arguments array.
+ var->set_maybe_assigned();
+ }
+ if (is_duplicate) {
+ classifier->RecordDuplicateFormalParameterError(
+ parser_->scanner()->location());
+ }
+}
} } // namespace v8::internal
#endif // V8_PARSER_H_
« no previous file with comments | « src/expression-classifier.h ('k') | src/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698