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

Side by Side Diff: src/prettyprinter.cc

Issue 2840018: [Isolates] Moved more compilation-related globals (builtins, runtime, &c.)... (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/isolates/
Patch Set: rebase Created 10 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/runtime.h » ('j') | src/runtime.h » ('J')
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 572 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 PrintStatements(clause->statements()); 583 PrintStatements(clause->statements());
584 if (clause->statements()->length() > 0) 584 if (clause->statements()->length() > 0)
585 Print(" "); 585 Print(" ");
586 } 586 }
587 587
588 588
589 //----------------------------------------------------------------------------- 589 //-----------------------------------------------------------------------------
590 590
591 class IndentedScope BASE_EMBEDDED { 591 class IndentedScope BASE_EMBEDDED {
592 public: 592 public:
593 IndentedScope() { 593 explicit IndentedScope(AstPrinter* printer) : ast_printer_(printer) {
594 ast_printer_->inc_indent(); 594 ast_printer_->inc_indent();
595 } 595 }
596 596
597 explicit IndentedScope(const char* txt, AstNode* node = NULL) { 597 explicit IndentedScope(const char* txt, AstNode* node = NULL) {
598 ast_printer_->PrintIndented(txt); 598 ast_printer_->PrintIndented(txt);
599 if (node != NULL && node->AsExpression() != NULL) { 599 if (node != NULL && node->AsExpression() != NULL) {
600 Expression* expr = node->AsExpression(); 600 Expression* expr = node->AsExpression();
601 bool printed_first = false; 601 bool printed_first = false;
602 if ((expr->type() != NULL) && (expr->type()->IsKnown())) { 602 if ((expr->type() != NULL) && (expr->type()->IsKnown())) {
603 ast_printer_->Print(" (type = "); 603 ast_printer_->Print(" (type = ");
604 ast_printer_->Print(StaticType::Type2String(expr->type())); 604 ast_printer_->Print(StaticType::Type2String(expr->type()));
605 printed_first = true; 605 printed_first = true;
606 } 606 }
607 if (expr->num() != AstNode::kNoNumber) { 607 if (expr->num() != AstNode::kNoNumber) {
608 ast_printer_->Print(printed_first ? ", num = " : " (num = "); 608 ast_printer_->Print(printed_first ? ", num = " : " (num = ");
609 ast_printer_->Print("%d", expr->num()); 609 ast_printer_->Print("%d", expr->num());
610 printed_first = true; 610 printed_first = true;
611 } 611 }
612 if (printed_first) ast_printer_->Print(")"); 612 if (printed_first) ast_printer_->Print(")");
613 } 613 }
614 ast_printer_->Print("\n"); 614 ast_printer_->Print("\n");
615 ast_printer_->inc_indent(); 615 ast_printer_->inc_indent();
616 } 616 }
617 617
618 virtual ~IndentedScope() { 618 virtual ~IndentedScope() {
619 ast_printer_->dec_indent(); 619 ast_printer_->dec_indent();
620 } 620 }
621 621
622 static void SetAstPrinter(AstPrinter* a) { ast_printer_ = a; }
623
624 private: 622 private:
625 static AstPrinter* ast_printer_; 623 AstPrinter* ast_printer_;
626 }; 624 };
627 625
628 626
629 AstPrinter* IndentedScope::ast_printer_ = NULL;
630
631
632 //----------------------------------------------------------------------------- 627 //-----------------------------------------------------------------------------
633 628
634 int AstPrinter::indent_ = 0;
635 629
636 630 AstPrinter::AstPrinter() : indent_(0) {
637 AstPrinter::AstPrinter() {
638 ASSERT(indent_ == 0);
639 IndentedScope::SetAstPrinter(this);
640 } 631 }
641 632
642 633
643 AstPrinter::~AstPrinter() { 634 AstPrinter::~AstPrinter() {
644 ASSERT(indent_ == 0); 635 ASSERT(indent_ == 0);
645 IndentedScope::SetAstPrinter(NULL);
646 } 636 }
647 637
648 638
649 void AstPrinter::PrintIndented(const char* txt) { 639 void AstPrinter::PrintIndented(const char* txt) {
650 for (int i = 0; i < indent_; i++) { 640 for (int i = 0; i < indent_; i++) {
651 Print(". "); 641 Print(". ");
652 } 642 }
653 Print(txt); 643 Print(txt);
654 } 644 }
655 645
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
1023 } 1013 }
1024 Print("\n"); 1014 Print("\n");
1025 } 1015 }
1026 1016
1027 1017
1028 void AstPrinter::VisitVariableProxy(VariableProxy* node) { 1018 void AstPrinter::VisitVariableProxy(VariableProxy* node) {
1029 PrintLiteralWithModeIndented("VAR PROXY", node->AsVariable(), node->name(), 1019 PrintLiteralWithModeIndented("VAR PROXY", node->AsVariable(), node->name(),
1030 node->type(), node->num(), node->IsPrimitive()); 1020 node->type(), node->num(), node->IsPrimitive());
1031 Variable* var = node->var(); 1021 Variable* var = node->var();
1032 if (var != NULL && var->rewrite() != NULL) { 1022 if (var != NULL && var->rewrite() != NULL) {
1033 IndentedScope indent; 1023 IndentedScope indent(this);
1034 Visit(var->rewrite()); 1024 Visit(var->rewrite());
1035 } 1025 }
1036 } 1026 }
1037 1027
1038 1028
1039 void AstPrinter::VisitAssignment(Assignment* node) { 1029 void AstPrinter::VisitAssignment(Assignment* node) {
1040 IndentedScope indent(Token::Name(node->op()), node); 1030 IndentedScope indent(Token::Name(node->op()), node);
1041 Visit(node->target()); 1031 Visit(node->target());
1042 Visit(node->value()); 1032 Visit(node->value());
1043 } 1033 }
(...skipping 25 matching lines...) Expand all
1069 1059
1070 void AstPrinter::VisitCallNew(CallNew* node) { 1060 void AstPrinter::VisitCallNew(CallNew* node) {
1071 IndentedScope indent("CALL NEW"); 1061 IndentedScope indent("CALL NEW");
1072 Visit(node->expression()); 1062 Visit(node->expression());
1073 PrintArguments(node->arguments()); 1063 PrintArguments(node->arguments());
1074 } 1064 }
1075 1065
1076 1066
1077 void AstPrinter::VisitCallRuntime(CallRuntime* node) { 1067 void AstPrinter::VisitCallRuntime(CallRuntime* node) {
1078 PrintLiteralIndented("CALL RUNTIME ", node->name(), false); 1068 PrintLiteralIndented("CALL RUNTIME ", node->name(), false);
1079 IndentedScope indent; 1069 IndentedScope indent(this);
1080 PrintArguments(node->arguments()); 1070 PrintArguments(node->arguments());
1081 } 1071 }
1082 1072
1083 1073
1084 void AstPrinter::VisitUnaryOperation(UnaryOperation* node) { 1074 void AstPrinter::VisitUnaryOperation(UnaryOperation* node) {
1085 PrintIndentedVisit(Token::Name(node->op()), node->expression()); 1075 PrintIndentedVisit(Token::Name(node->op()), node->expression());
1086 } 1076 }
1087 1077
1088 1078
1089 void AstPrinter::VisitCountOperation(CountOperation* node) { 1079 void AstPrinter::VisitCountOperation(CountOperation* node) {
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
1522 AddAttribute("mode", Variable::Mode2String(decl->mode())); 1512 AddAttribute("mode", Variable::Mode2String(decl->mode()));
1523 } 1513 }
1524 Visit(decl->proxy()); 1514 Visit(decl->proxy());
1525 if (decl->fun() != NULL) Visit(decl->fun()); 1515 if (decl->fun() != NULL) Visit(decl->fun());
1526 } 1516 }
1527 1517
1528 1518
1529 #endif // DEBUG 1519 #endif // DEBUG
1530 1520
1531 } } // namespace v8::internal 1521 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/prettyprinter.h ('k') | src/runtime.h » ('j') | src/runtime.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698