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

Side by Side Diff: src/prettyprinter.cc

Issue 9460064: Further refactoring of declarations in the AST: (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 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
« src/ast.h ('K') | « src/parser.cc ('k') | src/rewriter.cc » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 if (!node->is_initializer_block()) Print("{ "); 54 if (!node->is_initializer_block()) Print("{ ");
55 PrintStatements(node->statements()); 55 PrintStatements(node->statements());
56 if (node->statements()->length() > 0) Print(" "); 56 if (node->statements()->length() > 0) Print(" ");
57 if (!node->is_initializer_block()) Print("}"); 57 if (!node->is_initializer_block()) Print("}");
58 } 58 }
59 59
60 60
61 void PrettyPrinter::VisitVariableDeclaration(VariableDeclaration* node) { 61 void PrettyPrinter::VisitVariableDeclaration(VariableDeclaration* node) {
62 Print("var "); 62 Print("var ");
63 PrintLiteral(node->proxy()->name(), false); 63 PrintLiteral(node->proxy()->name(), false);
64 if (node->fun() != NULL) {
65 Print(" = ");
66 PrintFunctionLiteral(node->fun());
67 }
68 Print(";"); 64 Print(";");
69 } 65 }
70 66
67
68 void PrettyPrinter::VisitFunctionDeclaration(FunctionDeclaration* node) {
69 Print("function ");
70 PrintLiteral(node->proxy()->name(), false);
71 Print(" = ");
72 PrintFunctionLiteral(node->fun());
73 Print(";");
74 }
75
71 76
72 void PrettyPrinter::VisitModuleDeclaration(ModuleDeclaration* node) { 77 void PrettyPrinter::VisitModuleDeclaration(ModuleDeclaration* node) {
73 Print("module "); 78 Print("module ");
74 PrintLiteral(node->proxy()->name(), false); 79 PrintLiteral(node->proxy()->name(), false);
75 Print(" = "); 80 Print(" = ");
76 Visit(node->module()); 81 Visit(node->module());
77 Print(";"); 82 Print(";");
78 } 83 }
79 84
80 85
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after
737 742
738 743
739 void AstPrinter::VisitBlock(Block* node) { 744 void AstPrinter::VisitBlock(Block* node) {
740 const char* block_txt = node->is_initializer_block() ? "BLOCK INIT" : "BLOCK"; 745 const char* block_txt = node->is_initializer_block() ? "BLOCK INIT" : "BLOCK";
741 IndentedScope indent(this, block_txt); 746 IndentedScope indent(this, block_txt);
742 PrintStatements(node->statements()); 747 PrintStatements(node->statements());
743 } 748 }
744 749
745 750
746 void AstPrinter::VisitVariableDeclaration(VariableDeclaration* node) { 751 void AstPrinter::VisitVariableDeclaration(VariableDeclaration* node) {
747 if (node->fun() == NULL) { 752 PrintLiteralWithModeIndented(Variable::Mode2String(node->mode()),
748 // var or const declarations 753 node->proxy()->var(),
749 PrintLiteralWithModeIndented(Variable::Mode2String(node->mode()), 754 node->proxy()->name());
750 node->proxy()->var(),
751 node->proxy()->name());
752 } else {
753 // function declarations
754 PrintIndented("FUNCTION ");
755 PrintLiteral(node->proxy()->name(), true);
756 Print(" = function ");
757 PrintLiteral(node->fun()->name(), false);
758 Print("\n");
759 }
760 } 755 }
761 756
762 757
758 void AstPrinter::VisitFunctionDeclaration(FunctionDeclaration* node) {
759 PrintIndented("FUNCTION ");
760 PrintLiteral(node->proxy()->name(), true);
761 Print(" = function ");
762 PrintLiteral(node->fun()->name(), false);
763 Print("\n");
764 }
765
766
763 void AstPrinter::VisitModuleDeclaration(ModuleDeclaration* node) { 767 void AstPrinter::VisitModuleDeclaration(ModuleDeclaration* node) {
764 IndentedScope indent(this, "MODULE"); 768 IndentedScope indent(this, "MODULE");
765 PrintLiteralIndented("NAME", node->proxy()->name(), true); 769 PrintLiteralIndented("NAME", node->proxy()->name(), true);
766 Visit(node->module()); 770 Visit(node->module());
767 } 771 }
768 772
769 773
770 void AstPrinter::VisitModuleLiteral(ModuleLiteral* node) { 774 void AstPrinter::VisitModuleLiteral(ModuleLiteral* node) {
771 VisitBlock(node->body()); 775 VisitBlock(node->body());
772 } 776 }
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
1075 } 1079 }
1076 1080
1077 1081
1078 void AstPrinter::VisitThisFunction(ThisFunction* node) { 1082 void AstPrinter::VisitThisFunction(ThisFunction* node) {
1079 IndentedScope indent(this, "THIS-FUNCTION"); 1083 IndentedScope indent(this, "THIS-FUNCTION");
1080 } 1084 }
1081 1085
1082 #endif // DEBUG 1086 #endif // DEBUG
1083 1087
1084 } } // namespace v8::internal 1088 } } // namespace v8::internal
OLDNEW
« src/ast.h ('K') | « src/parser.cc ('k') | src/rewriter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698