OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 <cmath> | 5 #include <cmath> |
6 | 6 |
7 #include "src/allocation.h" | 7 #include "src/allocation.h" |
8 #include "src/base/logging.h" | 8 #include "src/base/logging.h" |
9 #include "src/conversions-inl.h" | 9 #include "src/conversions-inl.h" |
10 #include "src/conversions.h" | 10 #include "src/conversions.h" |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 if (declaration->pattern.identifiers_ != nullptr) { | 289 if (declaration->pattern.identifiers_ != nullptr) { |
290 DCHECK(FLAG_lazy_inner_functions); | 290 DCHECK(FLAG_lazy_inner_functions); |
291 /* Mimic what Parser does when declaring variables (see | 291 /* Mimic what Parser does when declaring variables (see |
292 Parser::PatternRewriter::VisitVariableProxy). | 292 Parser::PatternRewriter::VisitVariableProxy). |
293 | 293 |
294 var + no initializer -> RemoveUnresolved | 294 var + no initializer -> RemoveUnresolved |
295 let / const + no initializer -> RemoveUnresolved | 295 let / const + no initializer -> RemoveUnresolved |
296 var + initializer -> RemoveUnresolved followed by NewUnresolved | 296 var + initializer -> RemoveUnresolved followed by NewUnresolved |
297 let / const + initializer -> RemoveUnresolved | 297 let / const + initializer -> RemoveUnresolved |
298 */ | 298 */ |
299 | 299 Scope* scope = declaration_descriptor->hoist_scope; |
| 300 if (scope == nullptr) { |
| 301 scope = this->scope(); |
| 302 } |
300 if (declaration->initializer.IsEmpty() || | 303 if (declaration->initializer.IsEmpty() || |
301 (declaration_descriptor->mode == VariableMode::LET || | 304 (declaration_descriptor->mode == VariableMode::LET || |
302 declaration_descriptor->mode == VariableMode::CONST)) { | 305 declaration_descriptor->mode == VariableMode::CONST)) { |
303 for (auto identifier : *(declaration->pattern.identifiers_)) { | 306 for (auto identifier : *(declaration->pattern.identifiers_)) { |
304 declaration_descriptor->scope->RemoveUnresolved(identifier); | 307 declaration_descriptor->scope->RemoveUnresolved(identifier); |
305 } | 308 } |
306 } | 309 } |
| 310 for (auto identifier : *(declaration->pattern.identifiers_)) { |
| 311 scope->DeclareVariableName(identifier, declaration_descriptor->mode); |
| 312 } |
307 } | 313 } |
308 } | 314 } |
309 | 315 |
310 #undef CHECK_OK | 316 #undef CHECK_OK |
311 #undef CHECK_OK_CUSTOM | 317 #undef CHECK_OK_CUSTOM |
312 | 318 |
313 | 319 |
314 } // namespace internal | 320 } // namespace internal |
315 } // namespace v8 | 321 } // namespace v8 |
OLD | NEW |