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

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

Issue 1189743003: [destructuring] Implement parameter pattern matching. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix magic number issue Created 5 years, 6 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/parser.cc ('k') | src/preparser.h » ('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 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.h" 5 #include "src/ast.h"
6 #include "src/messages.h" 6 #include "src/messages.h"
7 #include "src/parser.h" 7 #include "src/parser.h"
8 8
9 namespace v8 { 9 namespace v8 {
10 10
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 // surrounding 'with' statements). 46 // surrounding 'with' statements).
47 // For let/const declarations in harmony mode, we can also immediately 47 // For let/const declarations in harmony mode, we can also immediately
48 // pre-resolve the proxy because it resides in the same scope as the 48 // pre-resolve the proxy because it resides in the same scope as the
49 // declaration. 49 // declaration.
50 Parser* parser = descriptor_->parser; 50 Parser* parser = descriptor_->parser;
51 const AstRawString* name = pattern->raw_name(); 51 const AstRawString* name = pattern->raw_name();
52 VariableProxy* proxy = parser->NewUnresolved(name, descriptor_->mode); 52 VariableProxy* proxy = parser->NewUnresolved(name, descriptor_->mode);
53 Declaration* declaration = factory()->NewVariableDeclaration( 53 Declaration* declaration = factory()->NewVariableDeclaration(
54 proxy, descriptor_->mode, descriptor_->scope, 54 proxy, descriptor_->mode, descriptor_->scope,
55 descriptor_->declaration_pos); 55 descriptor_->declaration_pos);
56 Variable* var = parser->Declare(declaration, descriptor_->mode != VAR, ok_); 56 Variable* var = parser->Declare(declaration, descriptor_->declaration_kind,
57 descriptor_->mode != VAR, ok_);
57 if (!*ok_) return; 58 if (!*ok_) return;
58 DCHECK_NOT_NULL(var); 59 DCHECK_NOT_NULL(var);
59 DCHECK(!proxy->is_resolved() || proxy->var() == var); 60 DCHECK(!proxy->is_resolved() || proxy->var() == var);
60 var->set_initializer_position(initializer_position_); 61 var->set_initializer_position(initializer_position_);
61 62
62 DCHECK(initializer_position_ != RelocInfo::kNoPosition); 63 DCHECK(initializer_position_ != RelocInfo::kNoPosition);
63 64
64 if (descriptor_->declaration_scope->num_var_or_const() > 65 if (descriptor_->declaration_scope->num_var_or_const() >
65 kMaxNumFunctionLocals) { 66 kMaxNumFunctionLocals) {
66 parser->ReportMessage(MessageTemplate::kTooManyVariables); 67 parser->ReportMessage(MessageTemplate::kTooManyVariables);
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 NOT_A_PATTERN(TryFinallyStatement) 414 NOT_A_PATTERN(TryFinallyStatement)
414 NOT_A_PATTERN(UnaryOperation) 415 NOT_A_PATTERN(UnaryOperation)
415 NOT_A_PATTERN(VariableDeclaration) 416 NOT_A_PATTERN(VariableDeclaration)
416 NOT_A_PATTERN(WhileStatement) 417 NOT_A_PATTERN(WhileStatement)
417 NOT_A_PATTERN(WithStatement) 418 NOT_A_PATTERN(WithStatement)
418 NOT_A_PATTERN(Yield) 419 NOT_A_PATTERN(Yield)
419 420
420 #undef NOT_A_PATTERN 421 #undef NOT_A_PATTERN
421 } // namespace internal 422 } // namespace internal
422 } // namespace v8 423 } // namespace v8
OLDNEW
« no previous file with comments | « src/parser.cc ('k') | src/preparser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698