2014-04-01 11:16:13 +00:00
|
|
|
// Copyright 2014 the V8 project authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2014-06-03 08:12:43 +00:00
|
|
|
#include "src/property.h"
|
2014-04-01 11:16:13 +00:00
|
|
|
|
2014-06-03 08:12:43 +00:00
|
|
|
#include "src/handles-inl.h"
|
2014-07-30 13:54:45 +00:00
|
|
|
#include "src/ostreams.h"
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2009-05-25 10:05:56 +00:00
|
|
|
namespace v8 {
|
|
|
|
namespace internal {
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2014-10-23 11:31:33 +00:00
|
|
|
std::ostream& operator<<(std::ostream& os,
|
|
|
|
const PropertyAttributes& attributes) {
|
|
|
|
os << "[";
|
|
|
|
os << (((attributes & READ_ONLY) == 0) ? "W" : "_"); // writable
|
|
|
|
os << (((attributes & DONT_ENUM) == 0) ? "E" : "_"); // enumerable
|
|
|
|
os << (((attributes & DONT_DELETE) == 0) ? "C" : "_"); // configurable
|
|
|
|
os << "]";
|
|
|
|
return os;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-11-19 11:45:17 +00:00
|
|
|
struct FastPropertyDetails {
|
|
|
|
explicit FastPropertyDetails(const PropertyDetails& v) : details(v) {}
|
|
|
|
const PropertyDetails details;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// Outputs PropertyDetails as a dictionary details.
|
2014-10-23 11:31:33 +00:00
|
|
|
std::ostream& operator<<(std::ostream& os, const PropertyDetails& details) {
|
|
|
|
os << "(";
|
2015-01-19 17:49:13 +00:00
|
|
|
if (details.location() == kDescriptor) {
|
2014-12-16 13:22:23 +00:00
|
|
|
os << "immutable ";
|
2014-11-19 11:45:17 +00:00
|
|
|
}
|
2015-01-19 17:49:13 +00:00
|
|
|
os << (details.kind() == kData ? "data" : "accessor");
|
2014-12-16 13:22:23 +00:00
|
|
|
return os << ", dictionary_index: " << details.dictionary_index()
|
2014-11-19 11:45:17 +00:00
|
|
|
<< ", attrs: " << details.attributes() << ")";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Outputs PropertyDetails as a descriptor array details.
|
|
|
|
std::ostream& operator<<(std::ostream& os,
|
|
|
|
const FastPropertyDetails& details_fast) {
|
|
|
|
const PropertyDetails& details = details_fast.details;
|
|
|
|
os << "(";
|
2015-01-19 17:49:13 +00:00
|
|
|
if (details.location() == kDescriptor) {
|
2014-12-16 13:22:23 +00:00
|
|
|
os << "immutable ";
|
2014-10-23 11:31:33 +00:00
|
|
|
}
|
2015-01-19 17:49:13 +00:00
|
|
|
os << (details.kind() == kData ? "data" : "accessor");
|
2015-02-16 15:25:33 +00:00
|
|
|
os << ": " << details.representation().Mnemonic();
|
2015-01-19 17:49:13 +00:00
|
|
|
if (details.location() == kField) {
|
2015-02-16 15:25:33 +00:00
|
|
|
os << ", field_index: " << details.field_index();
|
2014-12-16 13:22:23 +00:00
|
|
|
}
|
|
|
|
return os << ", p: " << details.pointer()
|
|
|
|
<< ", attrs: " << details.attributes() << ")";
|
2014-11-19 11:45:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef OBJECT_PRINT
|
|
|
|
void PropertyDetails::Print(bool dictionary_mode) {
|
|
|
|
OFStream os(stdout);
|
|
|
|
if (dictionary_mode) {
|
|
|
|
os << *this;
|
|
|
|
} else {
|
|
|
|
os << FastPropertyDetails(*this);
|
|
|
|
}
|
|
|
|
os << "\n" << std::flush;
|
2014-10-23 11:31:33 +00:00
|
|
|
}
|
2014-11-19 11:45:17 +00:00
|
|
|
#endif
|
2014-10-23 11:31:33 +00:00
|
|
|
|
|
|
|
|
2014-09-30 10:29:32 +00:00
|
|
|
std::ostream& operator<<(std::ostream& os, const Descriptor& d) {
|
2014-12-12 12:39:54 +00:00
|
|
|
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;
|
2008-07-03 15:10:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} } // namespace v8::internal
|