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 1299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1310 return parser_->SpreadCallNew(function, args, pos); | 1310 return parser_->SpreadCallNew(function, args, pos); |
1311 } | 1311 } |
1312 | 1312 |
1313 | 1313 |
1314 void ParserTraits::DeclareFormalParameter( | 1314 void ParserTraits::DeclareFormalParameter( |
1315 ParserFormalParameterParsingState* parsing_state, Expression* pattern, | 1315 ParserFormalParameterParsingState* parsing_state, Expression* pattern, |
1316 ExpressionClassifier* classifier, bool is_rest) { | 1316 ExpressionClassifier* classifier, bool is_rest) { |
1317 bool is_duplicate = false; | 1317 bool is_duplicate = false; |
1318 bool is_simple_name = pattern->IsVariableProxy(); | 1318 bool is_simple_name = pattern->IsVariableProxy(); |
1319 DCHECK(parser_->allow_harmony_destructuring() || is_simple_name); | 1319 DCHECK(parser_->allow_harmony_destructuring() || is_simple_name); |
1320 | 1320 if (is_rest) parsing_state->has_rest = true; |
1321 const AstRawString* name = is_simple_name | 1321 const AstRawString* name = is_simple_name |
1322 ? pattern->AsVariableProxy()->raw_name() | 1322 ? pattern->AsVariableProxy()->raw_name() |
1323 : parser_->ast_value_factory()->empty_string(); | 1323 : parser_->ast_value_factory()->empty_string(); |
1324 Variable* var = | 1324 Variable* var = |
1325 parsing_state->scope->DeclareParameter(name, VAR, is_rest, &is_duplicate); | 1325 parsing_state->scope->DeclareParameter(name, VAR, is_rest, &is_duplicate); |
1326 parsing_state->AddParameter(var, is_simple_name ? nullptr : pattern); | 1326 parsing_state->AddParameter(var, is_simple_name ? nullptr : pattern); |
1327 if (is_sloppy(parsing_state->scope->language_mode())) { | 1327 if (is_sloppy(parsing_state->scope->language_mode())) { |
1328 // TODO(sigurds) Mark every parameter as maybe assigned. This is a | 1328 // TODO(sigurds) Mark every parameter as maybe assigned. This is a |
1329 // conservative approximation necessary to account for parameters | 1329 // conservative approximation necessary to account for parameters |
1330 // that are assigned via the arguments array. | 1330 // that are assigned via the arguments array. |
(...skipping 13 matching lines...) Expand all Loading... |
1344 auto* init_block = | 1344 auto* init_block = |
1345 parser_->BuildParameterInitializationBlock(formal_parameters, ok); | 1345 parser_->BuildParameterInitializationBlock(formal_parameters, ok); |
1346 if (!*ok) return; | 1346 if (!*ok) return; |
1347 if (init_block != nullptr) { | 1347 if (init_block != nullptr) { |
1348 body->Add(init_block, parser_->zone()); | 1348 body->Add(init_block, parser_->zone()); |
1349 } | 1349 } |
1350 } | 1350 } |
1351 } } // namespace v8::internal | 1351 } } // namespace v8::internal |
1352 | 1352 |
1353 #endif // V8_PARSER_H_ | 1353 #endif // V8_PARSER_H_ |
OLD | NEW |