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

Unified Diff: src/prettyprinter.cc

Issue 561913002: Class syntax parsing (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: git rebase Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/prettyprinter.h ('k') | src/scanner.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/prettyprinter.cc
diff --git a/src/prettyprinter.cc b/src/prettyprinter.cc
index 0f5d225b650437e99d3e69ac120c8ce467a4ea86..1ff2edd2854adbdeab29b753bc3ba1c0119dba60 100644
--- a/src/prettyprinter.cc
+++ b/src/prettyprinter.cc
@@ -289,6 +289,21 @@ void PrettyPrinter::VisitFunctionLiteral(FunctionLiteral* node) {
}
+void PrettyPrinter::VisitClassLiteral(ClassLiteral* node) {
+ Print("(class ");
+ PrintLiteral(node->name(), false);
+ if (node->extends()) {
+ Print(" extends ");
+ Visit(node->extends());
+ }
+ Print(" { ");
+ for (int i = 0; i < node->properties()->length(); i++) {
+ PrintObjectLiteralProperty(node->properties()->at(i));
+ }
+ Print(" })");
+}
+
+
void PrettyPrinter::VisitNativeFunctionLiteral(NativeFunctionLiteral* node) {
Print("(");
PrintLiteral(node->name(), false);
@@ -323,16 +338,22 @@ void PrettyPrinter::VisitObjectLiteral(ObjectLiteral* node) {
Print("{ ");
for (int i = 0; i < node->properties()->length(); i++) {
if (i != 0) Print(",");
- ObjectLiteral::Property* property = node->properties()->at(i);
- Print(" ");
- Visit(property->key());
- Print(": ");
- Visit(property->value());
+ PrintObjectLiteralProperty(node->properties()->at(i));
}
Print(" }");
}
+void PrettyPrinter::PrintObjectLiteralProperty(
+ ObjectLiteralProperty* property) {
+ // TODO(arv): Better printing of methods etc.
+ Print(" ");
+ Visit(property->key());
+ Print(": ");
+ Visit(property->value());
+}
+
+
void PrettyPrinter::VisitArrayLiteral(ArrayLiteral* node) {
Print("[ ");
for (int i = 0; i < node->values()->length(); i++) {
@@ -969,6 +990,12 @@ void AstPrinter::VisitFunctionLiteral(FunctionLiteral* node) {
}
+void AstPrinter::VisitClassLiteral(ClassLiteral* node) {
+ IndentedScope indent(this, "CLASS LITERAL");
+ PrintLiteralIndented("NAME", node->name(), false);
+}
+
+
void AstPrinter::VisitNativeFunctionLiteral(NativeFunctionLiteral* node) {
IndentedScope indent(this, "NATIVE FUNC LITERAL");
PrintLiteralIndented("NAME", node->name(), false);
« no previous file with comments | « src/prettyprinter.h ('k') | src/scanner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698