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

Side by Side Diff: src/prettyprinter.cc

Issue 6685088: Merge isolates to bleeding_edge. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 9 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/profile-generator.h » ('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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 519
520 void PrettyPrinter::PrintLiteral(Handle<Object> value, bool quote) { 520 void PrettyPrinter::PrintLiteral(Handle<Object> value, bool quote) {
521 Object* object = *value; 521 Object* object = *value;
522 if (object->IsString()) { 522 if (object->IsString()) {
523 String* string = String::cast(object); 523 String* string = String::cast(object);
524 if (quote) Print("\""); 524 if (quote) Print("\"");
525 for (int i = 0; i < string->length(); i++) { 525 for (int i = 0; i < string->length(); i++) {
526 Print("%c", string->Get(i)); 526 Print("%c", string->Get(i));
527 } 527 }
528 if (quote) Print("\""); 528 if (quote) Print("\"");
529 } else if (object == Heap::null_value()) { 529 } else if (object->IsNull()) {
530 Print("null"); 530 Print("null");
531 } else if (object == Heap::true_value()) { 531 } else if (object->IsTrue()) {
532 Print("true"); 532 Print("true");
533 } else if (object == Heap::false_value()) { 533 } else if (object->IsFalse()) {
534 Print("false"); 534 Print("false");
535 } else if (object == Heap::undefined_value()) { 535 } else if (object->IsUndefined()) {
536 Print("undefined"); 536 Print("undefined");
537 } else if (object->IsNumber()) { 537 } else if (object->IsNumber()) {
538 Print("%g", object->Number()); 538 Print("%g", object->Number());
539 } else if (object->IsJSObject()) { 539 } else if (object->IsJSObject()) {
540 // regular expression 540 // regular expression
541 if (object->IsJSFunction()) { 541 if (object->IsJSFunction()) {
542 Print("JS-Function"); 542 Print("JS-Function");
543 } else if (object->IsJSArray()) { 543 } else if (object->IsJSArray()) {
544 Print("JS-array[%u]", JSArray::cast(object)->length()); 544 Print("JS-array[%u]", JSArray::cast(object)->length());
545 } else if (object->IsJSObject()) { 545 } else if (object->IsJSObject()) {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 PrintStatements(clause->statements()); 595 PrintStatements(clause->statements());
596 if (clause->statements()->length() > 0) 596 if (clause->statements()->length() > 0)
597 Print(" "); 597 Print(" ");
598 } 598 }
599 599
600 600
601 //----------------------------------------------------------------------------- 601 //-----------------------------------------------------------------------------
602 602
603 class IndentedScope BASE_EMBEDDED { 603 class IndentedScope BASE_EMBEDDED {
604 public: 604 public:
605 IndentedScope() { 605 explicit IndentedScope(AstPrinter* printer) : ast_printer_(printer) {
606 ast_printer_->inc_indent(); 606 ast_printer_->inc_indent();
607 } 607 }
608 608
609 explicit IndentedScope(const char* txt, AstNode* node = NULL) { 609 explicit IndentedScope(const char* txt, AstNode* node = NULL) {
610 ast_printer_->PrintIndented(txt); 610 ast_printer_->PrintIndented(txt);
611 if (node != NULL && node->AsExpression() != NULL) { 611 if (node != NULL && node->AsExpression() != NULL) {
612 Expression* expr = node->AsExpression(); 612 Expression* expr = node->AsExpression();
613 bool printed_first = false; 613 bool printed_first = false;
614 if ((expr->type() != NULL) && (expr->type()->IsKnown())) { 614 if ((expr->type() != NULL) && (expr->type()->IsKnown())) {
615 ast_printer_->Print(" (type = "); 615 ast_printer_->Print(" (type = ");
616 ast_printer_->Print(StaticType::Type2String(expr->type())); 616 ast_printer_->Print(StaticType::Type2String(expr->type()));
617 printed_first = true; 617 printed_first = true;
618 } 618 }
619 if (printed_first) ast_printer_->Print(")"); 619 if (printed_first) ast_printer_->Print(")");
620 } 620 }
621 ast_printer_->Print("\n"); 621 ast_printer_->Print("\n");
622 ast_printer_->inc_indent(); 622 ast_printer_->inc_indent();
623 } 623 }
624 624
625 virtual ~IndentedScope() { 625 virtual ~IndentedScope() {
626 ast_printer_->dec_indent(); 626 ast_printer_->dec_indent();
627 } 627 }
628 628
629 static void SetAstPrinter(AstPrinter* a) { ast_printer_ = a; }
630
631 private: 629 private:
632 static AstPrinter* ast_printer_; 630 AstPrinter* ast_printer_;
633 }; 631 };
634 632
635 633
636 AstPrinter* IndentedScope::ast_printer_ = NULL;
637
638
639 //----------------------------------------------------------------------------- 634 //-----------------------------------------------------------------------------
640 635
641 int AstPrinter::indent_ = 0;
642 636
643 637 AstPrinter::AstPrinter() : indent_(0) {
644 AstPrinter::AstPrinter() {
645 ASSERT(indent_ == 0);
646 IndentedScope::SetAstPrinter(this);
647 } 638 }
648 639
649 640
650 AstPrinter::~AstPrinter() { 641 AstPrinter::~AstPrinter() {
651 ASSERT(indent_ == 0); 642 ASSERT(indent_ == 0);
652 IndentedScope::SetAstPrinter(NULL);
653 } 643 }
654 644
655 645
656 void AstPrinter::PrintIndented(const char* txt) { 646 void AstPrinter::PrintIndented(const char* txt) {
657 for (int i = 0; i < indent_; i++) { 647 for (int i = 0; i < indent_; i++) {
658 Print(". "); 648 Print(". ");
659 } 649 }
660 Print(txt); 650 Print(txt);
661 } 651 }
662 652
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
1002 PrettyPrinter::VisitSlot(node); 992 PrettyPrinter::VisitSlot(node);
1003 Print("\n"); 993 Print("\n");
1004 } 994 }
1005 995
1006 996
1007 void AstPrinter::VisitVariableProxy(VariableProxy* node) { 997 void AstPrinter::VisitVariableProxy(VariableProxy* node) {
1008 PrintLiteralWithModeIndented("VAR PROXY", node->AsVariable(), node->name(), 998 PrintLiteralWithModeIndented("VAR PROXY", node->AsVariable(), node->name(),
1009 node->type()); 999 node->type());
1010 Variable* var = node->var(); 1000 Variable* var = node->var();
1011 if (var != NULL && var->rewrite() != NULL) { 1001 if (var != NULL && var->rewrite() != NULL) {
1012 IndentedScope indent; 1002 IndentedScope indent(this);
1013 Visit(var->rewrite()); 1003 Visit(var->rewrite());
1014 } 1004 }
1015 } 1005 }
1016 1006
1017 1007
1018 void AstPrinter::VisitAssignment(Assignment* node) { 1008 void AstPrinter::VisitAssignment(Assignment* node) {
1019 IndentedScope indent(Token::Name(node->op()), node); 1009 IndentedScope indent(Token::Name(node->op()), node);
1020 Visit(node->target()); 1010 Visit(node->target());
1021 Visit(node->value()); 1011 Visit(node->value());
1022 } 1012 }
(...skipping 25 matching lines...) Expand all
1048 1038
1049 void AstPrinter::VisitCallNew(CallNew* node) { 1039 void AstPrinter::VisitCallNew(CallNew* node) {
1050 IndentedScope indent("CALL NEW"); 1040 IndentedScope indent("CALL NEW");
1051 Visit(node->expression()); 1041 Visit(node->expression());
1052 PrintArguments(node->arguments()); 1042 PrintArguments(node->arguments());
1053 } 1043 }
1054 1044
1055 1045
1056 void AstPrinter::VisitCallRuntime(CallRuntime* node) { 1046 void AstPrinter::VisitCallRuntime(CallRuntime* node) {
1057 PrintLiteralIndented("CALL RUNTIME ", node->name(), false); 1047 PrintLiteralIndented("CALL RUNTIME ", node->name(), false);
1058 IndentedScope indent; 1048 IndentedScope indent(this);
1059 PrintArguments(node->arguments()); 1049 PrintArguments(node->arguments());
1060 } 1050 }
1061 1051
1062 1052
1063 void AstPrinter::VisitUnaryOperation(UnaryOperation* node) { 1053 void AstPrinter::VisitUnaryOperation(UnaryOperation* node) {
1064 PrintIndentedVisit(Token::Name(node->op()), node->expression()); 1054 PrintIndentedVisit(Token::Name(node->op()), node->expression());
1065 } 1055 }
1066 1056
1067 1057
1068 void AstPrinter::VisitIncrementOperation(IncrementOperation* node) { 1058 void AstPrinter::VisitIncrementOperation(IncrementOperation* node) {
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
1530 AddAttribute("mode", Variable::Mode2String(decl->mode())); 1520 AddAttribute("mode", Variable::Mode2String(decl->mode()));
1531 } 1521 }
1532 Visit(decl->proxy()); 1522 Visit(decl->proxy());
1533 if (decl->fun() != NULL) Visit(decl->fun()); 1523 if (decl->fun() != NULL) Visit(decl->fun());
1534 } 1524 }
1535 1525
1536 1526
1537 #endif // DEBUG 1527 #endif // DEBUG
1538 1528
1539 } } // namespace v8::internal 1529 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/prettyprinter.h ('k') | src/profile-generator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698