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
|
|
|
|
2011-10-18 11:18:55 +00:00
|
|
|
void LookupResult::Iterate(ObjectVisitor* visitor) {
|
|
|
|
LookupResult* current = this; // Could be NULL.
|
|
|
|
while (current != NULL) {
|
2014-09-08 09:11:11 +00:00
|
|
|
visitor->VisitPointer(bit_cast<Object**>(¤t->holder_));
|
|
|
|
visitor->VisitPointer(bit_cast<Object**>(¤t->transition_));
|
2011-10-18 11:18:55 +00:00
|
|
|
current = current->next_;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-30 10:29:32 +00:00
|
|
|
std::ostream& operator<<(std::ostream& os, const LookupResult& r) {
|
2014-07-07 09:57:29 +00:00
|
|
|
if (!r.IsFound()) return os << "Not Found\n";
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2014-07-03 07:18:30 +00:00
|
|
|
os << "LookupResult:\n";
|
2014-07-07 09:57:29 +00:00
|
|
|
if (r.IsTransition()) {
|
|
|
|
os << " -transition target:\n" << Brief(r.GetTransitionTarget()) << "\n";
|
2014-04-15 07:36:47 +00:00
|
|
|
}
|
2014-07-07 09:57:29 +00:00
|
|
|
return os;
|
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");
|
|
|
|
if (details.location() == kField) {
|
2014-12-16 13:22:23 +00:00
|
|
|
os << ": " << details.representation().Mnemonic()
|
|
|
|
<< ", field_index: " << details.field_index();
|
|
|
|
}
|
|
|
|
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
|