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

Unified Diff: src/property.cc

Issue 2627003005: [printing] Remove duplicate code that prints property details. (Closed)
Patch Set: Created 3 years, 11 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/property.h ('k') | src/property-details.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/property.cc
diff --git a/src/property.cc b/src/property.cc
index d5848bf44c0278c351a6421dd3e8ce51b15fce83..564d5548c4770a1c5b11e66f82e46e63b52ec504 100644
--- a/src/property.cc
+++ b/src/property.cc
@@ -29,66 +29,49 @@ Descriptor Descriptor::DataField(Handle<Name> key, int field_index,
representation, field_index);
}
-struct FastPropertyDetails {
- explicit FastPropertyDetails(const PropertyDetails& v) : details(v) {}
- const PropertyDetails details;
-};
-
-
// Outputs PropertyDetails as a dictionary details.
-std::ostream& operator<<(std::ostream& os, const PropertyDetails& details) {
+void PropertyDetails::PrintAsSlowTo(std::ostream& os) {
os << "(";
- if (details.location() == kDescriptor) {
- os << "immutable ";
- }
- os << (details.kind() == kData ? "data" : "accessor");
- return os << ", dictionary_index: " << details.dictionary_index()
- << ", attrs: " << details.attributes() << ")";
+ os << (kind() == kData ? "data" : "accessor");
+ os << ", dictionary_index: " << dictionary_index();
+ os << ", attrs: " << attributes() << ")";
}
-
// Outputs PropertyDetails as a descriptor array details.
-std::ostream& operator<<(std::ostream& os,
- const FastPropertyDetails& details_fast) {
- const PropertyDetails& details = details_fast.details;
+void PropertyDetails::PrintAsFastTo(std::ostream& os, PrintMode mode) {
os << "(";
- if (details.location() == kDescriptor) {
- os << "immutable ";
+ os << (kind() == kData ? "data" : "accessor");
+ if (location() == kField) {
+ os << " field";
+ if (mode & kPrintFieldIndex) {
+ os << " " << field_index();
+ }
+ if (mode & kPrintRepresentation) {
+ os << ":" << representation().Mnemonic();
Jakob Kummerow 2017/01/12 15:53:20 nit: might want a space after ':'
Igor Sheludko 2017/01/12 15:56:00 It looks better without a space.
+ }
+ } else {
+ os << " descriptor";
+ }
+ if (mode & kPrintPointer) {
+ os << ", p: " << pointer();
}
- os << (details.kind() == kData ? "data" : "accessor");
- os << ": " << details.representation().Mnemonic();
- if (details.location() == kField) {
- os << ", field_index: " << details.field_index();
+ if (mode & kPrintAttributes) {
+ os << ", attrs: " << attributes();
}
- return os << ", p: " << details.pointer()
- << ", attrs: " << details.attributes() << ")";
+ os << ")";
}
-
#ifdef OBJECT_PRINT
void PropertyDetails::Print(bool dictionary_mode) {
OFStream os(stdout);
if (dictionary_mode) {
- os << *this;
+ PrintAsSlowTo(os);
} else {
- os << FastPropertyDetails(*this);
+ PrintAsFastTo(os, PrintMode::kPrintFull);
}
os << "\n" << std::flush;
}
#endif
-
-std::ostream& operator<<(std::ostream& os, const Descriptor& d) {
- Object* value = *d.GetValue();
- os << "Descriptor " << Brief(*d.GetKey()) << " @ " << Brief(value) << " ";
- if (value->IsAccessorPair()) {
- AccessorPair* pair = AccessorPair::cast(value);
- os << "(get: " << Brief(pair->getter())
- << ", set: " << Brief(pair->setter()) << ") ";
- }
- os << FastPropertyDetails(d.GetDetails());
- return os;
-}
-
} // namespace internal
} // namespace v8
« no previous file with comments | « src/property.h ('k') | src/property-details.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698