| OLD | NEW |
| 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 <stdarg.h> | 5 #include <stdarg.h> |
| 6 | 6 |
| 7 #include "src/v8.h" | 7 #include "src/v8.h" |
| 8 | 8 |
| 9 #include "src/ast-value-factory.h" | 9 #include "src/ast-value-factory.h" |
| 10 #include "src/base/platform/platform.h" | 10 #include "src/base/platform/platform.h" |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 Visit(node->else_statement()); | 130 Visit(node->else_statement()); |
| 131 } | 131 } |
| 132 } | 132 } |
| 133 | 133 |
| 134 | 134 |
| 135 void PrettyPrinter::VisitContinueStatement(ContinueStatement* node) { | 135 void PrettyPrinter::VisitContinueStatement(ContinueStatement* node) { |
| 136 Print("continue"); | 136 Print("continue"); |
| 137 ZoneList<const AstRawString*>* labels = node->target()->labels(); | 137 ZoneList<const AstRawString*>* labels = node->target()->labels(); |
| 138 if (labels != NULL) { | 138 if (labels != NULL) { |
| 139 Print(" "); | 139 Print(" "); |
| 140 ASSERT(labels->length() > 0); // guaranteed to have at least one entry | 140 DCHECK(labels->length() > 0); // guaranteed to have at least one entry |
| 141 PrintLiteral(labels->at(0), false); // any label from the list is fine | 141 PrintLiteral(labels->at(0), false); // any label from the list is fine |
| 142 } | 142 } |
| 143 Print(";"); | 143 Print(";"); |
| 144 } | 144 } |
| 145 | 145 |
| 146 | 146 |
| 147 void PrettyPrinter::VisitBreakStatement(BreakStatement* node) { | 147 void PrettyPrinter::VisitBreakStatement(BreakStatement* node) { |
| 148 Print("break"); | 148 Print("break"); |
| 149 ZoneList<const AstRawString*>* labels = node->target()->labels(); | 149 ZoneList<const AstRawString*>* labels = node->target()->labels(); |
| 150 if (labels != NULL) { | 150 if (labels != NULL) { |
| 151 Print(" "); | 151 Print(" "); |
| 152 ASSERT(labels->length() > 0); // guaranteed to have at least one entry | 152 DCHECK(labels->length() > 0); // guaranteed to have at least one entry |
| 153 PrintLiteral(labels->at(0), false); // any label from the list is fine | 153 PrintLiteral(labels->at(0), false); // any label from the list is fine |
| 154 } | 154 } |
| 155 Print(";"); | 155 Print(";"); |
| 156 } | 156 } |
| 157 | 157 |
| 158 | 158 |
| 159 void PrettyPrinter::VisitReturnStatement(ReturnStatement* node) { | 159 void PrettyPrinter::VisitReturnStatement(ReturnStatement* node) { |
| 160 Print("return "); | 160 Print("return "); |
| 161 Visit(node->expression()); | 161 Visit(node->expression()); |
| 162 Print(";"); | 162 Print(";"); |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 | 472 |
| 473 | 473 |
| 474 void PrettyPrinter::PrintOut(Zone* zone, AstNode* node) { | 474 void PrettyPrinter::PrintOut(Zone* zone, AstNode* node) { |
| 475 PrettyPrinter printer(zone); | 475 PrettyPrinter printer(zone); |
| 476 PrintF("%s", printer.Print(node)); | 476 PrintF("%s", printer.Print(node)); |
| 477 } | 477 } |
| 478 | 478 |
| 479 | 479 |
| 480 void PrettyPrinter::Init() { | 480 void PrettyPrinter::Init() { |
| 481 if (size_ == 0) { | 481 if (size_ == 0) { |
| 482 ASSERT(output_ == NULL); | 482 DCHECK(output_ == NULL); |
| 483 const int initial_size = 256; | 483 const int initial_size = 256; |
| 484 output_ = NewArray<char>(initial_size); | 484 output_ = NewArray<char>(initial_size); |
| 485 size_ = initial_size; | 485 size_ = initial_size; |
| 486 } | 486 } |
| 487 output_[0] = '\0'; | 487 output_[0] = '\0'; |
| 488 pos_ = 0; | 488 pos_ = 0; |
| 489 } | 489 } |
| 490 | 490 |
| 491 | 491 |
| 492 void PrettyPrinter::Print(const char* format, ...) { | 492 void PrettyPrinter::Print(const char* format, ...) { |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 638 | 638 |
| 639 | 639 |
| 640 //----------------------------------------------------------------------------- | 640 //----------------------------------------------------------------------------- |
| 641 | 641 |
| 642 | 642 |
| 643 AstPrinter::AstPrinter(Zone* zone) : PrettyPrinter(zone), indent_(0) { | 643 AstPrinter::AstPrinter(Zone* zone) : PrettyPrinter(zone), indent_(0) { |
| 644 } | 644 } |
| 645 | 645 |
| 646 | 646 |
| 647 AstPrinter::~AstPrinter() { | 647 AstPrinter::~AstPrinter() { |
| 648 ASSERT(indent_ == 0); | 648 DCHECK(indent_ == 0); |
| 649 } | 649 } |
| 650 | 650 |
| 651 | 651 |
| 652 void AstPrinter::PrintIndented(const char* txt) { | 652 void AstPrinter::PrintIndented(const char* txt) { |
| 653 for (int i = 0; i < indent_; i++) { | 653 for (int i = 0; i < indent_; i++) { |
| 654 Print(". "); | 654 Print(". "); |
| 655 } | 655 } |
| 656 Print(txt); | 656 Print(txt); |
| 657 } | 657 } |
| 658 | 658 |
| (...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1141 } | 1141 } |
| 1142 | 1142 |
| 1143 | 1143 |
| 1144 void AstPrinter::VisitThisFunction(ThisFunction* node) { | 1144 void AstPrinter::VisitThisFunction(ThisFunction* node) { |
| 1145 IndentedScope indent(this, "THIS-FUNCTION"); | 1145 IndentedScope indent(this, "THIS-FUNCTION"); |
| 1146 } | 1146 } |
| 1147 | 1147 |
| 1148 #endif // DEBUG | 1148 #endif // DEBUG |
| 1149 | 1149 |
| 1150 } } // namespace v8::internal | 1150 } } // namespace v8::internal |
| OLD | NEW |