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 1320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1331 ParserFormalParameters::Parameter(name, pattern, initializer, is_rest), | 1331 ParserFormalParameters::Parameter(name, pattern, initializer, is_rest), |
1332 parameters->scope->zone()); | 1332 parameters->scope->zone()); |
1333 } | 1333 } |
1334 | 1334 |
1335 | 1335 |
1336 void ParserTraits::DeclareFormalParameter( | 1336 void ParserTraits::DeclareFormalParameter( |
1337 Scope* scope, const ParserFormalParameters::Parameter& parameter, | 1337 Scope* scope, const ParserFormalParameters::Parameter& parameter, |
1338 ExpressionClassifier* classifier) { | 1338 ExpressionClassifier* classifier) { |
1339 bool is_duplicate = false; | 1339 bool is_duplicate = false; |
1340 bool is_simple = classifier->is_simple_parameter_list(); | 1340 bool is_simple = classifier->is_simple_parameter_list(); |
1341 // TODO(caitp): Remove special handling for rest once desugaring is in. | 1341 auto name = parameter.name; |
1342 auto name = is_simple || parameter.is_rest | 1342 auto mode = is_simple ? VAR : TEMPORARY; |
1343 ? parameter.name : parser_->ast_value_factory()->empty_string(); | |
1344 auto mode = is_simple || parameter.is_rest ? VAR : TEMPORARY; | |
1345 if (!is_simple) scope->SetHasNonSimpleParameters(); | 1343 if (!is_simple) scope->SetHasNonSimpleParameters(); |
1346 bool is_optional = parameter.initializer != nullptr; | 1344 bool is_optional = parameter.initializer != nullptr; |
1347 Variable* var = scope->DeclareParameter( | 1345 Variable* var = scope->DeclareParameter( |
1348 name, mode, is_optional, parameter.is_rest, &is_duplicate); | 1346 name, mode, is_optional, parameter.is_rest, &is_duplicate); |
1349 if (is_duplicate) { | 1347 if (is_duplicate) { |
1350 classifier->RecordDuplicateFormalParameterError( | 1348 classifier->RecordDuplicateFormalParameterError( |
1351 parser_->scanner()->location()); | 1349 parser_->scanner()->location()); |
1352 } | 1350 } |
1353 if (is_sloppy(scope->language_mode())) { | 1351 if (is_sloppy(scope->language_mode())) { |
1354 // TODO(sigurds) Mark every parameter as maybe assigned. This is a | 1352 // TODO(sigurds) Mark every parameter as maybe assigned. This is a |
(...skipping 12 matching lines...) Expand all Loading... |
1367 parser_->BuildParameterInitializationBlock(parameters, ok); | 1365 parser_->BuildParameterInitializationBlock(parameters, ok); |
1368 if (!*ok) return; | 1366 if (!*ok) return; |
1369 if (init_block != nullptr) { | 1367 if (init_block != nullptr) { |
1370 body->Add(init_block, parser_->zone()); | 1368 body->Add(init_block, parser_->zone()); |
1371 } | 1369 } |
1372 } | 1370 } |
1373 } | 1371 } |
1374 } } // namespace v8::internal | 1372 } } // namespace v8::internal |
1375 | 1373 |
1376 #endif // V8_PARSER_H_ | 1374 #endif // V8_PARSER_H_ |
OLD | NEW |