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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ast/prettyprinter.cc
diff --git a/src/ast/prettyprinter.cc b/src/ast/prettyprinter.cc
index efd2d4c697a27c617d71f20536b742bf645506b1..49bff08e14c2b7de29e32cefebd18859e1bc3684 100644
--- a/src/ast/prettyprinter.cc
+++ b/src/ast/prettyprinter.cc
@@ -192,10 +192,11 @@ void CallPrinter::VisitForInStatement(ForInStatement* node) {
void CallPrinter::VisitForOfStatement(ForOfStatement* node) {
- Find(node->each());
Find(node->assign_iterator());
- Find(node->body());
Find(node->next_result());
+ Find(node->result_done());
+ Find(node->assign_each());
+ Find(node->body());
}
@@ -675,11 +676,37 @@ void PrettyPrinter::VisitForInStatement(ForInStatement* node) {
void PrettyPrinter::VisitForOfStatement(ForOfStatement* node) {
+ // TODO(adamk): ForOf is largely desugared as part of parsing,
+ // so it's hard to display useful stuff here. Should likely
+ // either bite the bullet and display less or try harder
+ // to preserve more.
PrintLabels(node->labels());
- Print("for (");
- Visit(node->each());
- Print(" of ");
- Visit(node->iterable());
+ // The <each> is embedded inside a do-expression by the time we get here.
+ Print("for (<each> of ");
+ if (node->assign_iterator()->IsAssignment() &&
+ node->assign_iterator()->AsAssignment()->value()->IsCall() &&
+ node->assign_iterator()
+ ->AsAssignment()
+ ->value()
+ ->AsCall()
+ ->expression()
+ ->IsProperty() &&
+ node->assign_iterator()
+ ->AsAssignment()
+ ->value()
+ ->AsCall()
+ ->expression()
+ ->IsProperty()) {
+ Visit(node->assign_iterator()
+ ->AsAssignment()
+ ->value()
+ ->AsCall()
+ ->expression()
+ ->AsProperty()
+ ->obj());
+ } else {
+ Print("<iterable>");
+ }
Print(") ");
Visit(node->body());
}
@@ -1408,13 +1435,11 @@ void AstPrinter::VisitForOfStatement(ForOfStatement* node) {
IndentedScope indent(this, "FOR OF", node->position());
PrintIndented("YIELD COUNT");
Print(" %d\n", node->yield_count());
- PrintIndentedVisit("FOR", node->each());
- PrintIndentedVisit("OF", node->iterable());
- PrintIndentedVisit("BODY", node->body());
PrintIndentedVisit("INIT", node->assign_iterator());
PrintIndentedVisit("NEXT", node->next_result());
- PrintIndentedVisit("EACH", node->assign_each());
PrintIndentedVisit("DONE", node->result_done());
+ PrintIndentedVisit("EACH", node->assign_each());
+ PrintIndentedVisit("BODY", node->body());
}
« 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