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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 VariableProxy* proxy = parser_->NewUnresolved(name, descriptor_->mode); |
151 Declaration* declaration = factory()->NewVariableDeclaration( | 151 Declaration* declaration = factory()->NewVariableDeclaration( |
152 proxy, descriptor_->mode, descriptor_->scope, | 152 proxy, descriptor_->mode, descriptor_->scope, |
153 descriptor_->declaration_pos); | 153 descriptor_->declaration_pos); |
154 Variable* var = parser_->Declare(declaration, descriptor_->declaration_kind, | 154 Variable* var = parser_->Declare(declaration, descriptor_->declaration_kind, |
| 155 DefaultInitializationFlag(descriptor_->mode), |
155 ok_, descriptor_->hoist_scope); | 156 ok_, descriptor_->hoist_scope); |
156 if (!*ok_) return; | 157 if (!*ok_) return; |
157 DCHECK_NOT_NULL(var); | 158 DCHECK_NOT_NULL(var); |
158 DCHECK(!proxy->is_resolved() || proxy->var() == var); | 159 DCHECK(!proxy->is_resolved() || proxy->var() == var); |
| 160 DCHECK(initializer_position_ != kNoSourcePosition); |
159 var->set_initializer_position(initializer_position_); | 161 var->set_initializer_position(initializer_position_); |
160 | 162 |
161 DCHECK(initializer_position_ != kNoSourcePosition); | |
162 | |
163 // TODO(adamk): This should probably be checking hoist_scope. | 163 // TODO(adamk): This should probably be checking hoist_scope. |
164 // Move it to Parser::Declare() to make it easier to test | 164 // Move it to Parser::Declare() to make it easier to test |
165 // the right scope. | 165 // the right scope. |
166 Scope* declaration_scope = IsLexicalVariableMode(descriptor_->mode) | 166 Scope* declaration_scope = IsLexicalVariableMode(descriptor_->mode) |
167 ? descriptor_->scope | 167 ? descriptor_->scope |
168 : descriptor_->scope->GetDeclarationScope(); | 168 : descriptor_->scope->GetDeclarationScope(); |
169 if (declaration_scope->num_var() > kMaxNumFunctionLocals) { | 169 if (declaration_scope->num_var() > kMaxNumFunctionLocals) { |
170 parser_->ReportMessage(MessageTemplate::kTooManyVariables); | 170 parser_->ReportMessage(MessageTemplate::kTooManyVariables); |
171 *ok_ = false; | 171 *ok_ = false; |
172 return; | 172 return; |
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
700 NOT_A_PATTERN(TryFinallyStatement) | 700 NOT_A_PATTERN(TryFinallyStatement) |
701 NOT_A_PATTERN(UnaryOperation) | 701 NOT_A_PATTERN(UnaryOperation) |
702 NOT_A_PATTERN(VariableDeclaration) | 702 NOT_A_PATTERN(VariableDeclaration) |
703 NOT_A_PATTERN(WhileStatement) | 703 NOT_A_PATTERN(WhileStatement) |
704 NOT_A_PATTERN(WithStatement) | 704 NOT_A_PATTERN(WithStatement) |
705 NOT_A_PATTERN(Yield) | 705 NOT_A_PATTERN(Yield) |
706 | 706 |
707 #undef NOT_A_PATTERN | 707 #undef NOT_A_PATTERN |
708 } // namespace internal | 708 } // namespace internal |
709 } // namespace v8 | 709 } // namespace v8 |
OLD | NEW |