Index: src/prettyprinter.cc |
diff --git a/src/prettyprinter.cc b/src/prettyprinter.cc |
index 8d5a8e860202badd8962afa9826166ca1a76d888..3a1eca7c6b1759b55312fddd5b92b9f609050409 100644 |
--- a/src/prettyprinter.cc |
+++ b/src/prettyprinter.cc |
@@ -628,10 +628,6 @@ void PrettyPrinter::PrintCaseClause(CaseClause* clause) { |
class IndentedScope BASE_EMBEDDED { |
public: |
- explicit IndentedScope(AstPrinter* printer) : ast_printer_(printer) { |
- ast_printer_->inc_indent(); |
- } |
- |
IndentedScope(AstPrinter* printer, const char* txt) |
: ast_printer_(printer) { |
ast_printer_->PrintIndented(txt); |
@@ -693,16 +689,11 @@ void AstPrinter::PrintLiteralWithModeIndented(const char* info, |
} |
-void AstPrinter::PrintLabelsIndented(const char* info, ZoneStringList* labels) { |
- if (labels != NULL && labels->length() > 0) { |
- PrintIndented(info == NULL ? "LABELS" : info); |
- Print(" "); |
- PrintLabels(labels); |
- Print("\n"); |
- } else if (info != NULL) { |
- PrintIndented(info); |
- Print("\n"); |
- } |
+void AstPrinter::PrintLabelsIndented(ZoneStringList* labels) { |
+ if (labels == NULL || labels->length() == 0) return; |
+ PrintIndented("LABELS "); |
+ PrintLabels(labels); |
+ Print("\n"); |
} |
@@ -779,6 +770,7 @@ void AstPrinter::VisitBlock(Block* node) { |
} |
+// TODO(svenpanne) Start with IndentedScope. |
mvstanton
2013/05/08 13:11:03
Actually can you fold the fix in here instead of t
Sven Panne
2013/05/08 13:23:56
Actually no, or at least not easily: As usual, we
|
void AstPrinter::VisitVariableDeclaration(VariableDeclaration* node) { |
PrintLiteralWithModeIndented(Variable::Mode2String(node->mode()), |
node->proxy()->var(), |
@@ -786,6 +778,7 @@ void AstPrinter::VisitVariableDeclaration(VariableDeclaration* node) { |
} |
+// TODO(svenpanne) Start with IndentedScope. |
mvstanton
2013/05/08 13:11:03
And here.
|
void AstPrinter::VisitFunctionDeclaration(FunctionDeclaration* node) { |
PrintIndented("FUNCTION "); |
PrintLiteral(node->proxy()->name(), true); |
@@ -816,19 +809,21 @@ void AstPrinter::VisitExportDeclaration(ExportDeclaration* node) { |
void AstPrinter::VisitModuleLiteral(ModuleLiteral* node) { |
+ IndentedScope indent(this, "MODULE LITERAL"); |
VisitBlock(node->body()); |
} |
void AstPrinter::VisitModuleVariable(ModuleVariable* node) { |
+ IndentedScope indent(this, "MODULE VARIABLE"); |
Visit(node->proxy()); |
} |
void AstPrinter::VisitModulePath(ModulePath* node) { |
- IndentedScope indent(this, "PATH"); |
- PrintIndentedVisit("MODULE", node->module()); |
- PrintLiteralIndented("NAME", node->name(), false); |
+ IndentedScope indent(this, "MODULE PATH"); |
+ PrintIndentedVisit("MODULE PATH PARENT", node->module()); |
+ PrintLiteralIndented("NAME", node->name(), true); |
} |
@@ -838,24 +833,26 @@ void AstPrinter::VisitModuleUrl(ModuleUrl* node) { |
void AstPrinter::VisitModuleStatement(ModuleStatement* node) { |
- IndentedScope indent(this, "MODULE"); |
+ IndentedScope indent(this, "MODULE STATEMENT"); |
PrintLiteralIndented("NAME", node->proxy()->name(), true); |
PrintStatements(node->body()->statements()); |
} |
void AstPrinter::VisitExpressionStatement(ExpressionStatement* node) { |
+ IndentedScope indent(this, "EXPRESSION STATEMENT"); |
Visit(node->expression()); |
} |
void AstPrinter::VisitEmptyStatement(EmptyStatement* node) { |
- PrintIndented("EMPTY\n"); |
+ IndentedScope indent(this, "EMPTY"); |
} |
void AstPrinter::VisitIfStatement(IfStatement* node) { |
- PrintIndentedVisit("IF", node->condition()); |
+ IndentedScope indent(this, "IF"); |
+ PrintIndentedVisit("CONDITION", node->condition()); |
PrintIndentedVisit("THEN", node->then_statement()); |
if (node->HasElseStatement()) { |
PrintIndentedVisit("ELSE", node->else_statement()); |
@@ -864,17 +861,20 @@ void AstPrinter::VisitIfStatement(IfStatement* node) { |
void AstPrinter::VisitContinueStatement(ContinueStatement* node) { |
- PrintLabelsIndented("CONTINUE", node->target()->labels()); |
+ IndentedScope indent(this, "CONTINUE"); |
+ PrintLabelsIndented(node->target()->labels()); |
} |
void AstPrinter::VisitBreakStatement(BreakStatement* node) { |
- PrintLabelsIndented("BREAK", node->target()->labels()); |
+ IndentedScope indent(this, "BREAK"); |
+ PrintLabelsIndented(node->target()->labels()); |
} |
void AstPrinter::VisitReturnStatement(ReturnStatement* node) { |
- PrintIndentedVisit("RETURN", node->expression()); |
+ IndentedScope indent(this, "RETURN"); |
+ Visit(node->expression()); |
} |
@@ -887,7 +887,7 @@ void AstPrinter::VisitWithStatement(WithStatement* node) { |
void AstPrinter::VisitSwitchStatement(SwitchStatement* node) { |
IndentedScope indent(this, "SWITCH"); |
- PrintLabelsIndented(NULL, node->labels()); |
+ PrintLabelsIndented(node->labels()); |
PrintIndentedVisit("TAG", node->tag()); |
for (int i = 0; i < node->cases()->length(); i++) { |
PrintCaseClause(node->cases()->at(i)); |
@@ -897,7 +897,7 @@ void AstPrinter::VisitSwitchStatement(SwitchStatement* node) { |
void AstPrinter::VisitDoWhileStatement(DoWhileStatement* node) { |
IndentedScope indent(this, "DO"); |
- PrintLabelsIndented(NULL, node->labels()); |
+ PrintLabelsIndented(node->labels()); |
PrintIndentedVisit("BODY", node->body()); |
PrintIndentedVisit("COND", node->cond()); |
} |
@@ -905,7 +905,7 @@ void AstPrinter::VisitDoWhileStatement(DoWhileStatement* node) { |
void AstPrinter::VisitWhileStatement(WhileStatement* node) { |
IndentedScope indent(this, "WHILE"); |
- PrintLabelsIndented(NULL, node->labels()); |
+ PrintLabelsIndented(node->labels()); |
PrintIndentedVisit("COND", node->cond()); |
PrintIndentedVisit("BODY", node->body()); |
} |
@@ -913,7 +913,7 @@ void AstPrinter::VisitWhileStatement(WhileStatement* node) { |
void AstPrinter::VisitForStatement(ForStatement* node) { |
IndentedScope indent(this, "FOR"); |
- PrintLabelsIndented(NULL, node->labels()); |
+ PrintLabelsIndented(node->labels()); |
if (node->init()) PrintIndentedVisit("INIT", node->init()); |
if (node->cond()) PrintIndentedVisit("COND", node->cond()); |
PrintIndentedVisit("BODY", node->body()); |
@@ -972,12 +972,13 @@ void AstPrinter::VisitSharedFunctionInfoLiteral( |
void AstPrinter::VisitConditional(Conditional* node) { |
IndentedScope indent(this, "CONDITIONAL"); |
- PrintIndentedVisit("?", node->condition()); |
+ PrintIndentedVisit("CONDITION", node->condition()); |
PrintIndentedVisit("THEN", node->then_expression()); |
PrintIndentedVisit("ELSE", node->else_expression()); |
} |
+// TODO(svenpanne) Start with IndentedScope. |
void AstPrinter::VisitLiteral(Literal* node) { |
PrintLiteralIndented("LITERAL", node->handle(), true); |
} |
@@ -1034,6 +1035,7 @@ void AstPrinter::VisitArrayLiteral(ArrayLiteral* node) { |
} |
+// TODO(svenpanne) Start with IndentedScope. |
void AstPrinter::VisitVariableProxy(VariableProxy* node) { |
Variable* var = node->var(); |
EmbeddedVector<char, 128> buf; |
@@ -1066,12 +1068,14 @@ void AstPrinter::VisitAssignment(Assignment* node) { |
void AstPrinter::VisitYield(Yield* node) { |
- PrintIndentedVisit("YIELD", node->expression()); |
+ IndentedScope indent(this, "YIELD"); |
+ Visit(node->expression()); |
} |
void AstPrinter::VisitThrow(Throw* node) { |
- PrintIndentedVisit("THROW", node->exception()); |
+ IndentedScope indent(this, "THROW"); |
+ Visit(node->exception()); |
} |
@@ -1102,14 +1106,15 @@ void AstPrinter::VisitCallNew(CallNew* node) { |
void AstPrinter::VisitCallRuntime(CallRuntime* node) { |
- PrintLiteralIndented("CALL RUNTIME ", node->name(), false); |
- IndentedScope indent(this); |
+ IndentedScope indent(this, "CALL RUNTIME"); |
+ PrintLiteralIndented("NAME", node->name(), false); |
PrintArguments(node->arguments()); |
} |
void AstPrinter::VisitUnaryOperation(UnaryOperation* node) { |
- PrintIndentedVisit(Token::Name(node->op()), node->expression()); |
+ IndentedScope indent(this, Token::Name(node->op())); |
+ Visit(node->expression()); |
} |
@@ -1117,7 +1122,8 @@ void AstPrinter::VisitCountOperation(CountOperation* node) { |
EmbeddedVector<char, 128> buf; |
OS::SNPrintF(buf, "%s %s", (node->is_prefix() ? "PRE" : "POST"), |
Token::Name(node->op())); |
- PrintIndentedVisit(buf.start(), node->expression()); |
+ IndentedScope indent(this, buf.start()); |
+ Visit(node->expression()); |
} |