OLD | NEW |
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 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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() != Expression::kNoLabel) { | 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 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
672 if (var == NULL) { | 672 if (var == NULL) { |
673 PrintLiteralIndented(info, value, true); | 673 PrintLiteralIndented(info, value, true); |
674 } else { | 674 } else { |
675 EmbeddedVector<char, 256> buf; | 675 EmbeddedVector<char, 256> buf; |
676 int pos = OS::SNPrintF(buf, "%s (mode = %s", info, | 676 int pos = OS::SNPrintF(buf, "%s (mode = %s", info, |
677 Variable::Mode2String(var->mode())); | 677 Variable::Mode2String(var->mode())); |
678 if (type->IsKnown()) { | 678 if (type->IsKnown()) { |
679 pos += OS::SNPrintF(buf + pos, ", type = %s", | 679 pos += OS::SNPrintF(buf + pos, ", type = %s", |
680 StaticType::Type2String(type)); | 680 StaticType::Type2String(type)); |
681 } | 681 } |
682 if (num != Expression::kNoLabel) { | 682 if (num != AstNode::kNoNumber) { |
683 pos += OS::SNPrintF(buf + pos, ", num = %d", num); | 683 pos += OS::SNPrintF(buf + pos, ", num = %d", num); |
684 } | 684 } |
685 OS::SNPrintF(buf + pos, ")"); | 685 OS::SNPrintF(buf + pos, ")"); |
686 PrintLiteralIndented(buf.start(), value, true); | 686 PrintLiteralIndented(buf.start(), value, true); |
687 } | 687 } |
688 } | 688 } |
689 | 689 |
690 | 690 |
691 void AstPrinter::PrintLabelsIndented(const char* info, ZoneStringList* labels) { | 691 void AstPrinter::PrintLabelsIndented(const char* info, ZoneStringList* labels) { |
692 if (labels != NULL && labels->length() > 0) { | 692 if (labels != NULL && labels->length() > 0) { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
733 } | 733 } |
734 | 734 |
735 | 735 |
736 void AstPrinter::PrintParameters(Scope* scope) { | 736 void AstPrinter::PrintParameters(Scope* scope) { |
737 if (scope->num_parameters() > 0) { | 737 if (scope->num_parameters() > 0) { |
738 IndentedScope indent("PARAMS"); | 738 IndentedScope indent("PARAMS"); |
739 for (int i = 0; i < scope->num_parameters(); i++) { | 739 for (int i = 0; i < scope->num_parameters(); i++) { |
740 PrintLiteralWithModeIndented("VAR", scope->parameter(i), | 740 PrintLiteralWithModeIndented("VAR", scope->parameter(i), |
741 scope->parameter(i)->name(), | 741 scope->parameter(i)->name(), |
742 scope->parameter(i)->type(), | 742 scope->parameter(i)->type(), |
743 Expression::kNoLabel); | 743 AstNode::kNoNumber); |
744 } | 744 } |
745 } | 745 } |
746 } | 746 } |
747 | 747 |
748 | 748 |
749 void AstPrinter::PrintStatements(ZoneList<Statement*>* statements) { | 749 void AstPrinter::PrintStatements(ZoneList<Statement*>* statements) { |
750 for (int i = 0; i < statements->length(); i++) { | 750 for (int i = 0; i < statements->length(); i++) { |
751 Visit(statements->at(i)); | 751 Visit(statements->at(i)); |
752 } | 752 } |
753 } | 753 } |
(...skipping 25 matching lines...) Expand all Loading... |
779 } | 779 } |
780 | 780 |
781 | 781 |
782 void AstPrinter::VisitDeclaration(Declaration* node) { | 782 void AstPrinter::VisitDeclaration(Declaration* node) { |
783 if (node->fun() == NULL) { | 783 if (node->fun() == NULL) { |
784 // var or const declarations | 784 // var or const declarations |
785 PrintLiteralWithModeIndented(Variable::Mode2String(node->mode()), | 785 PrintLiteralWithModeIndented(Variable::Mode2String(node->mode()), |
786 node->proxy()->AsVariable(), | 786 node->proxy()->AsVariable(), |
787 node->proxy()->name(), | 787 node->proxy()->name(), |
788 node->proxy()->AsVariable()->type(), | 788 node->proxy()->AsVariable()->type(), |
789 Expression::kNoLabel); | 789 AstNode::kNoNumber); |
790 } else { | 790 } else { |
791 // function declarations | 791 // function declarations |
792 PrintIndented("FUNCTION "); | 792 PrintIndented("FUNCTION "); |
793 PrintLiteral(node->proxy()->name(), true); | 793 PrintLiteral(node->proxy()->name(), true); |
794 Print(" = function "); | 794 Print(" = function "); |
795 PrintLiteral(node->fun()->name(), false); | 795 PrintLiteral(node->fun()->name(), false); |
796 Print("\n"); | 796 Print("\n"); |
797 } | 797 } |
798 } | 798 } |
799 | 799 |
(...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1517 AddAttribute("mode", Variable::Mode2String(decl->mode())); | 1517 AddAttribute("mode", Variable::Mode2String(decl->mode())); |
1518 } | 1518 } |
1519 Visit(decl->proxy()); | 1519 Visit(decl->proxy()); |
1520 if (decl->fun() != NULL) Visit(decl->fun()); | 1520 if (decl->fun() != NULL) Visit(decl->fun()); |
1521 } | 1521 } |
1522 | 1522 |
1523 | 1523 |
1524 #endif // DEBUG | 1524 #endif // DEBUG |
1525 | 1525 |
1526 } } // namespace v8::internal | 1526 } } // namespace v8::internal |
OLD | NEW |