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

Side by Side Diff: src/ast/prettyprinter.cc

Issue 1968753004: [cleanup] Split ForOf and ForIn AST nodes apart as they share little (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 7 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/ast/ast-expression-visitor.cc ('k') | src/compiler/ast-loop-assignment-analyzer.cc » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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/prettyprinter.h" 5 #include "src/ast/prettyprinter.h"
6 6
7 #include <stdarg.h> 7 #include <stdarg.h>
8 8
9 #include "src/ast/ast-value-factory.h" 9 #include "src/ast/ast-value-factory.h"
10 #include "src/ast/scopes.h" 10 #include "src/ast/scopes.h"
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 185
186 186
187 void CallPrinter::VisitForInStatement(ForInStatement* node) { 187 void CallPrinter::VisitForInStatement(ForInStatement* node) {
188 Find(node->each()); 188 Find(node->each());
189 Find(node->enumerable()); 189 Find(node->enumerable());
190 Find(node->body()); 190 Find(node->body());
191 } 191 }
192 192
193 193
194 void CallPrinter::VisitForOfStatement(ForOfStatement* node) { 194 void CallPrinter::VisitForOfStatement(ForOfStatement* node) {
195 Find(node->each());
196 Find(node->assign_iterator()); 195 Find(node->assign_iterator());
196 Find(node->next_result());
197 Find(node->result_done());
198 Find(node->assign_each());
197 Find(node->body()); 199 Find(node->body());
198 Find(node->next_result());
199 } 200 }
200 201
201 202
202 void CallPrinter::VisitTryCatchStatement(TryCatchStatement* node) { 203 void CallPrinter::VisitTryCatchStatement(TryCatchStatement* node) {
203 Find(node->try_block()); 204 Find(node->try_block());
204 Find(node->catch_block()); 205 Find(node->catch_block());
205 } 206 }
206 207
207 208
208 void CallPrinter::VisitTryFinallyStatement(TryFinallyStatement* node) { 209 void CallPrinter::VisitTryFinallyStatement(TryFinallyStatement* node) {
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 Print("for ("); 669 Print("for (");
669 Visit(node->each()); 670 Visit(node->each());
670 Print(" in "); 671 Print(" in ");
671 Visit(node->enumerable()); 672 Visit(node->enumerable());
672 Print(") "); 673 Print(") ");
673 Visit(node->body()); 674 Visit(node->body());
674 } 675 }
675 676
676 677
677 void PrettyPrinter::VisitForOfStatement(ForOfStatement* node) { 678 void PrettyPrinter::VisitForOfStatement(ForOfStatement* node) {
679 // TODO(adamk): ForOf is largely desugared as part of parsing,
680 // so it's hard to display useful stuff here. Should likely
681 // either bite the bullet and display less or try harder
682 // to preserve more.
678 PrintLabels(node->labels()); 683 PrintLabels(node->labels());
679 Print("for ("); 684 // The <each> is embedded inside a do-expression by the time we get here.
680 Visit(node->each()); 685 Print("for (<each> of ");
681 Print(" of "); 686 if (node->assign_iterator()->IsAssignment() &&
682 Visit(node->iterable()); 687 node->assign_iterator()->AsAssignment()->value()->IsCall() &&
688 node->assign_iterator()
689 ->AsAssignment()
690 ->value()
691 ->AsCall()
692 ->expression()
693 ->IsProperty() &&
694 node->assign_iterator()
695 ->AsAssignment()
696 ->value()
697 ->AsCall()
698 ->expression()
699 ->IsProperty()) {
700 Visit(node->assign_iterator()
701 ->AsAssignment()
702 ->value()
703 ->AsCall()
704 ->expression()
705 ->AsProperty()
706 ->obj());
707 } else {
708 Print("<iterable>");
709 }
683 Print(") "); 710 Print(") ");
684 Visit(node->body()); 711 Visit(node->body());
685 } 712 }
686 713
687 714
688 void PrettyPrinter::VisitTryCatchStatement(TryCatchStatement* node) { 715 void PrettyPrinter::VisitTryCatchStatement(TryCatchStatement* node) {
689 Print("try "); 716 Print("try ");
690 Visit(node->try_block()); 717 Visit(node->try_block());
691 Print(" catch ("); 718 Print(" catch (");
692 const bool quote = false; 719 const bool quote = false;
(...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after
1401 PrintIndentedVisit("FOR", node->each()); 1428 PrintIndentedVisit("FOR", node->each());
1402 PrintIndentedVisit("IN", node->enumerable()); 1429 PrintIndentedVisit("IN", node->enumerable());
1403 PrintIndentedVisit("BODY", node->body()); 1430 PrintIndentedVisit("BODY", node->body());
1404 } 1431 }
1405 1432
1406 1433
1407 void AstPrinter::VisitForOfStatement(ForOfStatement* node) { 1434 void AstPrinter::VisitForOfStatement(ForOfStatement* node) {
1408 IndentedScope indent(this, "FOR OF", node->position()); 1435 IndentedScope indent(this, "FOR OF", node->position());
1409 PrintIndented("YIELD COUNT"); 1436 PrintIndented("YIELD COUNT");
1410 Print(" %d\n", node->yield_count()); 1437 Print(" %d\n", node->yield_count());
1411 PrintIndentedVisit("FOR", node->each());
1412 PrintIndentedVisit("OF", node->iterable());
1413 PrintIndentedVisit("BODY", node->body());
1414 PrintIndentedVisit("INIT", node->assign_iterator()); 1438 PrintIndentedVisit("INIT", node->assign_iterator());
1415 PrintIndentedVisit("NEXT", node->next_result()); 1439 PrintIndentedVisit("NEXT", node->next_result());
1440 PrintIndentedVisit("DONE", node->result_done());
1416 PrintIndentedVisit("EACH", node->assign_each()); 1441 PrintIndentedVisit("EACH", node->assign_each());
1417 PrintIndentedVisit("DONE", node->result_done()); 1442 PrintIndentedVisit("BODY", node->body());
1418 } 1443 }
1419 1444
1420 1445
1421 void AstPrinter::VisitTryCatchStatement(TryCatchStatement* node) { 1446 void AstPrinter::VisitTryCatchStatement(TryCatchStatement* node) {
1422 IndentedScope indent(this, "TRY CATCH", node->position()); 1447 IndentedScope indent(this, "TRY CATCH", node->position());
1423 PrintIndentedVisit("TRY", node->try_block()); 1448 PrintIndentedVisit("TRY", node->try_block());
1424 PrintLiteralWithModeIndented("CATCHVAR", 1449 PrintLiteralWithModeIndented("CATCHVAR",
1425 node->variable(), 1450 node->variable(),
1426 node->variable()->name()); 1451 node->variable()->name());
1427 PrintIndentedVisit("CATCH", node->catch_block()); 1452 PrintIndentedVisit("CATCH", node->catch_block());
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
1721 1746
1722 void AstPrinter::VisitRewritableExpression(RewritableExpression* node) { 1747 void AstPrinter::VisitRewritableExpression(RewritableExpression* node) {
1723 Visit(node->expression()); 1748 Visit(node->expression());
1724 } 1749 }
1725 1750
1726 1751
1727 #endif // DEBUG 1752 #endif // DEBUG
1728 1753
1729 } // namespace internal 1754 } // namespace internal
1730 } // namespace v8 1755 } // namespace v8
OLDNEW
« no previous file with comments | « src/ast/ast-expression-visitor.cc ('k') | src/compiler/ast-loop-assignment-analyzer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698