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 | |
1323 DeclareAndInitializeVariables( | 1327 DeclareAndInitializeVariables( |
1324 PreParserStatement::Default(), &for_info->parsing_result.descriptor, | 1328 PreParserStatement::Default(), &for_info->parsing_result.descriptor, |
1325 &for_info->parsing_result.declarations[0], nullptr, ok); | 1329 &for_info->parsing_result.declarations[0], |
1330 (IsLexicalVariableMode(for_info->parsing_result.descriptor.mode) || | |
vogelheim
2017/02/06 10:02:11
super nitpick: Maybe hoist this expression into an
marja
2017/02/06 10:11:53
added collect_names = ... here and in the correspo
| |
1331 is_for_var_of) | |
1332 ? &for_info->bound_names | |
1333 : nullptr, | |
1334 ok); | |
1326 } | 1335 } |
1327 } | 1336 } |
1328 | 1337 |
1329 V8_INLINE PreParserStatement CreateForEachStatementTDZ( | 1338 V8_INLINE PreParserStatement CreateForEachStatementTDZ( |
1330 PreParserStatement init_block, const ForInfo& for_info, bool* ok) { | 1339 PreParserStatement init_block, const ForInfo& for_info, bool* ok) { |
1340 if (track_unresolved_variables_) { | |
1341 if (IsLexicalVariableMode(for_info.parsing_result.descriptor.mode)) { | |
1342 for (auto name : for_info.bound_names) { | |
1343 scope()->DeclareVariableName(name, LET); | |
1344 } | |
1345 return PreParserStatement::Default(); | |
1346 } | |
1347 } | |
1331 return init_block; | 1348 return init_block; |
1332 } | 1349 } |
1333 | 1350 |
1334 V8_INLINE StatementT DesugarLexicalBindingsInForStatement( | 1351 V8_INLINE StatementT DesugarLexicalBindingsInForStatement( |
1335 PreParserStatement loop, PreParserStatement init, | 1352 PreParserStatement loop, PreParserStatement init, |
1336 PreParserExpression cond, PreParserStatement next, | 1353 PreParserExpression cond, PreParserStatement next, |
1337 PreParserStatement body, Scope* inner_scope, const ForInfo& for_info, | 1354 PreParserStatement body, Scope* inner_scope, const ForInfo& for_info, |
1338 bool* ok) { | 1355 bool* ok) { |
1339 // See Parser::DesugarLexicalBindingsInForStatement. | 1356 // See Parser::DesugarLexicalBindingsInForStatement. |
1340 for (int i = 0; i < for_info.bound_names.length(); i++) { | 1357 if (track_unresolved_variables_) { |
1341 inner_scope->DeclareVariableName(for_info.bound_names[i], | 1358 for (auto name : for_info.bound_names) { |
1342 for_info.parsing_result.descriptor.mode); | 1359 inner_scope->DeclareVariableName( |
1360 name, for_info.parsing_result.descriptor.mode); | |
1361 } | |
1343 } | 1362 } |
1344 return loop; | 1363 return loop; |
1345 } | 1364 } |
1346 | 1365 |
1347 V8_INLINE PreParserStatement BuildParameterInitializationBlock( | 1366 V8_INLINE PreParserStatement BuildParameterInitializationBlock( |
1348 const PreParserFormalParameters& parameters, bool* ok) { | 1367 const PreParserFormalParameters& parameters, bool* ok) { |
1349 return PreParserStatement::Default(); | 1368 return PreParserStatement::Default(); |
1350 } | 1369 } |
1351 | 1370 |
1352 V8_INLINE PreParserStatement | 1371 V8_INLINE PreParserStatement |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1663 function_state_->NextMaterializedLiteralIndex(); | 1682 function_state_->NextMaterializedLiteralIndex(); |
1664 function_state_->NextMaterializedLiteralIndex(); | 1683 function_state_->NextMaterializedLiteralIndex(); |
1665 } | 1684 } |
1666 return EmptyExpression(); | 1685 return EmptyExpression(); |
1667 } | 1686 } |
1668 | 1687 |
1669 } // namespace internal | 1688 } // namespace internal |
1670 } // namespace v8 | 1689 } // namespace v8 |
1671 | 1690 |
1672 #endif // V8_PARSING_PREPARSER_H | 1691 #endif // V8_PARSING_PREPARSER_H |
OLD | NEW |