OLD | NEW |
---|---|
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/ast/ast.h" | 5 #include "src/ast/ast.h" |
6 #include "src/messages.h" | 6 #include "src/messages.h" |
7 #include "src/parsing/parameter-initializer-rewriter.h" | 7 #include "src/parsing/parameter-initializer-rewriter.h" |
8 #include "src/parsing/parser.h" | 8 #include "src/parsing/parser.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
140 // an initial value in the declaration (because they are initialized upon | 140 // an initial value in the declaration (because they are initialized upon |
141 // entering the function). | 141 // entering the function). |
142 // | 142 // |
143 // If we have a legacy const declaration, in an inner scope, the proxy | 143 // If we have a legacy const declaration, in an inner scope, the proxy |
144 // is always bound to the declared variable (independent of possibly | 144 // is always bound to the declared variable (independent of possibly |
145 // surrounding 'with' statements). | 145 // surrounding 'with' statements). |
146 // For let/const declarations in harmony mode, we can also immediately | 146 // For let/const declarations in harmony mode, we can also immediately |
147 // pre-resolve the proxy because it resides in the same scope as the | 147 // pre-resolve the proxy because it resides in the same scope as the |
148 // declaration. | 148 // declaration. |
149 const AstRawString* name = pattern->raw_name(); | 149 const AstRawString* name = pattern->raw_name(); |
150 VariableProxy* proxy = parser_->NewUnresolved(name, descriptor_->mode); | 150 Scope* scope = IsLexicalVariableMode(descriptor_->mode) |
151 ? parser_->scope() | |
152 : parser_->GetDeclarationScope(); | |
153 VariableProxy* proxy = scope->NewUnresolved( | |
adamk
2016/08/10 17:37:43
I think this should just be unconditionally create
| |
154 factory(), name, parser_->scanner()->location().beg_pos, | |
155 parser_->scanner()->location().end_pos); | |
151 Declaration* declaration = factory()->NewVariableDeclaration( | 156 Declaration* declaration = factory()->NewVariableDeclaration( |
152 proxy, descriptor_->mode, descriptor_->scope, | 157 proxy, descriptor_->mode, descriptor_->scope, |
153 descriptor_->declaration_pos); | 158 descriptor_->declaration_pos); |
154 Variable* var = parser_->Declare(declaration, descriptor_->declaration_kind, | 159 Variable* var = parser_->Declare(declaration, descriptor_->declaration_kind, |
155 DefaultInitializationFlag(descriptor_->mode), | 160 DefaultInitializationFlag(descriptor_->mode), |
156 ok_, descriptor_->hoist_scope); | 161 ok_, descriptor_->hoist_scope); |
157 if (!*ok_) return; | 162 if (!*ok_) return; |
158 DCHECK_NOT_NULL(var); | 163 DCHECK_NOT_NULL(var); |
159 DCHECK(!proxy->is_resolved() || proxy->var() == var); | 164 DCHECK(!proxy->is_resolved() || proxy->var() == var); |
160 DCHECK(initializer_position_ != kNoSourcePosition); | 165 DCHECK(initializer_position_ != kNoSourcePosition); |
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
700 NOT_A_PATTERN(TryFinallyStatement) | 705 NOT_A_PATTERN(TryFinallyStatement) |
701 NOT_A_PATTERN(UnaryOperation) | 706 NOT_A_PATTERN(UnaryOperation) |
702 NOT_A_PATTERN(VariableDeclaration) | 707 NOT_A_PATTERN(VariableDeclaration) |
703 NOT_A_PATTERN(WhileStatement) | 708 NOT_A_PATTERN(WhileStatement) |
704 NOT_A_PATTERN(WithStatement) | 709 NOT_A_PATTERN(WithStatement) |
705 NOT_A_PATTERN(Yield) | 710 NOT_A_PATTERN(Yield) |
706 | 711 |
707 #undef NOT_A_PATTERN | 712 #undef NOT_A_PATTERN |
708 } // namespace internal | 713 } // namespace internal |
709 } // namespace v8 | 714 } // namespace v8 |
OLD | NEW |