| OLD | NEW |
| 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 734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 745 } | 745 } |
| 746 ZoneList<ObjectLiteral::Property*>* NewPropertyList(int size, Zone* zone) { | 746 ZoneList<ObjectLiteral::Property*>* NewPropertyList(int size, Zone* zone) { |
| 747 return new(zone) ZoneList<ObjectLiteral::Property*>(size, zone); | 747 return new(zone) ZoneList<ObjectLiteral::Property*>(size, zone); |
| 748 } | 748 } |
| 749 ZoneList<v8::internal::Statement*>* NewStatementList(int size, Zone* zone) { | 749 ZoneList<v8::internal::Statement*>* NewStatementList(int size, Zone* zone) { |
| 750 return new(zone) ZoneList<v8::internal::Statement*>(size, zone); | 750 return new(zone) ZoneList<v8::internal::Statement*>(size, zone); |
| 751 } | 751 } |
| 752 V8_INLINE Scope* NewScope(Scope* parent_scope, ScopeType scope_type, | 752 V8_INLINE Scope* NewScope(Scope* parent_scope, ScopeType scope_type, |
| 753 FunctionKind kind = kNormalFunction); | 753 FunctionKind kind = kNormalFunction); |
| 754 | 754 |
| 755 bool DeclareFormalParameter(Scope* scope, const AstRawString* name, | 755 V8_INLINE void DeclareFormalParameter(Scope* scope, const AstRawString* name, |
| 756 bool is_rest) { | 756 ExpressionClassifier* classifier, |
| 757 bool is_duplicate = false; | 757 bool is_rest); |
| 758 Variable* var = scope->DeclareParameter(name, VAR, is_rest, &is_duplicate); | |
| 759 if (is_sloppy(scope->language_mode())) { | |
| 760 // TODO(sigurds) Mark every parameter as maybe assigned. This is a | |
| 761 // conservative approximation necessary to account for parameters | |
| 762 // that are assigned via the arguments array. | |
| 763 var->set_maybe_assigned(); | |
| 764 } | |
| 765 return is_duplicate; | |
| 766 } | |
| 767 | |
| 768 void DeclareArrowFunctionParameters(Scope* scope, Expression* expr, | 758 void DeclareArrowFunctionParameters(Scope* scope, Expression* expr, |
| 769 const Scanner::Location& params_loc, | 759 const Scanner::Location& params_loc, |
| 770 Scanner::Location* duplicate_loc, | 760 Scanner::Location* duplicate_loc, |
| 771 bool* ok); | 761 bool* ok); |
| 772 void ParseArrowFunctionFormalParameters(Scope* scope, Expression* params, | 762 void ParseArrowFunctionFormalParameters(Scope* scope, Expression* params, |
| 773 const Scanner::Location& params_loc, | 763 const Scanner::Location& params_loc, |
| 774 bool* is_rest, | 764 bool* is_rest, |
| 775 Scanner::Location* duplicate_loc, | 765 Scanner::Location* duplicate_loc, |
| 776 bool* ok); | 766 bool* ok); |
| 777 | 767 |
| (...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1273 ZoneList<v8::internal::Expression*>* args, | 1263 ZoneList<v8::internal::Expression*>* args, |
| 1274 int pos) { | 1264 int pos) { |
| 1275 return parser_->SpreadCall(function, args, pos); | 1265 return parser_->SpreadCall(function, args, pos); |
| 1276 } | 1266 } |
| 1277 | 1267 |
| 1278 | 1268 |
| 1279 Expression* ParserTraits::SpreadCallNew( | 1269 Expression* ParserTraits::SpreadCallNew( |
| 1280 Expression* function, ZoneList<v8::internal::Expression*>* args, int pos) { | 1270 Expression* function, ZoneList<v8::internal::Expression*>* args, int pos) { |
| 1281 return parser_->SpreadCallNew(function, args, pos); | 1271 return parser_->SpreadCallNew(function, args, pos); |
| 1282 } | 1272 } |
| 1273 |
| 1274 |
| 1275 void ParserTraits::DeclareFormalParameter(Scope* scope, |
| 1276 const AstRawString* name, |
| 1277 ExpressionClassifier* classifier, |
| 1278 bool is_rest) { |
| 1279 bool is_duplicate = false; |
| 1280 Variable* var = scope->DeclareParameter(name, VAR, is_rest, &is_duplicate); |
| 1281 if (is_sloppy(scope->language_mode())) { |
| 1282 // TODO(sigurds) Mark every parameter as maybe assigned. This is a |
| 1283 // conservative approximation necessary to account for parameters |
| 1284 // that are assigned via the arguments array. |
| 1285 var->set_maybe_assigned(); |
| 1286 } |
| 1287 if (is_duplicate) { |
| 1288 classifier->RecordDuplicateFormalParameterError( |
| 1289 parser_->scanner()->location()); |
| 1290 } |
| 1291 } |
| 1283 } } // namespace v8::internal | 1292 } } // namespace v8::internal |
| 1284 | 1293 |
| 1285 #endif // V8_PARSER_H_ | 1294 #endif // V8_PARSER_H_ |
| OLD | NEW |