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 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 void PreParser::DeclareAndInitializeVariables( | 303 void PreParser::DeclareAndInitializeVariables( |
304 PreParserStatement block, | 304 PreParserStatement block, |
305 const DeclarationDescriptor* declaration_descriptor, | 305 const DeclarationDescriptor* declaration_descriptor, |
306 const DeclarationParsingResult::Declaration* declaration, | 306 const DeclarationParsingResult::Declaration* declaration, |
307 ZoneList<const AstRawString*>* names, bool* ok) { | 307 ZoneList<const AstRawString*>* names, bool* ok) { |
308 if (declaration->pattern.variables_ != nullptr) { | 308 if (declaration->pattern.variables_ != nullptr) { |
309 DCHECK(FLAG_lazy_inner_functions); | 309 DCHECK(FLAG_lazy_inner_functions); |
310 DCHECK(track_unresolved_variables_); | 310 DCHECK(track_unresolved_variables_); |
311 for (auto variable : *(declaration->pattern.variables_)) { | 311 for (auto variable : *(declaration->pattern.variables_)) { |
312 declaration_descriptor->scope->RemoveUnresolved(variable); | 312 declaration_descriptor->scope->RemoveUnresolved(variable); |
313 scope()->DeclareVariableName(variable->raw_name(), | 313 Variable* var = scope()->DeclareVariableName( |
314 declaration_descriptor->mode); | 314 variable->raw_name(), declaration_descriptor->mode); |
| 315 if (FLAG_preparser_scope_analysis) { |
| 316 MarkLoopVariableAsAssigned(declaration_descriptor->scope, var); |
| 317 // This is only necessary if there is an initializer, but we don't have |
| 318 // that information here. Consequently, the preparser sometimes says |
| 319 // maybe-assigned where the parser (correctly) says never-assigned. |
| 320 } |
315 if (names) { | 321 if (names) { |
316 names->Add(variable->raw_name(), zone()); | 322 names->Add(variable->raw_name(), zone()); |
317 } | 323 } |
318 } | 324 } |
319 } | 325 } |
320 } | 326 } |
321 | 327 |
322 #undef CHECK_OK | 328 #undef CHECK_OK |
323 #undef CHECK_OK_CUSTOM | 329 #undef CHECK_OK_CUSTOM |
324 | 330 |
325 | 331 |
326 } // namespace internal | 332 } // namespace internal |
327 } // namespace v8 | 333 } // namespace v8 |
OLD | NEW |