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

Unified Diff: src/ast/prettyprinter.cc

Issue 2302643002: Split the AST representation of class properties from object properties (Closed)
Patch Set: rebase Created 4 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/ast/prettyprinter.h ('k') | src/compiler/ast-graph-builder.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ast/prettyprinter.cc
diff --git a/src/ast/prettyprinter.cc b/src/ast/prettyprinter.cc
index a411b7066af3cfdb3b9e471506ab13ad7ea246f0..944cfaa92902e04153825e7ea45b758db2a14098 100644
--- a/src/ast/prettyprinter.cc
+++ b/src/ast/prettyprinter.cc
@@ -897,32 +897,22 @@ void AstPrinter::VisitClassLiteral(ClassLiteral* node) {
if (node->extends() != nullptr) {
PrintIndentedVisit("EXTENDS", node->extends());
}
- PrintProperties(node->properties());
+ PrintClassProperties(node->properties());
}
-
-void AstPrinter::PrintProperties(
- ZoneList<ObjectLiteral::Property*>* properties) {
+void AstPrinter::PrintClassProperties(
+ ZoneList<ClassLiteral::Property*>* properties) {
for (int i = 0; i < properties->length(); i++) {
- ObjectLiteral::Property* property = properties->at(i);
+ ClassLiteral::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";
+ case ClassLiteral::Property::METHOD:
+ prop_kind = "METHOD";
break;
- case ObjectLiteral::Property::GETTER:
+ case ClassLiteral::Property::GETTER:
prop_kind = "GETTER";
break;
- case ObjectLiteral::Property::SETTER:
+ case ClassLiteral::Property::SETTER:
prop_kind = "SETTER";
break;
}
@@ -986,7 +976,40 @@ void AstPrinter::VisitObjectLiteral(ObjectLiteral* node) {
EmbeddedVector<char, 128> buf;
SNPrintF(buf, "literal_index = %d\n", node->literal_index());
PrintIndented(buf.start());
- PrintProperties(node->properties());
+ PrintObjectProperties(node->properties());
+}
+
+void AstPrinter::PrintObjectProperties(
+ 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", prop_kind);
+ IndentedScope prop(this, buf.start());
+ PrintIndentedVisit("KEY", properties->at(i)->key());
+ PrintIndentedVisit("VALUE", properties->at(i)->value());
+ }
}
« no previous file with comments | « src/ast/prettyprinter.h ('k') | src/compiler/ast-graph-builder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698