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 #include "src/parsing/parser.h" | 5 #include "src/parsing/parser.h" |
6 | 6 |
7 #include "src/api.h" | 7 #include "src/api.h" |
8 #include "src/ast/ast.h" | 8 #include "src/ast/ast.h" |
9 #include "src/ast/ast-expression-rewriter.h" | 9 #include "src/ast/ast-expression-rewriter.h" |
10 #include "src/ast/ast-expression-visitor.h" | 10 #include "src/ast/ast-expression-visitor.h" |
(...skipping 3482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3493 *ok = false; | 3493 *ok = false; |
3494 return nullptr; | 3494 return nullptr; |
3495 } | 3495 } |
3496 | 3496 |
3497 Block* init_block = nullptr; | 3497 Block* init_block = nullptr; |
3498 | 3498 |
3499 // special case for legacy for (var/const x =.... in) | 3499 // special case for legacy for (var/const x =.... in) |
3500 if (!IsLexicalVariableMode(parsing_result.descriptor.mode) && | 3500 if (!IsLexicalVariableMode(parsing_result.descriptor.mode) && |
3501 decl.pattern->IsVariableProxy() && decl.initializer != nullptr) { | 3501 decl.pattern->IsVariableProxy() && decl.initializer != nullptr) { |
3502 ++use_counts_[v8::Isolate::kForInInitializer]; | 3502 ++use_counts_[v8::Isolate::kForInInitializer]; |
3503 if (FLAG_harmony_for_in) { | |
nickie
2016/04/22 11:22:56
Shouldn't a similar thing be added to the preparse
rossberg
2016/04/22 11:34:50
Yes, normally it should. However, we'd lose use co
adamk
2016/04/22 17:28:18
This inconsistency seems like it'll cause us some
| |
3504 ParserTraits::ReportMessageAt( | |
3505 parsing_result.first_initializer_loc, | |
3506 MessageTemplate::kForInOfLoopInitializer, | |
3507 ForEachStatement::VisitModeString(mode)); | |
3508 *ok = false; | |
3509 return nullptr; | |
3510 } | |
3503 const AstRawString* name = | 3511 const AstRawString* name = |
3504 decl.pattern->AsVariableProxy()->raw_name(); | 3512 decl.pattern->AsVariableProxy()->raw_name(); |
3505 VariableProxy* single_var = scope_->NewUnresolved( | 3513 VariableProxy* single_var = scope_->NewUnresolved( |
3506 factory(), name, Variable::NORMAL, each_beg_pos, each_end_pos); | 3514 factory(), name, Variable::NORMAL, each_beg_pos, each_end_pos); |
3507 init_block = factory()->NewBlock( | 3515 init_block = factory()->NewBlock( |
3508 nullptr, 2, true, parsing_result.descriptor.declaration_pos); | 3516 nullptr, 2, true, parsing_result.descriptor.declaration_pos); |
3509 init_block->statements()->Add( | 3517 init_block->statements()->Add( |
3510 factory()->NewExpressionStatement( | 3518 factory()->NewExpressionStatement( |
3511 factory()->NewAssignment(Token::ASSIGN, single_var, | 3519 factory()->NewAssignment(Token::ASSIGN, single_var, |
3512 decl.initializer, | 3520 decl.initializer, |
(...skipping 3270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6783 try_block, target); | 6791 try_block, target); |
6784 final_loop = target; | 6792 final_loop = target; |
6785 } | 6793 } |
6786 | 6794 |
6787 return final_loop; | 6795 return final_loop; |
6788 } | 6796 } |
6789 | 6797 |
6790 | 6798 |
6791 } // namespace internal | 6799 } // namespace internal |
6792 } // namespace v8 | 6800 } // namespace v8 |
OLD | NEW |