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 765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
776 ZoneList<v8::internal::Statement*>* body, bool* ok); | 776 ZoneList<v8::internal::Statement*>* body, bool* ok); |
777 | 777 |
778 V8_INLINE Scope* NewScope(Scope* parent_scope, ScopeType scope_type, | 778 V8_INLINE Scope* NewScope(Scope* parent_scope, ScopeType scope_type, |
779 FunctionKind kind = kNormalFunction); | 779 FunctionKind kind = kNormalFunction); |
780 | 780 |
781 V8_INLINE void AddFormalParameter( | 781 V8_INLINE void AddFormalParameter( |
782 ParserFormalParameters* parameters, Expression* pattern, | 782 ParserFormalParameters* parameters, Expression* pattern, |
783 Expression* initializer, bool is_rest); | 783 Expression* initializer, bool is_rest); |
784 V8_INLINE void DeclareFormalParameter( | 784 V8_INLINE void DeclareFormalParameter( |
785 Scope* scope, const ParserFormalParameters::Parameter& parameter, | 785 Scope* scope, const ParserFormalParameters::Parameter& parameter, |
786 bool is_simple, ExpressionClassifier* classifier); | 786 ExpressionClassifier* classifier); |
787 void ParseArrowFunctionFormalParameters( | 787 void ParseArrowFunctionFormalParameters(ParserFormalParameters* parameters, |
788 ParserFormalParameters* parameters, Expression* params, | 788 Expression* params, |
789 const Scanner::Location& params_loc, | 789 const Scanner::Location& params_loc, |
790 Scanner::Location* duplicate_loc, bool* ok); | 790 bool* ok); |
791 void ParseArrowFunctionFormalParameterList( | 791 void ParseArrowFunctionFormalParameterList( |
792 ParserFormalParameters* parameters, Expression* params, | 792 ParserFormalParameters* parameters, Expression* params, |
793 const Scanner::Location& params_loc, | 793 const Scanner::Location& params_loc, |
794 Scanner::Location* duplicate_loc, bool* ok); | 794 Scanner::Location* duplicate_loc, bool* ok); |
795 | 795 |
796 void ReindexLiterals(const ParserFormalParameters& parameters); | 796 void ReindexLiterals(const ParserFormalParameters& parameters); |
797 | 797 |
798 // Temporary glue; these functions will move to ParserBase. | 798 // Temporary glue; these functions will move to ParserBase. |
799 Expression* ParseV8Intrinsic(bool* ok); | 799 Expression* ParseV8Intrinsic(bool* ok); |
800 FunctionLiteral* ParseFunctionLiteral( | 800 FunctionLiteral* ParseFunctionLiteral( |
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1325 ? pattern->AsVariableProxy()->raw_name() | 1325 ? pattern->AsVariableProxy()->raw_name() |
1326 : parser_->ast_value_factory()->empty_string(); | 1326 : parser_->ast_value_factory()->empty_string(); |
1327 parameters->params.Add( | 1327 parameters->params.Add( |
1328 ParserFormalParameters::Parameter(name, pattern, initializer, is_rest), | 1328 ParserFormalParameters::Parameter(name, pattern, initializer, is_rest), |
1329 parameters->scope->zone()); | 1329 parameters->scope->zone()); |
1330 } | 1330 } |
1331 | 1331 |
1332 | 1332 |
1333 void ParserTraits::DeclareFormalParameter( | 1333 void ParserTraits::DeclareFormalParameter( |
1334 Scope* scope, const ParserFormalParameters::Parameter& parameter, | 1334 Scope* scope, const ParserFormalParameters::Parameter& parameter, |
1335 bool is_simple, ExpressionClassifier* classifier) { | 1335 ExpressionClassifier* classifier) { |
1336 bool is_duplicate = false; | 1336 bool is_duplicate = false; |
| 1337 bool is_simple = classifier->is_simple_parameter_list(); |
1337 // TODO(caitp): Remove special handling for rest once desugaring is in. | 1338 // TODO(caitp): Remove special handling for rest once desugaring is in. |
1338 auto name = is_simple || parameter.is_rest | 1339 auto name = is_simple || parameter.is_rest |
1339 ? parameter.name : parser_->ast_value_factory()->empty_string(); | 1340 ? parameter.name : parser_->ast_value_factory()->empty_string(); |
1340 auto mode = is_simple || parameter.is_rest ? VAR : TEMPORARY; | 1341 auto mode = is_simple || parameter.is_rest ? VAR : TEMPORARY; |
| 1342 if (!is_simple) scope->SetHasNonSimpleParameters(); |
1341 Variable* var = | 1343 Variable* var = |
1342 scope->DeclareParameter(name, mode, parameter.is_rest, &is_duplicate); | 1344 scope->DeclareParameter(name, mode, parameter.is_rest, &is_duplicate); |
1343 if (is_duplicate) { | 1345 if (is_duplicate) { |
1344 classifier->RecordDuplicateFormalParameterError( | 1346 classifier->RecordDuplicateFormalParameterError( |
1345 parser_->scanner()->location()); | 1347 parser_->scanner()->location()); |
1346 } | 1348 } |
1347 if (is_sloppy(scope->language_mode())) { | 1349 if (is_sloppy(scope->language_mode())) { |
1348 // TODO(sigurds) Mark every parameter as maybe assigned. This is a | 1350 // TODO(sigurds) Mark every parameter as maybe assigned. This is a |
1349 // conservative approximation necessary to account for parameters | 1351 // conservative approximation necessary to account for parameters |
1350 // that are assigned via the arguments array. | 1352 // that are assigned via the arguments array. |
(...skipping 10 matching lines...) Expand all Loading... |
1361 parser_->BuildParameterInitializationBlock(parameters, ok); | 1363 parser_->BuildParameterInitializationBlock(parameters, ok); |
1362 if (!*ok) return; | 1364 if (!*ok) return; |
1363 if (init_block != nullptr) { | 1365 if (init_block != nullptr) { |
1364 body->Add(init_block, parser_->zone()); | 1366 body->Add(init_block, parser_->zone()); |
1365 } | 1367 } |
1366 } | 1368 } |
1367 } | 1369 } |
1368 } } // namespace v8::internal | 1370 } } // namespace v8::internal |
1369 | 1371 |
1370 #endif // V8_PARSER_H_ | 1372 #endif // V8_PARSER_H_ |
OLD | NEW |