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/parsing/pattern-rewriter.cc

Issue 1704533002: Support rest element pattern with user-defined iterable (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 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/js/runtime.js ('k') | test/mjsunit/harmony/destructuring.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 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 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 block_->statements()->Add(if_statement, zone()); 475 block_->statements()->Add(if_statement, zone());
476 476
477 if (!(value->IsLiteral() && value->AsLiteral()->raw_value()->IsTheHole())) { 477 if (!(value->IsLiteral() && value->AsLiteral()->raw_value()->IsTheHole())) {
478 RecurseIntoSubpattern(value, factory()->NewVariableProxy(v)); 478 RecurseIntoSubpattern(value, factory()->NewVariableProxy(v));
479 } 479 }
480 set_context(context); 480 set_context(context);
481 } 481 }
482 482
483 if (spread != nullptr) { 483 if (spread != nullptr) {
484 // array = []; 484 // array = [];
485 // if (!done) %concat_iterable_to_array(array, iterator); 485 // if (!done) %concat_iterator_to_array(array, iterator);
486 auto empty_exprs = new (zone()) ZoneList<Expression*>(0, zone()); 486 auto empty_exprs = new (zone()) ZoneList<Expression*>(0, zone());
487 auto array = CreateTempVar(factory()->NewArrayLiteral( 487 auto array = CreateTempVar(factory()->NewArrayLiteral(
488 empty_exprs, 488 empty_exprs,
489 // Reuse pattern's literal index - it is unused since there is no 489 // Reuse pattern's literal index - it is unused since there is no
490 // actual literal allocated. 490 // actual literal allocated.
491 node->literal_index(), is_strong(scope()->language_mode()), 491 node->literal_index(), is_strong(scope()->language_mode()),
492 RelocInfo::kNoPosition)); 492 RelocInfo::kNoPosition));
493 493
494 auto arguments = new (zone()) ZoneList<Expression*>(2, zone()); 494 auto arguments = new (zone()) ZoneList<Expression*>(2, zone());
495 arguments->Add(factory()->NewVariableProxy(array), zone()); 495 arguments->Add(factory()->NewVariableProxy(array), zone());
496 arguments->Add(factory()->NewVariableProxy(iterator), zone()); 496 arguments->Add(factory()->NewVariableProxy(iterator), zone());
497 auto spread_into_array_call = 497 auto spread_into_array_call =
498 factory()->NewCallRuntime(Context::CONCAT_ITERABLE_TO_ARRAY_INDEX, 498 factory()->NewCallRuntime(Context::CONCAT_ITERATOR_TO_ARRAY_INDEX,
499 arguments, RelocInfo::kNoPosition); 499 arguments, RelocInfo::kNoPosition);
500 500
501 auto if_statement = factory()->NewIfStatement( 501 auto if_statement = factory()->NewIfStatement(
502 factory()->NewUnaryOperation(Token::NOT, 502 factory()->NewUnaryOperation(Token::NOT,
503 factory()->NewVariableProxy(done), 503 factory()->NewVariableProxy(done),
504 RelocInfo::kNoPosition), 504 RelocInfo::kNoPosition),
505 factory()->NewExpressionStatement(spread_into_array_call, 505 factory()->NewExpressionStatement(spread_into_array_call,
506 RelocInfo::kNoPosition), 506 RelocInfo::kNoPosition),
507 factory()->NewEmptyStatement(RelocInfo::kNoPosition), 507 factory()->NewEmptyStatement(RelocInfo::kNoPosition),
508 RelocInfo::kNoPosition); 508 RelocInfo::kNoPosition);
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 NOT_A_PATTERN(TryFinallyStatement) 619 NOT_A_PATTERN(TryFinallyStatement)
620 NOT_A_PATTERN(UnaryOperation) 620 NOT_A_PATTERN(UnaryOperation)
621 NOT_A_PATTERN(VariableDeclaration) 621 NOT_A_PATTERN(VariableDeclaration)
622 NOT_A_PATTERN(WhileStatement) 622 NOT_A_PATTERN(WhileStatement)
623 NOT_A_PATTERN(WithStatement) 623 NOT_A_PATTERN(WithStatement)
624 NOT_A_PATTERN(Yield) 624 NOT_A_PATTERN(Yield)
625 625
626 #undef NOT_A_PATTERN 626 #undef NOT_A_PATTERN
627 } // namespace internal 627 } // namespace internal
628 } // namespace v8 628 } // namespace v8
OLDNEW
« no previous file with comments | « src/js/runtime.js ('k') | test/mjsunit/harmony/destructuring.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698