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

Side by Side Diff: src/parsing/pattern-rewriter.cc

Issue 1836183002: Remove vestigial legacy const handling from parser (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 8 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
« src/parsing/parser.cc ('K') | « src/parsing/parser.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 } else { 261 } else {
262 initialize = NULL; 262 initialize = NULL;
263 } 263 }
264 } 264 }
265 265
266 if (initialize != NULL) { 266 if (initialize != NULL) {
267 block_->statements()->Add( 267 block_->statements()->Add(
268 factory()->NewExpressionStatement(initialize, initialize->position()), 268 factory()->NewExpressionStatement(initialize, initialize->position()),
269 zone()); 269 zone());
270 } 270 }
271 } else if (value != nullptr && (descriptor_->mode == CONST_LEGACY || 271 } else if (value != nullptr && IsLexicalVariableMode(descriptor_->mode)) {
272 IsLexicalVariableMode(descriptor_->mode))) { 272 // For 'let' and 'const' declared variables the initialization always
273 // Constant initializations always assign to the declared constant which 273 // assigns to the declared variable.
274 // is always at the function scope level. This is only relevant for
275 // dynamically looked-up variables and constants (the
276 // start context for constant lookups is always the function context,
277 // while it is the top context for var declared variables). Sigh...
278 // For 'let' and 'const' declared variables in harmony mode the
279 // initialization also always assigns to the declared variable.
280 DCHECK_NOT_NULL(proxy); 274 DCHECK_NOT_NULL(proxy);
281 DCHECK_NOT_NULL(proxy->var()); 275 DCHECK_NOT_NULL(proxy->var());
282 DCHECK_NOT_NULL(value); 276 DCHECK_NOT_NULL(value);
283 // Add break location for destructured sub-pattern. 277 // Add break location for destructured sub-pattern.
284 int pos = IsSubPattern() ? pattern->position() : value->position(); 278 int pos = IsSubPattern() ? pattern->position() : value->position();
285 Assignment* assignment = 279 Assignment* assignment =
286 factory()->NewAssignment(Token::INIT, proxy, value, pos); 280 factory()->NewAssignment(Token::INIT, proxy, value, pos);
287 block_->statements()->Add( 281 block_->statements()->Add(
288 factory()->NewExpressionStatement(assignment, pos), zone()); 282 factory()->NewExpressionStatement(assignment, pos), zone());
289 value = NULL; 283 value = NULL;
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 NOT_A_PATTERN(TryFinallyStatement) 693 NOT_A_PATTERN(TryFinallyStatement)
700 NOT_A_PATTERN(UnaryOperation) 694 NOT_A_PATTERN(UnaryOperation)
701 NOT_A_PATTERN(VariableDeclaration) 695 NOT_A_PATTERN(VariableDeclaration)
702 NOT_A_PATTERN(WhileStatement) 696 NOT_A_PATTERN(WhileStatement)
703 NOT_A_PATTERN(WithStatement) 697 NOT_A_PATTERN(WithStatement)
704 NOT_A_PATTERN(Yield) 698 NOT_A_PATTERN(Yield)
705 699
706 #undef NOT_A_PATTERN 700 #undef NOT_A_PATTERN
707 } // namespace internal 701 } // namespace internal
708 } // namespace v8 702 } // namespace v8
OLDNEW
« src/parsing/parser.cc ('K') | « src/parsing/parser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698