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

Side by Side Diff: src/prettyprinter.cc

Issue 328343003: Remove dependency on Vector from platform files (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: updates 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
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 "src/v8.h" 7 #include "src/v8.h"
8 8
9 #include "src/prettyprinter.h" 9 #include "src/prettyprinter.h"
10 #include "src/scopes.h" 10 #include "src/scopes.h"
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 } 485 }
486 output_[0] = '\0'; 486 output_[0] = '\0';
487 pos_ = 0; 487 pos_ = 0;
488 } 488 }
489 489
490 490
491 void PrettyPrinter::Print(const char* format, ...) { 491 void PrettyPrinter::Print(const char* format, ...) {
492 for (;;) { 492 for (;;) {
493 va_list arguments; 493 va_list arguments;
494 va_start(arguments, format); 494 va_start(arguments, format);
495 int n = OS::VSNPrintF(Vector<char>(output_, size_) + pos_, 495 int n = VSNPrintF(Vector<char>(output_, size_) + pos_,
496 format, 496 format,
497 arguments); 497 arguments);
498 va_end(arguments); 498 va_end(arguments);
499 499
500 if (n >= 0) { 500 if (n >= 0) {
501 // there was enough space - we are done 501 // there was enough space - we are done
502 pos_ += n; 502 pos_ += n;
503 return; 503 return;
504 } else { 504 } else {
505 // there was not enough space - allocate more and try again 505 // there was not enough space - allocate more and try again
506 const int slack = 32; 506 const int slack = 32;
507 int new_size = size_ + (size_ >> 1) + slack; 507 int new_size = size_ + (size_ >> 1) + slack;
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 } 661 }
662 662
663 663
664 void AstPrinter::PrintLiteralWithModeIndented(const char* info, 664 void AstPrinter::PrintLiteralWithModeIndented(const char* info,
665 Variable* var, 665 Variable* var,
666 Handle<Object> value) { 666 Handle<Object> value) {
667 if (var == NULL) { 667 if (var == NULL) {
668 PrintLiteralIndented(info, value, true); 668 PrintLiteralIndented(info, value, true);
669 } else { 669 } else {
670 EmbeddedVector<char, 256> buf; 670 EmbeddedVector<char, 256> buf;
671 int pos = OS::SNPrintF(buf, "%s (mode = %s", info, 671 int pos = SNPrintF(buf, "%s (mode = %s", info,
672 Variable::Mode2String(var->mode())); 672 Variable::Mode2String(var->mode()));
673 OS::SNPrintF(buf + pos, ")"); 673 SNPrintF(buf + pos, ")");
674 PrintLiteralIndented(buf.start(), value, true); 674 PrintLiteralIndented(buf.start(), value, true);
675 } 675 }
676 } 676 }
677 677
678 678
679 void AstPrinter::PrintLabelsIndented(ZoneStringList* labels) { 679 void AstPrinter::PrintLabelsIndented(ZoneStringList* labels) {
680 if (labels == NULL || labels->length() == 0) return; 680 if (labels == NULL || labels->length() == 0) return;
681 PrintIndented("LABELS "); 681 PrintIndented("LABELS ");
682 PrintLabels(labels); 682 PrintLabels(labels);
683 Print("\n"); 683 Print("\n");
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
1026 Visit(node->values()->at(i)); 1026 Visit(node->values()->at(i));
1027 } 1027 }
1028 } 1028 }
1029 } 1029 }
1030 1030
1031 1031
1032 // TODO(svenpanne) Start with IndentedScope. 1032 // TODO(svenpanne) Start with IndentedScope.
1033 void AstPrinter::VisitVariableProxy(VariableProxy* node) { 1033 void AstPrinter::VisitVariableProxy(VariableProxy* node) {
1034 Variable* var = node->var(); 1034 Variable* var = node->var();
1035 EmbeddedVector<char, 128> buf; 1035 EmbeddedVector<char, 128> buf;
1036 int pos = OS::SNPrintF(buf, "VAR PROXY"); 1036 int pos = SNPrintF(buf, "VAR PROXY");
1037 switch (var->location()) { 1037 switch (var->location()) {
1038 case Variable::UNALLOCATED: 1038 case Variable::UNALLOCATED:
1039 break; 1039 break;
1040 case Variable::PARAMETER: 1040 case Variable::PARAMETER:
1041 OS::SNPrintF(buf + pos, " parameter[%d]", var->index()); 1041 SNPrintF(buf + pos, " parameter[%d]", var->index());
1042 break; 1042 break;
1043 case Variable::LOCAL: 1043 case Variable::LOCAL:
1044 OS::SNPrintF(buf + pos, " local[%d]", var->index()); 1044 SNPrintF(buf + pos, " local[%d]", var->index());
1045 break; 1045 break;
1046 case Variable::CONTEXT: 1046 case Variable::CONTEXT:
1047 OS::SNPrintF(buf + pos, " context[%d]", var->index()); 1047 SNPrintF(buf + pos, " context[%d]", var->index());
1048 break; 1048 break;
1049 case Variable::LOOKUP: 1049 case Variable::LOOKUP:
1050 OS::SNPrintF(buf + pos, " lookup"); 1050 SNPrintF(buf + pos, " lookup");
1051 break; 1051 break;
1052 } 1052 }
1053 PrintLiteralWithModeIndented(buf.start(), var, node->name()); 1053 PrintLiteralWithModeIndented(buf.start(), var, node->name());
1054 } 1054 }
1055 1055
1056 1056
1057 void AstPrinter::VisitAssignment(Assignment* node) { 1057 void AstPrinter::VisitAssignment(Assignment* node) {
1058 IndentedScope indent(this, Token::Name(node->op())); 1058 IndentedScope indent(this, Token::Name(node->op()));
1059 Visit(node->target()); 1059 Visit(node->target());
1060 Visit(node->value()); 1060 Visit(node->value());
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1107 1107
1108 1108
1109 void AstPrinter::VisitUnaryOperation(UnaryOperation* node) { 1109 void AstPrinter::VisitUnaryOperation(UnaryOperation* node) {
1110 IndentedScope indent(this, Token::Name(node->op())); 1110 IndentedScope indent(this, Token::Name(node->op()));
1111 Visit(node->expression()); 1111 Visit(node->expression());
1112 } 1112 }
1113 1113
1114 1114
1115 void AstPrinter::VisitCountOperation(CountOperation* node) { 1115 void AstPrinter::VisitCountOperation(CountOperation* node) {
1116 EmbeddedVector<char, 128> buf; 1116 EmbeddedVector<char, 128> buf;
1117 OS::SNPrintF(buf, "%s %s", (node->is_prefix() ? "PRE" : "POST"), 1117 SNPrintF(buf, "%s %s", (node->is_prefix() ? "PRE" : "POST"),
1118 Token::Name(node->op())); 1118 Token::Name(node->op()));
1119 IndentedScope indent(this, buf.start()); 1119 IndentedScope indent(this, buf.start());
1120 Visit(node->expression()); 1120 Visit(node->expression());
1121 } 1121 }
1122 1122
1123 1123
1124 void AstPrinter::VisitBinaryOperation(BinaryOperation* node) { 1124 void AstPrinter::VisitBinaryOperation(BinaryOperation* node) {
1125 IndentedScope indent(this, Token::Name(node->op())); 1125 IndentedScope indent(this, Token::Name(node->op()));
1126 Visit(node->left()); 1126 Visit(node->left());
1127 Visit(node->right()); 1127 Visit(node->right());
1128 } 1128 }
1129 1129
1130 1130
1131 void AstPrinter::VisitCompareOperation(CompareOperation* node) { 1131 void AstPrinter::VisitCompareOperation(CompareOperation* node) {
1132 IndentedScope indent(this, Token::Name(node->op())); 1132 IndentedScope indent(this, Token::Name(node->op()));
1133 Visit(node->left()); 1133 Visit(node->left());
1134 Visit(node->right()); 1134 Visit(node->right());
1135 } 1135 }
1136 1136
1137 1137
1138 void AstPrinter::VisitThisFunction(ThisFunction* node) { 1138 void AstPrinter::VisitThisFunction(ThisFunction* node) {
1139 IndentedScope indent(this, "THIS-FUNCTION"); 1139 IndentedScope indent(this, "THIS-FUNCTION");
1140 } 1140 }
1141 1141
1142 #endif // DEBUG 1142 #endif // DEBUG
1143 1143
1144 } } // namespace v8::internal 1144 } } // namespace v8::internal
OLDNEW
« src/platform-solaris.cc ('K') | « src/platform-win32.cc ('k') | src/profile-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698