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 1326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 // TODO(caitp): Remove special handling for rest once desugaring is in. |
1342 auto name = is_simple || parameter.is_rest | 1342 auto name = is_simple || parameter.is_rest |
1343 ? parameter.name : parser_->ast_value_factory()->empty_string(); | 1343 ? parameter.name : parser_->ast_value_factory()->empty_string(); |
1344 auto mode = is_simple || parameter.is_rest ? VAR : TEMPORARY; | 1344 auto mode = is_simple || parameter.is_rest ? VAR : TEMPORARY; |
1345 if (!is_simple) scope->SetHasNonSimpleParameters(); | 1345 if (!is_simple) scope->SetHasNonSimpleParameters(); |
1346 bool is_optional = parameter.initializer != nullptr; | 1346 bool is_optional = parameter.initializer != nullptr; |
1347 Variable* var = scope->DeclareParameter( | 1347 Variable* var = scope->DeclareParameter(name, mode, is_optional, |
Benedikt Meurer
2015/08/27 04:34:51
Please revert this unrelated change.
gdeepti
2015/08/27 18:49:17
Done.
| |
1348 name, mode, is_optional, parameter.is_rest, &is_duplicate); | 1348 parameter.is_rest, &is_duplicate); |
1349 if (is_duplicate) { | 1349 if (is_duplicate) { |
1350 classifier->RecordDuplicateFormalParameterError( | 1350 classifier->RecordDuplicateFormalParameterError( |
1351 parser_->scanner()->location()); | 1351 parser_->scanner()->location()); |
1352 } | 1352 } |
1353 if (is_sloppy(scope->language_mode())) { | 1353 if (is_sloppy(scope->language_mode())) { |
1354 // TODO(sigurds) Mark every parameter as maybe assigned. This is a | 1354 // TODO(sigurds) Mark every parameter as maybe assigned. This is a |
1355 // conservative approximation necessary to account for parameters | 1355 // conservative approximation necessary to account for parameters |
1356 // that are assigned via the arguments array. | 1356 // that are assigned via the arguments array. |
1357 var->set_maybe_assigned(); | 1357 var->set_maybe_assigned(); |
1358 } | 1358 } |
1359 } | 1359 } |
1360 | 1360 |
1361 | 1361 |
1362 void ParserTraits::AddParameterInitializationBlock( | 1362 void ParserTraits::AddParameterInitializationBlock( |
1363 const ParserFormalParameters& parameters, | 1363 const ParserFormalParameters& parameters, |
1364 ZoneList<v8::internal::Statement*>* body, bool* ok) { | 1364 ZoneList<v8::internal::Statement*>* body, bool* ok) { |
1365 if (!parameters.is_simple) { | 1365 if (!parameters.is_simple) { |
1366 auto* init_block = | 1366 auto* init_block = |
1367 parser_->BuildParameterInitializationBlock(parameters, ok); | 1367 parser_->BuildParameterInitializationBlock(parameters, ok); |
1368 if (!*ok) return; | 1368 if (!*ok) return; |
1369 if (init_block != nullptr) { | 1369 if (init_block != nullptr) { |
1370 body->Add(init_block, parser_->zone()); | 1370 body->Add(init_block, parser_->zone()); |
1371 } | 1371 } |
1372 } | 1372 } |
1373 } | 1373 } |
1374 } } // namespace v8::internal | 1374 } } // namespace v8::internal |
1375 | 1375 |
1376 #endif // V8_PARSER_H_ | 1376 #endif // V8_PARSER_H_ |
OLD | NEW |