| 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 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 | 599 |
| 600 | 600 |
| 601 //----------------------------------------------------------------------------- | 601 //----------------------------------------------------------------------------- |
| 602 | 602 |
| 603 class IndentedScope BASE_EMBEDDED { | 603 class IndentedScope BASE_EMBEDDED { |
| 604 public: | 604 public: |
| 605 explicit IndentedScope(AstPrinter* printer) : ast_printer_(printer) { | 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 IndentedScope(AstPrinter* printer, const char* txt, AstNode* node = NULL) |
| 610 : ast_printer_(printer) { |
| 610 ast_printer_->PrintIndented(txt); | 611 ast_printer_->PrintIndented(txt); |
| 611 if (node != NULL && node->AsExpression() != NULL) { | 612 if (node != NULL && node->AsExpression() != NULL) { |
| 612 Expression* expr = node->AsExpression(); | 613 Expression* expr = node->AsExpression(); |
| 613 bool printed_first = false; | 614 bool printed_first = false; |
| 614 if ((expr->type() != NULL) && (expr->type()->IsKnown())) { | 615 if ((expr->type() != NULL) && (expr->type()->IsKnown())) { |
| 615 ast_printer_->Print(" (type = "); | 616 ast_printer_->Print(" (type = "); |
| 616 ast_printer_->Print(StaticType::Type2String(expr->type())); | 617 ast_printer_->Print(StaticType::Type2String(expr->type())); |
| 617 printed_first = true; | 618 printed_first = true; |
| 618 } | 619 } |
| 619 if (printed_first) ast_printer_->Print(")"); | 620 if (printed_first) ast_printer_->Print(")"); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 691 } | 692 } |
| 692 PrintLabels(labels); | 693 PrintLabels(labels); |
| 693 } else if (info != NULL) { | 694 } else if (info != NULL) { |
| 694 PrintIndented(info); | 695 PrintIndented(info); |
| 695 } | 696 } |
| 696 Print("\n"); | 697 Print("\n"); |
| 697 } | 698 } |
| 698 | 699 |
| 699 | 700 |
| 700 void AstPrinter::PrintIndentedVisit(const char* s, AstNode* node) { | 701 void AstPrinter::PrintIndentedVisit(const char* s, AstNode* node) { |
| 701 IndentedScope indent(s, node); | 702 IndentedScope indent(this, s, node); |
| 702 Visit(node); | 703 Visit(node); |
| 703 } | 704 } |
| 704 | 705 |
| 705 | 706 |
| 706 const char* AstPrinter::PrintProgram(FunctionLiteral* program) { | 707 const char* AstPrinter::PrintProgram(FunctionLiteral* program) { |
| 707 Init(); | 708 Init(); |
| 708 { IndentedScope indent("FUNC"); | 709 { IndentedScope indent(this, "FUNC"); |
| 709 PrintLiteralIndented("NAME", program->name(), true); | 710 PrintLiteralIndented("NAME", program->name(), true); |
| 710 PrintLiteralIndented("INFERRED NAME", program->inferred_name(), true); | 711 PrintLiteralIndented("INFERRED NAME", program->inferred_name(), true); |
| 711 PrintParameters(program->scope()); | 712 PrintParameters(program->scope()); |
| 712 PrintDeclarations(program->scope()->declarations()); | 713 PrintDeclarations(program->scope()->declarations()); |
| 713 PrintStatements(program->body()); | 714 PrintStatements(program->body()); |
| 714 } | 715 } |
| 715 return Output(); | 716 return Output(); |
| 716 } | 717 } |
| 717 | 718 |
| 718 | 719 |
| 719 void AstPrinter::PrintDeclarations(ZoneList<Declaration*>* declarations) { | 720 void AstPrinter::PrintDeclarations(ZoneList<Declaration*>* declarations) { |
| 720 if (declarations->length() > 0) { | 721 if (declarations->length() > 0) { |
| 721 IndentedScope indent("DECLS"); | 722 IndentedScope indent(this, "DECLS"); |
| 722 for (int i = 0; i < declarations->length(); i++) { | 723 for (int i = 0; i < declarations->length(); i++) { |
| 723 Visit(declarations->at(i)); | 724 Visit(declarations->at(i)); |
| 724 } | 725 } |
| 725 } | 726 } |
| 726 } | 727 } |
| 727 | 728 |
| 728 | 729 |
| 729 void AstPrinter::PrintParameters(Scope* scope) { | 730 void AstPrinter::PrintParameters(Scope* scope) { |
| 730 if (scope->num_parameters() > 0) { | 731 if (scope->num_parameters() > 0) { |
| 731 IndentedScope indent("PARAMS"); | 732 IndentedScope indent(this, "PARAMS"); |
| 732 for (int i = 0; i < scope->num_parameters(); i++) { | 733 for (int i = 0; i < scope->num_parameters(); i++) { |
| 733 PrintLiteralWithModeIndented("VAR", scope->parameter(i), | 734 PrintLiteralWithModeIndented("VAR", scope->parameter(i), |
| 734 scope->parameter(i)->name(), | 735 scope->parameter(i)->name(), |
| 735 scope->parameter(i)->type()); | 736 scope->parameter(i)->type()); |
| 736 } | 737 } |
| 737 } | 738 } |
| 738 } | 739 } |
| 739 | 740 |
| 740 | 741 |
| 741 void AstPrinter::PrintStatements(ZoneList<Statement*>* statements) { | 742 void AstPrinter::PrintStatements(ZoneList<Statement*>* statements) { |
| 742 for (int i = 0; i < statements->length(); i++) { | 743 for (int i = 0; i < statements->length(); i++) { |
| 743 Visit(statements->at(i)); | 744 Visit(statements->at(i)); |
| 744 } | 745 } |
| 745 } | 746 } |
| 746 | 747 |
| 747 | 748 |
| 748 void AstPrinter::PrintArguments(ZoneList<Expression*>* arguments) { | 749 void AstPrinter::PrintArguments(ZoneList<Expression*>* arguments) { |
| 749 for (int i = 0; i < arguments->length(); i++) { | 750 for (int i = 0; i < arguments->length(); i++) { |
| 750 Visit(arguments->at(i)); | 751 Visit(arguments->at(i)); |
| 751 } | 752 } |
| 752 } | 753 } |
| 753 | 754 |
| 754 | 755 |
| 755 void AstPrinter::PrintCaseClause(CaseClause* clause) { | 756 void AstPrinter::PrintCaseClause(CaseClause* clause) { |
| 756 if (clause->is_default()) { | 757 if (clause->is_default()) { |
| 757 IndentedScope indent("DEFAULT"); | 758 IndentedScope indent(this, "DEFAULT"); |
| 758 PrintStatements(clause->statements()); | 759 PrintStatements(clause->statements()); |
| 759 } else { | 760 } else { |
| 760 IndentedScope indent("CASE"); | 761 IndentedScope indent(this, "CASE"); |
| 761 Visit(clause->label()); | 762 Visit(clause->label()); |
| 762 PrintStatements(clause->statements()); | 763 PrintStatements(clause->statements()); |
| 763 } | 764 } |
| 764 } | 765 } |
| 765 | 766 |
| 766 | 767 |
| 767 void AstPrinter::VisitBlock(Block* node) { | 768 void AstPrinter::VisitBlock(Block* node) { |
| 768 const char* block_txt = node->is_initializer_block() ? "BLOCK INIT" : "BLOCK"; | 769 const char* block_txt = node->is_initializer_block() ? "BLOCK INIT" : "BLOCK"; |
| 769 IndentedScope indent(block_txt); | 770 IndentedScope indent(this, block_txt); |
| 770 PrintStatements(node->statements()); | 771 PrintStatements(node->statements()); |
| 771 } | 772 } |
| 772 | 773 |
| 773 | 774 |
| 774 void AstPrinter::VisitDeclaration(Declaration* node) { | 775 void AstPrinter::VisitDeclaration(Declaration* node) { |
| 775 if (node->fun() == NULL) { | 776 if (node->fun() == NULL) { |
| 776 // var or const declarations | 777 // var or const declarations |
| 777 PrintLiteralWithModeIndented(Variable::Mode2String(node->mode()), | 778 PrintLiteralWithModeIndented(Variable::Mode2String(node->mode()), |
| 778 node->proxy()->AsVariable(), | 779 node->proxy()->AsVariable(), |
| 779 node->proxy()->name(), | 780 node->proxy()->name(), |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 827 PrintIndentedVisit("WITH ENTER", node->expression()); | 828 PrintIndentedVisit("WITH ENTER", node->expression()); |
| 828 } | 829 } |
| 829 | 830 |
| 830 | 831 |
| 831 void AstPrinter::VisitWithExitStatement(WithExitStatement* node) { | 832 void AstPrinter::VisitWithExitStatement(WithExitStatement* node) { |
| 832 PrintIndented("WITH EXIT\n"); | 833 PrintIndented("WITH EXIT\n"); |
| 833 } | 834 } |
| 834 | 835 |
| 835 | 836 |
| 836 void AstPrinter::VisitSwitchStatement(SwitchStatement* node) { | 837 void AstPrinter::VisitSwitchStatement(SwitchStatement* node) { |
| 837 IndentedScope indent("SWITCH"); | 838 IndentedScope indent(this, "SWITCH"); |
| 838 PrintLabelsIndented(NULL, node->labels()); | 839 PrintLabelsIndented(NULL, node->labels()); |
| 839 PrintIndentedVisit("TAG", node->tag()); | 840 PrintIndentedVisit("TAG", node->tag()); |
| 840 for (int i = 0; i < node->cases()->length(); i++) { | 841 for (int i = 0; i < node->cases()->length(); i++) { |
| 841 PrintCaseClause(node->cases()->at(i)); | 842 PrintCaseClause(node->cases()->at(i)); |
| 842 } | 843 } |
| 843 } | 844 } |
| 844 | 845 |
| 845 | 846 |
| 846 void AstPrinter::VisitDoWhileStatement(DoWhileStatement* node) { | 847 void AstPrinter::VisitDoWhileStatement(DoWhileStatement* node) { |
| 847 IndentedScope indent("DO"); | 848 IndentedScope indent(this, "DO"); |
| 848 PrintLabelsIndented(NULL, node->labels()); | 849 PrintLabelsIndented(NULL, node->labels()); |
| 849 PrintIndentedVisit("BODY", node->body()); | 850 PrintIndentedVisit("BODY", node->body()); |
| 850 PrintIndentedVisit("COND", node->cond()); | 851 PrintIndentedVisit("COND", node->cond()); |
| 851 } | 852 } |
| 852 | 853 |
| 853 | 854 |
| 854 void AstPrinter::VisitWhileStatement(WhileStatement* node) { | 855 void AstPrinter::VisitWhileStatement(WhileStatement* node) { |
| 855 IndentedScope indent("WHILE"); | 856 IndentedScope indent(this, "WHILE"); |
| 856 PrintLabelsIndented(NULL, node->labels()); | 857 PrintLabelsIndented(NULL, node->labels()); |
| 857 PrintIndentedVisit("COND", node->cond()); | 858 PrintIndentedVisit("COND", node->cond()); |
| 858 PrintIndentedVisit("BODY", node->body()); | 859 PrintIndentedVisit("BODY", node->body()); |
| 859 } | 860 } |
| 860 | 861 |
| 861 | 862 |
| 862 void AstPrinter::VisitForStatement(ForStatement* node) { | 863 void AstPrinter::VisitForStatement(ForStatement* node) { |
| 863 IndentedScope indent("FOR"); | 864 IndentedScope indent(this, "FOR"); |
| 864 PrintLabelsIndented(NULL, node->labels()); | 865 PrintLabelsIndented(NULL, node->labels()); |
| 865 if (node->init()) PrintIndentedVisit("INIT", node->init()); | 866 if (node->init()) PrintIndentedVisit("INIT", node->init()); |
| 866 if (node->cond()) PrintIndentedVisit("COND", node->cond()); | 867 if (node->cond()) PrintIndentedVisit("COND", node->cond()); |
| 867 PrintIndentedVisit("BODY", node->body()); | 868 PrintIndentedVisit("BODY", node->body()); |
| 868 if (node->next()) PrintIndentedVisit("NEXT", node->next()); | 869 if (node->next()) PrintIndentedVisit("NEXT", node->next()); |
| 869 } | 870 } |
| 870 | 871 |
| 871 | 872 |
| 872 void AstPrinter::VisitForInStatement(ForInStatement* node) { | 873 void AstPrinter::VisitForInStatement(ForInStatement* node) { |
| 873 IndentedScope indent("FOR IN"); | 874 IndentedScope indent(this, "FOR IN"); |
| 874 PrintIndentedVisit("FOR", node->each()); | 875 PrintIndentedVisit("FOR", node->each()); |
| 875 PrintIndentedVisit("IN", node->enumerable()); | 876 PrintIndentedVisit("IN", node->enumerable()); |
| 876 PrintIndentedVisit("BODY", node->body()); | 877 PrintIndentedVisit("BODY", node->body()); |
| 877 } | 878 } |
| 878 | 879 |
| 879 | 880 |
| 880 void AstPrinter::VisitTryCatchStatement(TryCatchStatement* node) { | 881 void AstPrinter::VisitTryCatchStatement(TryCatchStatement* node) { |
| 881 IndentedScope indent("TRY CATCH"); | 882 IndentedScope indent(this, "TRY CATCH"); |
| 882 PrintIndentedVisit("TRY", node->try_block()); | 883 PrintIndentedVisit("TRY", node->try_block()); |
| 883 PrintIndentedVisit("CATCHVAR", node->catch_var()); | 884 PrintIndentedVisit("CATCHVAR", node->catch_var()); |
| 884 PrintIndentedVisit("CATCH", node->catch_block()); | 885 PrintIndentedVisit("CATCH", node->catch_block()); |
| 885 } | 886 } |
| 886 | 887 |
| 887 | 888 |
| 888 void AstPrinter::VisitTryFinallyStatement(TryFinallyStatement* node) { | 889 void AstPrinter::VisitTryFinallyStatement(TryFinallyStatement* node) { |
| 889 IndentedScope indent("TRY FINALLY"); | 890 IndentedScope indent(this, "TRY FINALLY"); |
| 890 PrintIndentedVisit("TRY", node->try_block()); | 891 PrintIndentedVisit("TRY", node->try_block()); |
| 891 PrintIndentedVisit("FINALLY", node->finally_block()); | 892 PrintIndentedVisit("FINALLY", node->finally_block()); |
| 892 } | 893 } |
| 893 | 894 |
| 894 | 895 |
| 895 void AstPrinter::VisitDebuggerStatement(DebuggerStatement* node) { | 896 void AstPrinter::VisitDebuggerStatement(DebuggerStatement* node) { |
| 896 IndentedScope indent("DEBUGGER"); | 897 IndentedScope indent(this, "DEBUGGER"); |
| 897 } | 898 } |
| 898 | 899 |
| 899 | 900 |
| 900 void AstPrinter::VisitFunctionLiteral(FunctionLiteral* node) { | 901 void AstPrinter::VisitFunctionLiteral(FunctionLiteral* node) { |
| 901 IndentedScope indent("FUNC LITERAL"); | 902 IndentedScope indent(this, "FUNC LITERAL"); |
| 902 PrintLiteralIndented("NAME", node->name(), false); | 903 PrintLiteralIndented("NAME", node->name(), false); |
| 903 PrintLiteralIndented("INFERRED NAME", node->inferred_name(), false); | 904 PrintLiteralIndented("INFERRED NAME", node->inferred_name(), false); |
| 904 PrintParameters(node->scope()); | 905 PrintParameters(node->scope()); |
| 905 // We don't want to see the function literal in this case: it | 906 // We don't want to see the function literal in this case: it |
| 906 // will be printed via PrintProgram when the code for it is | 907 // will be printed via PrintProgram when the code for it is |
| 907 // generated. | 908 // generated. |
| 908 // PrintStatements(node->body()); | 909 // PrintStatements(node->body()); |
| 909 } | 910 } |
| 910 | 911 |
| 911 | 912 |
| 912 void AstPrinter::VisitSharedFunctionInfoLiteral( | 913 void AstPrinter::VisitSharedFunctionInfoLiteral( |
| 913 SharedFunctionInfoLiteral* node) { | 914 SharedFunctionInfoLiteral* node) { |
| 914 IndentedScope indent("FUNC LITERAL"); | 915 IndentedScope indent(this, "FUNC LITERAL"); |
| 915 PrintLiteralIndented("SHARED INFO", node->shared_function_info(), true); | 916 PrintLiteralIndented("SHARED INFO", node->shared_function_info(), true); |
| 916 } | 917 } |
| 917 | 918 |
| 918 | 919 |
| 919 void AstPrinter::VisitConditional(Conditional* node) { | 920 void AstPrinter::VisitConditional(Conditional* node) { |
| 920 IndentedScope indent("CONDITIONAL"); | 921 IndentedScope indent(this, "CONDITIONAL"); |
| 921 PrintIndentedVisit("?", node->condition()); | 922 PrintIndentedVisit("?", node->condition()); |
| 922 PrintIndentedVisit("THEN", node->then_expression()); | 923 PrintIndentedVisit("THEN", node->then_expression()); |
| 923 PrintIndentedVisit("ELSE", node->else_expression()); | 924 PrintIndentedVisit("ELSE", node->else_expression()); |
| 924 } | 925 } |
| 925 | 926 |
| 926 | 927 |
| 927 void AstPrinter::VisitLiteral(Literal* node) { | 928 void AstPrinter::VisitLiteral(Literal* node) { |
| 928 PrintLiteralIndented("LITERAL", node->handle(), true); | 929 PrintLiteralIndented("LITERAL", node->handle(), true); |
| 929 } | 930 } |
| 930 | 931 |
| 931 | 932 |
| 932 void AstPrinter::VisitRegExpLiteral(RegExpLiteral* node) { | 933 void AstPrinter::VisitRegExpLiteral(RegExpLiteral* node) { |
| 933 IndentedScope indent("REGEXP LITERAL"); | 934 IndentedScope indent(this, "REGEXP LITERAL"); |
| 934 PrintLiteralIndented("PATTERN", node->pattern(), false); | 935 PrintLiteralIndented("PATTERN", node->pattern(), false); |
| 935 PrintLiteralIndented("FLAGS", node->flags(), false); | 936 PrintLiteralIndented("FLAGS", node->flags(), false); |
| 936 } | 937 } |
| 937 | 938 |
| 938 | 939 |
| 939 void AstPrinter::VisitObjectLiteral(ObjectLiteral* node) { | 940 void AstPrinter::VisitObjectLiteral(ObjectLiteral* node) { |
| 940 IndentedScope indent("OBJ LITERAL"); | 941 IndentedScope indent(this, "OBJ LITERAL"); |
| 941 for (int i = 0; i < node->properties()->length(); i++) { | 942 for (int i = 0; i < node->properties()->length(); i++) { |
| 942 const char* prop_kind = NULL; | 943 const char* prop_kind = NULL; |
| 943 switch (node->properties()->at(i)->kind()) { | 944 switch (node->properties()->at(i)->kind()) { |
| 944 case ObjectLiteral::Property::CONSTANT: | 945 case ObjectLiteral::Property::CONSTANT: |
| 945 prop_kind = "PROPERTY - CONSTANT"; | 946 prop_kind = "PROPERTY - CONSTANT"; |
| 946 break; | 947 break; |
| 947 case ObjectLiteral::Property::COMPUTED: | 948 case ObjectLiteral::Property::COMPUTED: |
| 948 prop_kind = "PROPERTY - COMPUTED"; | 949 prop_kind = "PROPERTY - COMPUTED"; |
| 949 break; | 950 break; |
| 950 case ObjectLiteral::Property::MATERIALIZED_LITERAL: | 951 case ObjectLiteral::Property::MATERIALIZED_LITERAL: |
| 951 prop_kind = "PROPERTY - MATERIALIZED_LITERAL"; | 952 prop_kind = "PROPERTY - MATERIALIZED_LITERAL"; |
| 952 break; | 953 break; |
| 953 case ObjectLiteral::Property::PROTOTYPE: | 954 case ObjectLiteral::Property::PROTOTYPE: |
| 954 prop_kind = "PROPERTY - PROTOTYPE"; | 955 prop_kind = "PROPERTY - PROTOTYPE"; |
| 955 break; | 956 break; |
| 956 case ObjectLiteral::Property::GETTER: | 957 case ObjectLiteral::Property::GETTER: |
| 957 prop_kind = "PROPERTY - GETTER"; | 958 prop_kind = "PROPERTY - GETTER"; |
| 958 break; | 959 break; |
| 959 case ObjectLiteral::Property::SETTER: | 960 case ObjectLiteral::Property::SETTER: |
| 960 prop_kind = "PROPERTY - SETTER"; | 961 prop_kind = "PROPERTY - SETTER"; |
| 961 break; | 962 break; |
| 962 default: | 963 default: |
| 963 UNREACHABLE(); | 964 UNREACHABLE(); |
| 964 } | 965 } |
| 965 IndentedScope prop(prop_kind); | 966 IndentedScope prop(this, prop_kind); |
| 966 PrintIndentedVisit("KEY", node->properties()->at(i)->key()); | 967 PrintIndentedVisit("KEY", node->properties()->at(i)->key()); |
| 967 PrintIndentedVisit("VALUE", node->properties()->at(i)->value()); | 968 PrintIndentedVisit("VALUE", node->properties()->at(i)->value()); |
| 968 } | 969 } |
| 969 } | 970 } |
| 970 | 971 |
| 971 | 972 |
| 972 void AstPrinter::VisitArrayLiteral(ArrayLiteral* node) { | 973 void AstPrinter::VisitArrayLiteral(ArrayLiteral* node) { |
| 973 IndentedScope indent("ARRAY LITERAL"); | 974 IndentedScope indent(this, "ARRAY LITERAL"); |
| 974 if (node->values()->length() > 0) { | 975 if (node->values()->length() > 0) { |
| 975 IndentedScope indent("VALUES"); | 976 IndentedScope indent(this, "VALUES"); |
| 976 for (int i = 0; i < node->values()->length(); i++) { | 977 for (int i = 0; i < node->values()->length(); i++) { |
| 977 Visit(node->values()->at(i)); | 978 Visit(node->values()->at(i)); |
| 978 } | 979 } |
| 979 } | 980 } |
| 980 } | 981 } |
| 981 | 982 |
| 982 | 983 |
| 983 void AstPrinter::VisitCatchExtensionObject(CatchExtensionObject* node) { | 984 void AstPrinter::VisitCatchExtensionObject(CatchExtensionObject* node) { |
| 984 IndentedScope indent("CatchExtensionObject"); | 985 IndentedScope indent(this, "CatchExtensionObject"); |
| 985 PrintIndentedVisit("KEY", node->key()); | 986 PrintIndentedVisit("KEY", node->key()); |
| 986 PrintIndentedVisit("VALUE", node->value()); | 987 PrintIndentedVisit("VALUE", node->value()); |
| 987 } | 988 } |
| 988 | 989 |
| 989 | 990 |
| 990 void AstPrinter::VisitSlot(Slot* node) { | 991 void AstPrinter::VisitSlot(Slot* node) { |
| 991 PrintIndented("SLOT "); | 992 PrintIndented("SLOT "); |
| 992 PrettyPrinter::VisitSlot(node); | 993 PrettyPrinter::VisitSlot(node); |
| 993 Print("\n"); | 994 Print("\n"); |
| 994 } | 995 } |
| 995 | 996 |
| 996 | 997 |
| 997 void AstPrinter::VisitVariableProxy(VariableProxy* node) { | 998 void AstPrinter::VisitVariableProxy(VariableProxy* node) { |
| 998 PrintLiteralWithModeIndented("VAR PROXY", node->AsVariable(), node->name(), | 999 PrintLiteralWithModeIndented("VAR PROXY", node->AsVariable(), node->name(), |
| 999 node->type()); | 1000 node->type()); |
| 1000 Variable* var = node->var(); | 1001 Variable* var = node->var(); |
| 1001 if (var != NULL && var->rewrite() != NULL) { | 1002 if (var != NULL && var->rewrite() != NULL) { |
| 1002 IndentedScope indent(this); | 1003 IndentedScope indent(this); |
| 1003 Visit(var->rewrite()); | 1004 Visit(var->rewrite()); |
| 1004 } | 1005 } |
| 1005 } | 1006 } |
| 1006 | 1007 |
| 1007 | 1008 |
| 1008 void AstPrinter::VisitAssignment(Assignment* node) { | 1009 void AstPrinter::VisitAssignment(Assignment* node) { |
| 1009 IndentedScope indent(Token::Name(node->op()), node); | 1010 IndentedScope indent(this, Token::Name(node->op()), node); |
| 1010 Visit(node->target()); | 1011 Visit(node->target()); |
| 1011 Visit(node->value()); | 1012 Visit(node->value()); |
| 1012 } | 1013 } |
| 1013 | 1014 |
| 1014 | 1015 |
| 1015 void AstPrinter::VisitThrow(Throw* node) { | 1016 void AstPrinter::VisitThrow(Throw* node) { |
| 1016 PrintIndentedVisit("THROW", node->exception()); | 1017 PrintIndentedVisit("THROW", node->exception()); |
| 1017 } | 1018 } |
| 1018 | 1019 |
| 1019 | 1020 |
| 1020 void AstPrinter::VisitProperty(Property* node) { | 1021 void AstPrinter::VisitProperty(Property* node) { |
| 1021 IndentedScope indent("PROPERTY", node); | 1022 IndentedScope indent(this, "PROPERTY", node); |
| 1022 Visit(node->obj()); | 1023 Visit(node->obj()); |
| 1023 Literal* literal = node->key()->AsLiteral(); | 1024 Literal* literal = node->key()->AsLiteral(); |
| 1024 if (literal != NULL && literal->handle()->IsSymbol()) { | 1025 if (literal != NULL && literal->handle()->IsSymbol()) { |
| 1025 PrintLiteralIndented("NAME", literal->handle(), false); | 1026 PrintLiteralIndented("NAME", literal->handle(), false); |
| 1026 } else { | 1027 } else { |
| 1027 PrintIndentedVisit("KEY", node->key()); | 1028 PrintIndentedVisit("KEY", node->key()); |
| 1028 } | 1029 } |
| 1029 } | 1030 } |
| 1030 | 1031 |
| 1031 | 1032 |
| 1032 void AstPrinter::VisitCall(Call* node) { | 1033 void AstPrinter::VisitCall(Call* node) { |
| 1033 IndentedScope indent("CALL"); | 1034 IndentedScope indent(this, "CALL"); |
| 1034 Visit(node->expression()); | 1035 Visit(node->expression()); |
| 1035 PrintArguments(node->arguments()); | 1036 PrintArguments(node->arguments()); |
| 1036 } | 1037 } |
| 1037 | 1038 |
| 1038 | 1039 |
| 1039 void AstPrinter::VisitCallNew(CallNew* node) { | 1040 void AstPrinter::VisitCallNew(CallNew* node) { |
| 1040 IndentedScope indent("CALL NEW"); | 1041 IndentedScope indent(this, "CALL NEW"); |
| 1041 Visit(node->expression()); | 1042 Visit(node->expression()); |
| 1042 PrintArguments(node->arguments()); | 1043 PrintArguments(node->arguments()); |
| 1043 } | 1044 } |
| 1044 | 1045 |
| 1045 | 1046 |
| 1046 void AstPrinter::VisitCallRuntime(CallRuntime* node) { | 1047 void AstPrinter::VisitCallRuntime(CallRuntime* node) { |
| 1047 PrintLiteralIndented("CALL RUNTIME ", node->name(), false); | 1048 PrintLiteralIndented("CALL RUNTIME ", node->name(), false); |
| 1048 IndentedScope indent(this); | 1049 IndentedScope indent(this); |
| 1049 PrintArguments(node->arguments()); | 1050 PrintArguments(node->arguments()); |
| 1050 } | 1051 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1069 StaticType::Type2String(node->type())); | 1070 StaticType::Type2String(node->type())); |
| 1070 } else { | 1071 } else { |
| 1071 OS::SNPrintF(buf, "%s %s", (node->is_prefix() ? "PRE" : "POST"), | 1072 OS::SNPrintF(buf, "%s %s", (node->is_prefix() ? "PRE" : "POST"), |
| 1072 Token::Name(node->op())); | 1073 Token::Name(node->op())); |
| 1073 } | 1074 } |
| 1074 PrintIndentedVisit(buf.start(), node->expression()); | 1075 PrintIndentedVisit(buf.start(), node->expression()); |
| 1075 } | 1076 } |
| 1076 | 1077 |
| 1077 | 1078 |
| 1078 void AstPrinter::VisitBinaryOperation(BinaryOperation* node) { | 1079 void AstPrinter::VisitBinaryOperation(BinaryOperation* node) { |
| 1079 IndentedScope indent(Token::Name(node->op()), node); | 1080 IndentedScope indent(this, Token::Name(node->op()), node); |
| 1080 Visit(node->left()); | 1081 Visit(node->left()); |
| 1081 Visit(node->right()); | 1082 Visit(node->right()); |
| 1082 } | 1083 } |
| 1083 | 1084 |
| 1084 | 1085 |
| 1085 void AstPrinter::VisitCompareOperation(CompareOperation* node) { | 1086 void AstPrinter::VisitCompareOperation(CompareOperation* node) { |
| 1086 IndentedScope indent(Token::Name(node->op()), node); | 1087 IndentedScope indent(this, Token::Name(node->op()), node); |
| 1087 Visit(node->left()); | 1088 Visit(node->left()); |
| 1088 Visit(node->right()); | 1089 Visit(node->right()); |
| 1089 } | 1090 } |
| 1090 | 1091 |
| 1091 | 1092 |
| 1092 void AstPrinter::VisitCompareToNull(CompareToNull* node) { | 1093 void AstPrinter::VisitCompareToNull(CompareToNull* node) { |
| 1093 const char* name = node->is_strict() | 1094 const char* name = node->is_strict() |
| 1094 ? "COMPARE-TO-NULL-STRICT" | 1095 ? "COMPARE-TO-NULL-STRICT" |
| 1095 : "COMPARE-TO-NULL"; | 1096 : "COMPARE-TO-NULL"; |
| 1096 IndentedScope indent(name, node); | 1097 IndentedScope indent(this, name, node); |
| 1097 Visit(node->expression()); | 1098 Visit(node->expression()); |
| 1098 } | 1099 } |
| 1099 | 1100 |
| 1100 | 1101 |
| 1101 void AstPrinter::VisitThisFunction(ThisFunction* node) { | 1102 void AstPrinter::VisitThisFunction(ThisFunction* node) { |
| 1102 IndentedScope indent("THIS-FUNCTION"); | 1103 IndentedScope indent(this, "THIS-FUNCTION"); |
| 1103 } | 1104 } |
| 1104 | 1105 |
| 1105 | 1106 |
| 1106 TagScope::TagScope(JsonAstBuilder* builder, const char* name) | 1107 TagScope::TagScope(JsonAstBuilder* builder, const char* name) |
| 1107 : builder_(builder), next_(builder->tag()), has_body_(false) { | 1108 : builder_(builder), next_(builder->tag()), has_body_(false) { |
| 1108 if (next_ != NULL) { | 1109 if (next_ != NULL) { |
| 1109 next_->use(); | 1110 next_->use(); |
| 1110 builder->Print(",\n"); | 1111 builder->Print(",\n"); |
| 1111 } | 1112 } |
| 1112 builder->set_tag(this); | 1113 builder->set_tag(this); |
| (...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1520 AddAttribute("mode", Variable::Mode2String(decl->mode())); | 1521 AddAttribute("mode", Variable::Mode2String(decl->mode())); |
| 1521 } | 1522 } |
| 1522 Visit(decl->proxy()); | 1523 Visit(decl->proxy()); |
| 1523 if (decl->fun() != NULL) Visit(decl->fun()); | 1524 if (decl->fun() != NULL) Visit(decl->fun()); |
| 1524 } | 1525 } |
| 1525 | 1526 |
| 1526 | 1527 |
| 1527 #endif // DEBUG | 1528 #endif // DEBUG |
| 1528 | 1529 |
| 1529 } } // namespace v8::internal | 1530 } } // namespace v8::internal |
| OLD | NEW |