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_PREPARSER_H | 5 #ifndef V8_PARSING_PREPARSER_H |
6 #define V8_PARSING_PREPARSER_H | 6 #define V8_PARSING_PREPARSER_H |
7 | 7 |
8 #include "src/ast/ast.h" | 8 #include "src/ast/ast.h" |
9 #include "src/ast/scopes.h" | 9 #include "src/ast/scopes.h" |
10 #include "src/parsing/parser-base.h" | 10 #include "src/parsing/parser-base.h" |
(...skipping 1302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1313 | 1313 |
1314 V8_INLINE PreParserStatement RewriteForVarInLegacy(const ForInfo& for_info) { | 1314 V8_INLINE PreParserStatement RewriteForVarInLegacy(const ForInfo& for_info) { |
1315 return PreParserStatement::Null(); | 1315 return PreParserStatement::Null(); |
1316 } | 1316 } |
1317 | 1317 |
1318 V8_INLINE void DesugarBindingInForEachStatement( | 1318 V8_INLINE void DesugarBindingInForEachStatement( |
1319 ForInfo* for_info, PreParserStatement* body_block, | 1319 ForInfo* for_info, PreParserStatement* body_block, |
1320 PreParserExpression* each_variable, bool* ok) { | 1320 PreParserExpression* each_variable, bool* ok) { |
1321 if (track_unresolved_variables_) { | 1321 if (track_unresolved_variables_) { |
1322 DCHECK(for_info->parsing_result.declarations.length() == 1); | 1322 DCHECK(for_info->parsing_result.declarations.length() == 1); |
| 1323 bool is_for_var_of = |
| 1324 for_info->mode == ForEachStatement::ITERATE && |
| 1325 for_info->parsing_result.descriptor.mode == VariableMode::VAR; |
| 1326 bool collect_names = |
| 1327 IsLexicalVariableMode(for_info->parsing_result.descriptor.mode) || |
| 1328 is_for_var_of; |
| 1329 |
1323 DeclareAndInitializeVariables( | 1330 DeclareAndInitializeVariables( |
1324 PreParserStatement::Default(), &for_info->parsing_result.descriptor, | 1331 PreParserStatement::Default(), &for_info->parsing_result.descriptor, |
1325 &for_info->parsing_result.declarations[0], nullptr, ok); | 1332 &for_info->parsing_result.declarations[0], |
| 1333 collect_names ? &for_info->bound_names : nullptr, ok); |
1326 } | 1334 } |
1327 } | 1335 } |
1328 | 1336 |
1329 V8_INLINE PreParserStatement CreateForEachStatementTDZ( | 1337 V8_INLINE PreParserStatement CreateForEachStatementTDZ( |
1330 PreParserStatement init_block, const ForInfo& for_info, bool* ok) { | 1338 PreParserStatement init_block, const ForInfo& for_info, bool* ok) { |
| 1339 if (track_unresolved_variables_) { |
| 1340 if (IsLexicalVariableMode(for_info.parsing_result.descriptor.mode)) { |
| 1341 for (auto name : for_info.bound_names) { |
| 1342 scope()->DeclareVariableName(name, LET); |
| 1343 } |
| 1344 return PreParserStatement::Default(); |
| 1345 } |
| 1346 } |
1331 return init_block; | 1347 return init_block; |
1332 } | 1348 } |
1333 | 1349 |
1334 V8_INLINE StatementT DesugarLexicalBindingsInForStatement( | 1350 V8_INLINE StatementT DesugarLexicalBindingsInForStatement( |
1335 PreParserStatement loop, PreParserStatement init, | 1351 PreParserStatement loop, PreParserStatement init, |
1336 PreParserExpression cond, PreParserStatement next, | 1352 PreParserExpression cond, PreParserStatement next, |
1337 PreParserStatement body, Scope* inner_scope, const ForInfo& for_info, | 1353 PreParserStatement body, Scope* inner_scope, const ForInfo& for_info, |
1338 bool* ok) { | 1354 bool* ok) { |
1339 // See Parser::DesugarLexicalBindingsInForStatement. | 1355 // See Parser::DesugarLexicalBindingsInForStatement. |
1340 for (int i = 0; i < for_info.bound_names.length(); i++) { | 1356 if (track_unresolved_variables_) { |
1341 inner_scope->DeclareVariableName(for_info.bound_names[i], | 1357 for (auto name : for_info.bound_names) { |
1342 for_info.parsing_result.descriptor.mode); | 1358 inner_scope->DeclareVariableName( |
| 1359 name, for_info.parsing_result.descriptor.mode); |
| 1360 } |
1343 } | 1361 } |
1344 return loop; | 1362 return loop; |
1345 } | 1363 } |
1346 | 1364 |
1347 V8_INLINE PreParserStatement BuildParameterInitializationBlock( | 1365 V8_INLINE PreParserStatement BuildParameterInitializationBlock( |
1348 const PreParserFormalParameters& parameters, bool* ok) { | 1366 const PreParserFormalParameters& parameters, bool* ok) { |
1349 return PreParserStatement::Default(); | 1367 return PreParserStatement::Default(); |
1350 } | 1368 } |
1351 | 1369 |
1352 V8_INLINE PreParserStatement | 1370 V8_INLINE PreParserStatement |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1663 function_state_->NextMaterializedLiteralIndex(); | 1681 function_state_->NextMaterializedLiteralIndex(); |
1664 function_state_->NextMaterializedLiteralIndex(); | 1682 function_state_->NextMaterializedLiteralIndex(); |
1665 } | 1683 } |
1666 return EmptyExpression(); | 1684 return EmptyExpression(); |
1667 } | 1685 } |
1668 | 1686 |
1669 } // namespace internal | 1687 } // namespace internal |
1670 } // namespace v8 | 1688 } // namespace v8 |
1671 | 1689 |
1672 #endif // V8_PARSING_PREPARSER_H | 1690 #endif // V8_PARSING_PREPARSER_H |
OLD | NEW |