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_PARSING_PARSER_H_ | 5 #ifndef V8_PARSING_PARSER_H_ |
6 #define V8_PARSING_PARSER_H_ | 6 #define V8_PARSING_PARSER_H_ |
7 | 7 |
8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
9 #include "src/ast/ast.h" | 9 #include "src/ast/ast.h" |
10 #include "src/ast/scopes.h" | 10 #include "src/ast/scopes.h" |
(...skipping 1376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1387 Expression* function, ZoneList<v8::internal::Expression*>* args, int pos) { | 1387 Expression* function, ZoneList<v8::internal::Expression*>* args, int pos) { |
1388 return parser_->SpreadCallNew(function, args, pos); | 1388 return parser_->SpreadCallNew(function, args, pos); |
1389 } | 1389 } |
1390 | 1390 |
1391 | 1391 |
1392 void ParserTraits::AddFormalParameter(ParserFormalParameters* parameters, | 1392 void ParserTraits::AddFormalParameter(ParserFormalParameters* parameters, |
1393 Expression* pattern, | 1393 Expression* pattern, |
1394 Expression* initializer, | 1394 Expression* initializer, |
1395 int initializer_end_position, | 1395 int initializer_end_position, |
1396 bool is_rest) { | 1396 bool is_rest) { |
1397 bool is_simple = | 1397 bool is_simple = pattern->IsVariableProxy() && initializer == nullptr; |
1398 !is_rest && pattern->IsVariableProxy() && initializer == nullptr; | |
1399 const AstRawString* name = is_simple | 1398 const AstRawString* name = is_simple |
1400 ? pattern->AsVariableProxy()->raw_name() | 1399 ? pattern->AsVariableProxy()->raw_name() |
1401 : parser_->ast_value_factory()->empty_string(); | 1400 : parser_->ast_value_factory()->empty_string(); |
1402 parameters->params.Add( | 1401 parameters->params.Add( |
1403 ParserFormalParameters::Parameter(name, pattern, initializer, | 1402 ParserFormalParameters::Parameter(name, pattern, initializer, |
1404 initializer_end_position, is_rest), | 1403 initializer_end_position, is_rest), |
1405 parameters->scope->zone()); | 1404 parameters->scope->zone()); |
1406 } | 1405 } |
1407 | 1406 |
1408 | 1407 |
1409 void ParserTraits::DeclareFormalParameter( | 1408 void ParserTraits::DeclareFormalParameter( |
1410 Scope* scope, const ParserFormalParameters::Parameter& parameter, | 1409 Scope* scope, const ParserFormalParameters::Parameter& parameter, |
1411 ExpressionClassifier* classifier) { | 1410 ExpressionClassifier* classifier) { |
1412 bool is_duplicate = false; | 1411 bool is_duplicate = false; |
1413 bool is_simple = classifier->is_simple_parameter_list(); | 1412 bool is_simple = classifier->is_simple_parameter_list(); |
1414 auto name = parameter.name; | 1413 auto name = is_simple || parameter.is_rest |
1415 auto mode = is_simple ? VAR : TEMPORARY; | 1414 ? parameter.name |
| 1415 : parser_->ast_value_factory()->empty_string(); |
| 1416 auto mode = is_simple || parameter.is_rest ? VAR : TEMPORARY; |
1416 if (!is_simple) scope->SetHasNonSimpleParameters(); | 1417 if (!is_simple) scope->SetHasNonSimpleParameters(); |
1417 bool is_optional = parameter.initializer != nullptr; | 1418 bool is_optional = parameter.initializer != nullptr; |
1418 Variable* var = scope->DeclareParameter( | 1419 Variable* var = scope->DeclareParameter( |
1419 name, mode, is_optional, parameter.is_rest, &is_duplicate); | 1420 name, mode, is_optional, parameter.is_rest, &is_duplicate); |
1420 if (is_duplicate) { | 1421 if (is_duplicate) { |
1421 classifier->RecordDuplicateFormalParameterError( | 1422 classifier->RecordDuplicateFormalParameterError( |
1422 parser_->scanner()->location()); | 1423 parser_->scanner()->location()); |
1423 } | 1424 } |
1424 if (is_sloppy(scope->language_mode())) { | 1425 if (is_sloppy(scope->language_mode())) { |
1425 // TODO(sigurds) Mark every parameter as maybe assigned. This is a | 1426 // TODO(sigurds) Mark every parameter as maybe assigned. This is a |
(...skipping 20 matching lines...) Expand all Loading... |
1446 | 1447 |
1447 DoExpression* ParserTraits::ParseDoExpression(bool* ok) { | 1448 DoExpression* ParserTraits::ParseDoExpression(bool* ok) { |
1448 return parser_->ParseDoExpression(ok); | 1449 return parser_->ParseDoExpression(ok); |
1449 } | 1450 } |
1450 | 1451 |
1451 | 1452 |
1452 } // namespace internal | 1453 } // namespace internal |
1453 } // namespace v8 | 1454 } // namespace v8 |
1454 | 1455 |
1455 #endif // V8_PARSING_PARSER_H_ | 1456 #endif // V8_PARSING_PARSER_H_ |
OLD | NEW |