Chromium Code Reviews| 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) { |
|
arv (Not doing code reviews)
2014/09/12 21:36:34
When is the PrettyPrinter used? I don't see any te
rossberg
2014/09/15 12:32:49
Good question...
|
| + 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); |