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

Side by Side Diff: src/prettyprinter.cc

Issue 7866041: Improved pretty printing of VAR PROXY and some control flow AST nodes. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 3 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 607
608 608
609 void AstPrinter::PrintLiteralIndented(const char* info, 609 void AstPrinter::PrintLiteralIndented(const char* info,
610 Handle<Object> value, 610 Handle<Object> value,
611 bool quote) { 611 bool quote) {
612 PrintIndented(info); 612 PrintIndented(info);
613 Print(" "); 613 Print(" ");
614 PrintLiteral(value, quote); 614 PrintLiteral(value, quote);
615 Print("\n"); 615 Print("\n");
616 } 616 }
617 617
danno 2011/09/12 13:48:39 remove line
618 618
619
619 void AstPrinter::PrintLiteralWithModeIndented(const char* info, 620 void AstPrinter::PrintLiteralWithModeIndented(const char* info,
620 Variable* var, 621 Variable* var,
621 Handle<Object> value) { 622 Handle<Object> value) {
622 if (var == NULL) { 623 if (var == NULL) {
623 PrintLiteralIndented(info, value, true); 624 PrintLiteralIndented(info, value, true);
624 } else { 625 } else {
625 EmbeddedVector<char, 256> buf; 626 EmbeddedVector<char, 256> buf;
626 int pos = OS::SNPrintF(buf, "%s (mode = %s", info, 627 int pos = OS::SNPrintF(buf, "%s (mode = %s", info,
627 Variable::Mode2String(var->mode())); 628 Variable::Mode2String(var->mode()));
628 OS::SNPrintF(buf + pos, ")"); 629 OS::SNPrintF(buf + pos, ")");
629 PrintLiteralIndented(buf.start(), value, true); 630 PrintLiteralIndented(buf.start(), value, true);
630 } 631 }
631 } 632 }
632 633
633 634
634 void AstPrinter::PrintLabelsIndented(const char* info, ZoneStringList* labels) { 635 void AstPrinter::PrintLabelsIndented(const char* info, ZoneStringList* labels) {
635 if (labels != NULL && labels->length() > 0) { 636 if (labels != NULL && labels->length() > 0) {
636 if (info == NULL) { 637 PrintIndented(info == NULL ? "LABELS" : info);
637 PrintIndented("LABELS "); 638 Print(" ");
638 } else {
639 PrintIndented(info);
640 Print(" ");
641 }
642 PrintLabels(labels); 639 PrintLabels(labels);
640 Print("\n");
643 } else if (info != NULL) { 641 } else if (info != NULL) {
644 PrintIndented(info); 642 PrintIndented(info);
645 } 643 Print("\n");
646 Print("\n"); 644 }
647 } 645 }
648 646
649 647
650 void AstPrinter::PrintIndentedVisit(const char* s, AstNode* node) { 648 void AstPrinter::PrintIndentedVisit(const char* s, AstNode* node) {
651 IndentedScope indent(this, s, node); 649 IndentedScope indent(this, s, node);
652 Visit(node); 650 Visit(node);
653 } 651 }
654 652
655 653
656 const char* AstPrinter::PrintProgram(FunctionLiteral* program) { 654 const char* AstPrinter::PrintProgram(FunctionLiteral* program) {
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
922 IndentedScope indent(this, "VALUES"); 920 IndentedScope indent(this, "VALUES");
923 for (int i = 0; i < node->values()->length(); i++) { 921 for (int i = 0; i < node->values()->length(); i++) {
924 Visit(node->values()->at(i)); 922 Visit(node->values()->at(i));
925 } 923 }
926 } 924 }
927 } 925 }
928 926
929 927
930 void AstPrinter::VisitVariableProxy(VariableProxy* node) { 928 void AstPrinter::VisitVariableProxy(VariableProxy* node) {
931 Variable* var = node->var(); 929 Variable* var = node->var();
932 PrintLiteralWithModeIndented("VAR PROXY", var, node->name()); 930 EmbeddedVector<char, 128> buf;
933 { IndentedScope indent(this); 931 int pos = OS::SNPrintF(buf, "VAR PROXY");
934 switch (var->location()) { 932 switch (var->location()) {
935 case Variable::UNALLOCATED: 933 case Variable::UNALLOCATED:
936 break; 934 break;
937 case Variable::PARAMETER: 935 case Variable::PARAMETER:
938 Print("parameter[%d]", var->index()); 936 OS::SNPrintF(buf + pos, " parameter[%d]", var->index());
939 break; 937 break;
940 case Variable::LOCAL: 938 case Variable::LOCAL:
941 Print("local[%d]", var->index()); 939 OS::SNPrintF(buf + pos, " local[%d]", var->index());
942 break; 940 break;
943 case Variable::CONTEXT: 941 case Variable::CONTEXT:
944 Print("context[%d]", var->index()); 942 OS::SNPrintF(buf + pos, " context[%d]", var->index());
945 break; 943 break;
946 case Variable::LOOKUP: 944 case Variable::LOOKUP:
947 Print("lookup"); 945 OS::SNPrintF(buf + pos, " lookup");
948 break; 946 break;
949 }
950 } 947 }
948 PrintLiteralWithModeIndented(buf.start(), var, node->name());
951 } 949 }
952 950
953 951
954 void AstPrinter::VisitAssignment(Assignment* node) { 952 void AstPrinter::VisitAssignment(Assignment* node) {
955 IndentedScope indent(this, Token::Name(node->op()), node); 953 IndentedScope indent(this, Token::Name(node->op()), node);
956 Visit(node->target()); 954 Visit(node->target());
957 Visit(node->value()); 955 Visit(node->value());
958 } 956 }
959 957
960 958
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
1429 AddAttribute("mode", Variable::Mode2String(decl->mode())); 1427 AddAttribute("mode", Variable::Mode2String(decl->mode()));
1430 } 1428 }
1431 Visit(decl->proxy()); 1429 Visit(decl->proxy());
1432 if (decl->fun() != NULL) Visit(decl->fun()); 1430 if (decl->fun() != NULL) Visit(decl->fun());
1433 } 1431 }
1434 1432
1435 1433
1436 #endif // DEBUG 1434 #endif // DEBUG
1437 1435
1438 } } // namespace v8::internal 1436 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698