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()); |
} |