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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « src/expression-classifier.h ('k') | src/parser.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_PARSER_H_ 5 #ifndef V8_PARSER_H_
6 #define V8_PARSER_H_ 6 #define V8_PARSER_H_
7 7
8 #include "src/allocation.h" 8 #include "src/allocation.h"
9 #include "src/ast.h" 9 #include "src/ast.h"
10 #include "src/compiler.h" // TODO(titzer): remove this include dependency 10 #include "src/compiler.h" // TODO(titzer): remove this include dependency
(...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 } 747 }
748 ZoneList<ObjectLiteral::Property*>* NewPropertyList(int size, Zone* zone) { 748 ZoneList<ObjectLiteral::Property*>* NewPropertyList(int size, Zone* zone) {
749 return new(zone) ZoneList<ObjectLiteral::Property*>(size, zone); 749 return new(zone) ZoneList<ObjectLiteral::Property*>(size, zone);
750 } 750 }
751 ZoneList<v8::internal::Statement*>* NewStatementList(int size, Zone* zone) { 751 ZoneList<v8::internal::Statement*>* NewStatementList(int size, Zone* zone) {
752 return new(zone) ZoneList<v8::internal::Statement*>(size, zone); 752 return new(zone) ZoneList<v8::internal::Statement*>(size, zone);
753 } 753 }
754 V8_INLINE Scope* NewScope(Scope* parent_scope, ScopeType scope_type, 754 V8_INLINE Scope* NewScope(Scope* parent_scope, ScopeType scope_type,
755 FunctionKind kind = kNormalFunction); 755 FunctionKind kind = kNormalFunction);
756 756
757 bool DeclareFormalParameter(Scope* scope, const AstRawString* name, 757 V8_INLINE void DeclareFormalParameter(Scope* scope, const AstRawString* name,
758 bool is_rest) { 758 ExpressionClassifier* classifier,
759 bool is_duplicate = false; 759 bool is_rest);
760 Variable* var = scope->DeclareParameter(name, VAR, is_rest, &is_duplicate);
761 if (is_sloppy(scope->language_mode())) {
762 // TODO(sigurds) Mark every parameter as maybe assigned. This is a
763 // conservative approximation necessary to account for parameters
764 // that are assigned via the arguments array.
765 var->set_maybe_assigned();
766 }
767 return is_duplicate;
768 }
769
770 void DeclareArrowFunctionParameters(Scope* scope, Expression* expr, 760 void DeclareArrowFunctionParameters(Scope* scope, Expression* expr,
771 const Scanner::Location& params_loc, 761 const Scanner::Location& params_loc,
772 Scanner::Location* duplicate_loc, 762 Scanner::Location* duplicate_loc,
773 bool* ok); 763 bool* ok);
774 void ParseArrowFunctionFormalParameters(Scope* scope, Expression* params, 764 void ParseArrowFunctionFormalParameters(Scope* scope, Expression* params,
775 const Scanner::Location& params_loc, 765 const Scanner::Location& params_loc,
776 bool* is_rest, 766 bool* is_rest,
777 Scanner::Location* duplicate_loc, 767 Scanner::Location* duplicate_loc,
778 bool* ok); 768 bool* ok);
779 769
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after
1275 ZoneList<v8::internal::Expression*>* args, 1265 ZoneList<v8::internal::Expression*>* args,
1276 int pos) { 1266 int pos) {
1277 return parser_->SpreadCall(function, args, pos); 1267 return parser_->SpreadCall(function, args, pos);
1278 } 1268 }
1279 1269
1280 1270
1281 Expression* ParserTraits::SpreadCallNew( 1271 Expression* ParserTraits::SpreadCallNew(
1282 Expression* function, ZoneList<v8::internal::Expression*>* args, int pos) { 1272 Expression* function, ZoneList<v8::internal::Expression*>* args, int pos) {
1283 return parser_->SpreadCallNew(function, args, pos); 1273 return parser_->SpreadCallNew(function, args, pos);
1284 } 1274 }
1275
1276
1277 void ParserTraits::DeclareFormalParameter(Scope* scope,
1278 const AstRawString* name,
1279 ExpressionClassifier* classifier,
1280 bool is_rest) {
1281 bool is_duplicate = false;
1282 Variable* var = scope->DeclareParameter(name, VAR, is_rest, &is_duplicate);
1283 if (is_sloppy(scope->language_mode())) {
1284 // TODO(sigurds) Mark every parameter as maybe assigned. This is a
1285 // conservative approximation necessary to account for parameters
1286 // that are assigned via the arguments array.
1287 var->set_maybe_assigned();
1288 }
1289 if (is_duplicate) {
1290 classifier->RecordDuplicateFormalParameterError(
1291 parser_->scanner()->location());
1292 }
1293 }
1285 } } // namespace v8::internal 1294 } } // namespace v8::internal
1286 1295
1287 #endif // V8_PARSER_H_ 1296 #endif // V8_PARSER_H_
OLDNEW
« 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