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 <memory> | 7 #include <memory> |
8 | 8 |
9 #include "src/api.h" | 9 #include "src/api.h" |
10 #include "src/ast/ast-expression-rewriter.h" | 10 #include "src/ast/ast-expression-rewriter.h" |
(...skipping 3621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3632 } | 3632 } |
3633 | 3633 |
3634 | 3634 |
3635 void Parser::InsertShadowingVarBindingInitializers(Block* inner_block) { | 3635 void Parser::InsertShadowingVarBindingInitializers(Block* inner_block) { |
3636 // For each var-binding that shadows a parameter, insert an assignment | 3636 // For each var-binding that shadows a parameter, insert an assignment |
3637 // initializing the variable with the parameter. | 3637 // initializing the variable with the parameter. |
3638 Scope* inner_scope = inner_block->scope(); | 3638 Scope* inner_scope = inner_block->scope(); |
3639 DCHECK(inner_scope->is_declaration_scope()); | 3639 DCHECK(inner_scope->is_declaration_scope()); |
3640 Scope* function_scope = inner_scope->outer_scope(); | 3640 Scope* function_scope = inner_scope->outer_scope(); |
3641 DCHECK(function_scope->is_function_scope()); | 3641 DCHECK(function_scope->is_function_scope()); |
3642 ZoneList<Declaration*>* decls = inner_scope->declarations(); | |
3643 BlockState block_state(&scope_state_, inner_scope); | 3642 BlockState block_state(&scope_state_, inner_scope); |
3644 for (int i = 0; i < decls->length(); ++i) { | 3643 for (Declaration* decl : *inner_scope->declarations()) { |
3645 Declaration* decl = decls->at(i); | |
3646 if (decl->proxy()->var()->mode() != VAR || !decl->IsVariableDeclaration()) { | 3644 if (decl->proxy()->var()->mode() != VAR || !decl->IsVariableDeclaration()) { |
3647 continue; | 3645 continue; |
3648 } | 3646 } |
3649 const AstRawString* name = decl->proxy()->raw_name(); | 3647 const AstRawString* name = decl->proxy()->raw_name(); |
3650 Variable* parameter = function_scope->LookupLocal(name); | 3648 Variable* parameter = function_scope->LookupLocal(name); |
3651 if (parameter == nullptr) continue; | 3649 if (parameter == nullptr) continue; |
3652 VariableProxy* to = NewUnresolved(name); | 3650 VariableProxy* to = NewUnresolved(name); |
3653 VariableProxy* from = factory()->NewVariableProxy(parameter); | 3651 VariableProxy* from = factory()->NewVariableProxy(parameter); |
3654 Expression* assignment = | 3652 Expression* assignment = |
3655 factory()->NewAssignment(Token::ASSIGN, to, from, kNoSourcePosition); | 3653 factory()->NewAssignment(Token::ASSIGN, to, from, kNoSourcePosition); |
(...skipping 1750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5406 | 5404 |
5407 return final_loop; | 5405 return final_loop; |
5408 } | 5406 } |
5409 | 5407 |
5410 #undef CHECK_OK | 5408 #undef CHECK_OK |
5411 #undef CHECK_OK_VOID | 5409 #undef CHECK_OK_VOID |
5412 #undef CHECK_FAILED | 5410 #undef CHECK_FAILED |
5413 | 5411 |
5414 } // namespace internal | 5412 } // namespace internal |
5415 } // namespace v8 | 5413 } // namespace v8 |
OLD | NEW |