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

Unified Diff: src/prettyprinter.cc

Issue 1165613003: Fix issue with --print-ast and class expressions (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Removed default case Created 5 years, 7 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') | no next file » | 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 3a476575718d4dbfb83388252886dfdc2c8b676c..160bb6f549b4414a55ca37903de7baf8665c86b4 100644
--- a/src/prettyprinter.cc
+++ b/src/prettyprinter.cc
@@ -1321,7 +1321,48 @@ void AstPrinter::VisitFunctionLiteral(FunctionLiteral* node) {
void AstPrinter::VisitClassLiteral(ClassLiteral* node) {
IndentedScope indent(this, "CLASS LITERAL");
- PrintLiteralIndented("NAME", node->name(), false);
+ if (node->raw_name() != nullptr) {
+ PrintLiteralIndented("NAME", node->name(), false);
+ }
+ if (node->extends() != nullptr) {
+ PrintIndentedVisit("EXTENDS", node->extends());
+ }
+ PrintProperties(node->properties());
+}
+
+
+void AstPrinter::PrintProperties(
+ ZoneList<ObjectLiteral::Property*>* properties) {
+ for (int i = 0; i < properties->length(); i++) {
+ ObjectLiteral::Property* property = properties->at(i);
+ const char* prop_kind = nullptr;
+ switch (property->kind()) {
+ case ObjectLiteral::Property::CONSTANT:
+ prop_kind = "CONSTANT";
+ break;
+ case ObjectLiteral::Property::COMPUTED:
+ prop_kind = "COMPUTED";
+ break;
+ case ObjectLiteral::Property::MATERIALIZED_LITERAL:
+ prop_kind = "MATERIALIZED_LITERAL";
+ break;
+ case ObjectLiteral::Property::PROTOTYPE:
+ prop_kind = "PROTOTYPE";
+ break;
+ case ObjectLiteral::Property::GETTER:
+ prop_kind = "GETTER";
+ break;
+ case ObjectLiteral::Property::SETTER:
+ prop_kind = "SETTER";
+ break;
+ }
+ EmbeddedVector<char, 128> buf;
+ SNPrintF(buf, "PROPERTY%s - %s", property->is_static() ? " - STATIC" : "",
+ prop_kind);
+ IndentedScope prop(this, buf.start());
+ PrintIndentedVisit("KEY", properties->at(i)->key());
+ PrintIndentedVisit("VALUE", properties->at(i)->value());
+ }
}
@@ -1354,34 +1395,7 @@ void AstPrinter::VisitRegExpLiteral(RegExpLiteral* node) {
void AstPrinter::VisitObjectLiteral(ObjectLiteral* node) {
IndentedScope indent(this, "OBJ LITERAL");
- for (int i = 0; i < node->properties()->length(); i++) {
- const char* prop_kind = NULL;
- switch (node->properties()->at(i)->kind()) {
- case ObjectLiteral::Property::CONSTANT:
- prop_kind = "PROPERTY - CONSTANT";
- break;
- case ObjectLiteral::Property::COMPUTED:
- prop_kind = "PROPERTY - COMPUTED";
- break;
- case ObjectLiteral::Property::MATERIALIZED_LITERAL:
- prop_kind = "PROPERTY - MATERIALIZED_LITERAL";
- break;
- case ObjectLiteral::Property::PROTOTYPE:
- prop_kind = "PROPERTY - PROTOTYPE";
- break;
- case ObjectLiteral::Property::GETTER:
- prop_kind = "PROPERTY - GETTER";
- break;
- case ObjectLiteral::Property::SETTER:
- prop_kind = "PROPERTY - SETTER";
- break;
- default:
- UNREACHABLE();
- }
- IndentedScope prop(this, prop_kind);
- PrintIndentedVisit("KEY", node->properties()->at(i)->key());
- PrintIndentedVisit("VALUE", node->properties()->at(i)->value());
- }
+ PrintProperties(node->properties());
}
« no previous file with comments | « src/prettyprinter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698