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

Side by Side Diff: src/prettyprinter.cc

Issue 231073002: WIP: Parser: delay string internalization. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: more cleanup Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « src/prettyprinter.h ('k') | src/rewriter.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 <stdarg.h> 5 #include <stdarg.h>
6 6
7 #include "v8.h" 7 #include "v8.h"
8 8
9 #include "prettyprinter.h" 9 #include "prettyprinter.h"
10 #include "ast-string-table.h"
10 #include "scopes.h" 11 #include "scopes.h"
11 #include "platform.h" 12 #include "platform.h"
12 13
13 namespace v8 { 14 namespace v8 {
14 namespace internal { 15 namespace internal {
15 16
16 #ifdef DEBUG 17 #ifdef DEBUG
17 18
18 PrettyPrinter::PrettyPrinter(Zone* zone) { 19 PrettyPrinter::PrettyPrinter(Zone* zone) {
19 output_ = NULL; 20 output_ = NULL;
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 Visit(node->then_statement()); 127 Visit(node->then_statement());
127 if (node->HasElseStatement()) { 128 if (node->HasElseStatement()) {
128 Print(" else "); 129 Print(" else ");
129 Visit(node->else_statement()); 130 Visit(node->else_statement());
130 } 131 }
131 } 132 }
132 133
133 134
134 void PrettyPrinter::VisitContinueStatement(ContinueStatement* node) { 135 void PrettyPrinter::VisitContinueStatement(ContinueStatement* node) {
135 Print("continue"); 136 Print("continue");
136 ZoneStringList* labels = node->target()->labels(); 137 ZoneList<const AstString*>* labels = node->target()->labels();
137 if (labels != NULL) { 138 if (labels != NULL) {
138 Print(" "); 139 Print(" ");
139 ASSERT(labels->length() > 0); // guaranteed to have at least one entry 140 ASSERT(labels->length() > 0); // guaranteed to have at least one entry
140 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
141 } 142 }
142 Print(";"); 143 Print(";");
143 } 144 }
144 145
145 146
146 void PrettyPrinter::VisitBreakStatement(BreakStatement* node) { 147 void PrettyPrinter::VisitBreakStatement(BreakStatement* node) {
147 Print("break"); 148 Print("break");
148 ZoneStringList* labels = node->target()->labels(); 149 ZoneList<const AstString*>* labels = node->target()->labels();
149 if (labels != NULL) { 150 if (labels != NULL) {
150 Print(" "); 151 Print(" ");
151 ASSERT(labels->length() > 0); // guaranteed to have at least one entry 152 ASSERT(labels->length() > 0); // guaranteed to have at least one entry
152 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
153 } 154 }
154 Print(";"); 155 Print(";");
155 } 156 }
156 157
157 158
158 void PrettyPrinter::VisitReturnStatement(ReturnStatement* node) { 159 void PrettyPrinter::VisitReturnStatement(ReturnStatement* node) {
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 518
518 void PrettyPrinter::PrintStatements(ZoneList<Statement*>* statements) { 519 void PrettyPrinter::PrintStatements(ZoneList<Statement*>* statements) {
519 if (statements == NULL) return; 520 if (statements == NULL) return;
520 for (int i = 0; i < statements->length(); i++) { 521 for (int i = 0; i < statements->length(); i++) {
521 if (i != 0) Print(" "); 522 if (i != 0) Print(" ");
522 Visit(statements->at(i)); 523 Visit(statements->at(i));
523 } 524 }
524 } 525 }
525 526
526 527
527 void PrettyPrinter::PrintLabels(ZoneStringList* labels) { 528 void PrettyPrinter::PrintLabels(ZoneList<const AstString*>* labels) {
528 if (labels != NULL) { 529 if (labels != NULL) {
529 for (int i = 0; i < labels->length(); i++) { 530 for (int i = 0; i < labels->length(); i++) {
530 PrintLiteral(labels->at(i), false); 531 PrintLiteral(labels->at(i), false);
531 Print(": "); 532 Print(": ");
532 } 533 }
533 } 534 }
534 } 535 }
535 536
536 537
537 void PrettyPrinter::PrintArguments(ZoneList<Expression*>* arguments) { 538 void PrettyPrinter::PrintArguments(ZoneList<Expression*>* arguments) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 Print("?UNKNOWN?"); 576 Print("?UNKNOWN?");
576 } 577 }
577 } else if (object->IsFixedArray()) { 578 } else if (object->IsFixedArray()) {
578 Print("FixedArray"); 579 Print("FixedArray");
579 } else { 580 } else {
580 Print("<unknown literal %p>", object); 581 Print("<unknown literal %p>", object);
581 } 582 }
582 } 583 }
583 584
584 585
586 void PrettyPrinter::PrintLiteral(const AstString* value, bool quote) {
587 PrintLiteral(value->string(), quote);
588 }
589
590
585 void PrettyPrinter::PrintParameters(Scope* scope) { 591 void PrettyPrinter::PrintParameters(Scope* scope) {
586 Print("("); 592 Print("(");
587 for (int i = 0; i < scope->num_parameters(); i++) { 593 for (int i = 0; i < scope->num_parameters(); i++) {
588 if (i > 0) Print(", "); 594 if (i > 0) Print(", ");
589 PrintLiteral(scope->parameter(i)->name(), false); 595 PrintLiteral(scope->parameter(i)->name(), false);
590 } 596 }
591 Print(")"); 597 Print(")");
592 } 598 }
593 599
594 600
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
669 } else { 675 } else {
670 EmbeddedVector<char, 256> buf; 676 EmbeddedVector<char, 256> buf;
671 int pos = OS::SNPrintF(buf, "%s (mode = %s", info, 677 int pos = OS::SNPrintF(buf, "%s (mode = %s", info,
672 Variable::Mode2String(var->mode())); 678 Variable::Mode2String(var->mode()));
673 OS::SNPrintF(buf + pos, ")"); 679 OS::SNPrintF(buf + pos, ")");
674 PrintLiteralIndented(buf.start(), value, true); 680 PrintLiteralIndented(buf.start(), value, true);
675 } 681 }
676 } 682 }
677 683
678 684
679 void AstPrinter::PrintLabelsIndented(ZoneStringList* labels) { 685 void AstPrinter::PrintLabelsIndented(ZoneList<const AstString*>* labels) {
680 if (labels == NULL || labels->length() == 0) return; 686 if (labels == NULL || labels->length() == 0) return;
681 PrintIndented("LABELS "); 687 PrintIndented("LABELS ");
682 PrintLabels(labels); 688 PrintLabels(labels);
683 Print("\n"); 689 Print("\n");
684 } 690 }
685 691
686 692
687 void AstPrinter::PrintIndentedVisit(const char* s, AstNode* node) { 693 void AstPrinter::PrintIndentedVisit(const char* s, AstNode* node) {
688 IndentedScope indent(this, s); 694 IndentedScope indent(this, s);
689 Visit(node); 695 Visit(node);
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
1135 } 1141 }
1136 1142
1137 1143
1138 void AstPrinter::VisitThisFunction(ThisFunction* node) { 1144 void AstPrinter::VisitThisFunction(ThisFunction* node) {
1139 IndentedScope indent(this, "THIS-FUNCTION"); 1145 IndentedScope indent(this, "THIS-FUNCTION");
1140 } 1146 }
1141 1147
1142 #endif // DEBUG 1148 #endif // DEBUG
1143 1149
1144 } } // namespace v8::internal 1150 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/prettyprinter.h ('k') | src/rewriter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698