Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Side by Side Diff: src/parsing/preparser.cc

Issue 2388183003: PreParsing inner functions: Fix declaration-only variables. (Closed)
Patch Set: flag off Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/parsing/preparser.h ('k') | test/mjsunit/fixed-context-shapes-when-recompiling.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
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);
232 } 232 }
233 233
234 void PreParser::DeclareAndInitializeVariables(
235 PreParserStatement block,
236 const DeclarationDescriptor* declaration_descriptor,
237 const DeclarationParsingResult::Declaration* declaration,
238 ZoneList<const AstRawString*>* names, bool* ok) {
239 if (declaration->pattern.string_) {
240 /* Mimic what Parser does when declaring variables (see
241 Parser::PatternRewriter::VisitVariableProxy).
242
243 var + no initializer -> RemoveUnresolved
244 let + no initializer -> RemoveUnresolved
245 var + initializer -> RemoveUnresolved followed by NewUnresolved
246 let + initializer -> RemoveUnresolved
247 */
248
249 if (declaration->initializer.IsEmpty() ||
250 declaration_descriptor->mode == VariableMode::LET) {
251 declaration_descriptor->scope->RemoveUnresolved(
252 declaration->pattern.string_);
253 }
254 }
255 }
256
234 #undef CHECK_OK 257 #undef CHECK_OK
235 #undef CHECK_OK_CUSTOM 258 #undef CHECK_OK_CUSTOM
236 259
237 260
238 } // namespace internal 261 } // namespace internal
239 } // namespace v8 262 } // namespace v8
OLDNEW
« no previous file with comments | « src/parsing/preparser.h ('k') | test/mjsunit/fixed-context-shapes-when-recompiling.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698