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