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 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 InferName infer) { | 221 InferName infer) { |
222 if (track_unresolved_variables_) { | 222 if (track_unresolved_variables_) { |
223 AstNodeFactory factory(ast_value_factory()); | 223 AstNodeFactory factory(ast_value_factory()); |
224 // Setting the Zone is necessary because zone_ might be the temp Zone, and | 224 // Setting the Zone is necessary because zone_ might be the temp Zone, and |
225 // AstValueFactory doesn't know about it. | 225 // AstValueFactory doesn't know about it. |
226 factory.set_zone(zone()); | 226 factory.set_zone(zone()); |
227 DCHECK_NOT_NULL(name.string_); | 227 DCHECK_NOT_NULL(name.string_); |
228 scope()->NewUnresolved(&factory, name.string_, start_position, end_position, | 228 scope()->NewUnresolved(&factory, name.string_, start_position, end_position, |
229 NORMAL_VARIABLE); | 229 NORMAL_VARIABLE); |
230 } | 230 } |
231 return PreParserExpression::FromIdentifier(name); | 231 return PreParserExpression::FromIdentifier(name, zone()); |
232 } | 232 } |
233 | 233 |
234 void PreParser::DeclareAndInitializeVariables( | 234 void PreParser::DeclareAndInitializeVariables( |
235 PreParserStatement block, | 235 PreParserStatement block, |
236 const DeclarationDescriptor* declaration_descriptor, | 236 const DeclarationDescriptor* declaration_descriptor, |
237 const DeclarationParsingResult::Declaration* declaration, | 237 const DeclarationParsingResult::Declaration* declaration, |
238 ZoneList<const AstRawString*>* names, bool* ok) { | 238 ZoneList<const AstRawString*>* names, bool* ok) { |
239 if (declaration->pattern.string_) { | 239 if (declaration->pattern.identifiers_ != nullptr) { |
| 240 DCHECK(FLAG_lazy_inner_functions); |
240 /* Mimic what Parser does when declaring variables (see | 241 /* Mimic what Parser does when declaring variables (see |
241 Parser::PatternRewriter::VisitVariableProxy). | 242 Parser::PatternRewriter::VisitVariableProxy). |
242 | 243 |
243 var + no initializer -> RemoveUnresolved | 244 var + no initializer -> RemoveUnresolved |
244 let + no initializer -> RemoveUnresolved | 245 let / const + no initializer -> RemoveUnresolved |
245 var + initializer -> RemoveUnresolved followed by NewUnresolved | 246 var + initializer -> RemoveUnresolved followed by NewUnresolved |
246 let + initializer -> RemoveUnresolved | 247 let / const + initializer -> RemoveUnresolved |
247 */ | 248 */ |
248 | 249 |
249 if (declaration->initializer.IsEmpty() || | 250 if (declaration->initializer.IsEmpty() || |
250 declaration_descriptor->mode == VariableMode::LET) { | 251 (declaration_descriptor->mode == VariableMode::LET || |
251 declaration_descriptor->scope->RemoveUnresolved( | 252 declaration_descriptor->mode == VariableMode::CONST)) { |
252 declaration->pattern.string_); | 253 for (auto identifier : *(declaration->pattern.identifiers_)) { |
| 254 declaration_descriptor->scope->RemoveUnresolved(identifier); |
| 255 } |
253 } | 256 } |
254 } | 257 } |
255 } | 258 } |
256 | 259 |
257 #undef CHECK_OK | 260 #undef CHECK_OK |
258 #undef CHECK_OK_CUSTOM | 261 #undef CHECK_OK_CUSTOM |
259 | 262 |
260 | 263 |
261 } // namespace internal | 264 } // namespace internal |
262 } // namespace v8 | 265 } // namespace v8 |
OLD | NEW |