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

Side by Side Diff: src/prettyprinter.cc

Issue 9348057: Split AST Declaration class, in preparation for new module declaration forms. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed Jakob's comments. Created 8 years, 10 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/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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 51
52 52
53 void PrettyPrinter::VisitBlock(Block* node) { 53 void PrettyPrinter::VisitBlock(Block* node) {
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::VisitDeclaration(Declaration* 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) { 64 if (node->fun() != NULL) {
65 Print(" = "); 65 Print(" = ");
66 PrintFunctionLiteral(node->fun()); 66 PrintFunctionLiteral(node->fun());
67 } 67 }
68 Print(";"); 68 Print(";");
69 } 69 }
70 70
71 71
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 } 704 }
705 705
706 706
707 void AstPrinter::VisitBlock(Block* node) { 707 void AstPrinter::VisitBlock(Block* node) {
708 const char* block_txt = node->is_initializer_block() ? "BLOCK INIT" : "BLOCK"; 708 const char* block_txt = node->is_initializer_block() ? "BLOCK INIT" : "BLOCK";
709 IndentedScope indent(this, block_txt); 709 IndentedScope indent(this, block_txt);
710 PrintStatements(node->statements()); 710 PrintStatements(node->statements());
711 } 711 }
712 712
713 713
714 void AstPrinter::VisitDeclaration(Declaration* node) { 714 void AstPrinter::VisitVariableDeclaration(VariableDeclaration* node) {
715 if (node->fun() == NULL) { 715 if (node->fun() == NULL) {
716 // var or const declarations 716 // var or const declarations
717 PrintLiteralWithModeIndented(Variable::Mode2String(node->mode()), 717 PrintLiteralWithModeIndented(Variable::Mode2String(node->mode()),
718 node->proxy()->var(), 718 node->proxy()->var(),
719 node->proxy()->name()); 719 node->proxy()->name());
720 } else { 720 } else {
721 // function declarations 721 // function declarations
722 PrintIndented("FUNCTION "); 722 PrintIndented("FUNCTION ");
723 PrintLiteral(node->proxy()->name(), true); 723 PrintLiteral(node->proxy()->name(), true);
724 Print(" = function "); 724 Print(" = function ");
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
1014 } 1014 }
1015 1015
1016 1016
1017 void AstPrinter::VisitThisFunction(ThisFunction* node) { 1017 void AstPrinter::VisitThisFunction(ThisFunction* node) {
1018 IndentedScope indent(this, "THIS-FUNCTION"); 1018 IndentedScope indent(this, "THIS-FUNCTION");
1019 } 1019 }
1020 1020
1021 #endif // DEBUG 1021 #endif // DEBUG
1022 1022
1023 } } // namespace v8::internal 1023 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/parser.cc ('k') | src/rewriter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698