| Index: src/prettyprinter.cc
|
| diff --git a/src/prettyprinter.cc b/src/prettyprinter.cc
|
| index 0f5d225b650437e99d3e69ac120c8ce467a4ea86..e1af892884bb4001258d392e06454dac94486283 100644
|
| --- a/src/prettyprinter.cc
|
| +++ b/src/prettyprinter.cc
|
| @@ -53,6 +53,15 @@ void PrettyPrinter::VisitFunctionDeclaration(FunctionDeclaration* node) {
|
| }
|
|
|
|
|
| +void PrettyPrinter::VisitClassDeclaration(ClassDeclaration* node) {
|
| + Print("class ");
|
| + PrintLiteral(node->proxy()->name(), false);
|
| + Print(" = ");
|
| + PrintClassLiteral(node->classLiteral());
|
| + Print(";");
|
| +}
|
| +
|
| +
|
| void PrettyPrinter::VisitModuleDeclaration(ModuleDeclaration* node) {
|
| Print("module ");
|
| PrintLiteral(node->proxy()->name(), false);
|
| @@ -289,6 +298,13 @@ void PrettyPrinter::VisitFunctionLiteral(FunctionLiteral* node) {
|
| }
|
|
|
|
|
| +void PrettyPrinter::VisitClassLiteral(ClassLiteral* node) {
|
| + Print("(");
|
| + PrintClassLiteral(node);
|
| + Print(")");
|
| +}
|
| +
|
| +
|
| void PrettyPrinter::VisitNativeFunctionLiteral(NativeFunctionLiteral* node) {
|
| Print("(");
|
| PrintLiteral(node->name(), false);
|
| @@ -323,16 +339,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++) {
|
| @@ -622,6 +644,21 @@ void PrettyPrinter::PrintFunctionLiteral(FunctionLiteral* function) {
|
| }
|
|
|
|
|
| +void PrettyPrinter::PrintClassLiteral(ClassLiteral* class_literal) {
|
| + Print("class ");
|
| + PrintLiteral(class_literal->name(), false);
|
| + if (class_literal->extends()) {
|
| + Print(" extends ");
|
| + Visit(class_literal->extends());
|
| + }
|
| + Print(" { ");
|
| + for (int i = 0; i < class_literal->properties()->length(); i++) {
|
| + PrintObjectLiteralProperty(class_literal->properties()->at(i));
|
| + }
|
| + Print(" }");
|
| +}
|
| +
|
| +
|
| //-----------------------------------------------------------------------------
|
|
|
| class IndentedScope BASE_EMBEDDED {
|
| @@ -774,6 +811,15 @@ void AstPrinter::VisitFunctionDeclaration(FunctionDeclaration* node) {
|
| }
|
|
|
|
|
| +void AstPrinter::VisitClassDeclaration(ClassDeclaration* node) {
|
| + PrintIndented("CLASS ");
|
| + PrintLiteral(node->proxy()->name(), true);
|
| + Print(" = class ");
|
| + PrintLiteral(node->classLiteral()->name(), false);
|
| + Print("\n");
|
| +}
|
| +
|
| +
|
| void AstPrinter::VisitModuleDeclaration(ModuleDeclaration* node) {
|
| IndentedScope indent(this, "MODULE");
|
| PrintLiteralIndented("NAME", node->proxy()->name(), true);
|
| @@ -969,6 +1015,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);
|
|
|