Minor clean-up of Type::Print
R=verwaest@chromium.org BUG= Review URL: https://codereview.chromium.org/75423002 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@18010 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
709010dead
commit
6aec0d39ae
46
src/types.cc
46
src/types.cc
@ -525,25 +525,35 @@ void Type::TypePrint() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const char* Type::bitset_name(int bitset) {
|
||||||
|
switch (bitset) {
|
||||||
|
#define PRINT_COMPOSED_TYPE(type, value) case k##type: return #type;
|
||||||
|
BITSET_TYPE_LIST(PRINT_COMPOSED_TYPE)
|
||||||
|
#undef PRINT_COMPOSED_TYPE
|
||||||
|
default:
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Type::TypePrint(FILE* out) {
|
void Type::TypePrint(FILE* out) {
|
||||||
if (is_bitset()) {
|
if (is_bitset()) {
|
||||||
int val = as_bitset();
|
int bitset = as_bitset();
|
||||||
const char* composed_name = GetComposedName(val);
|
const char* name = bitset_name(bitset);
|
||||||
if (composed_name != NULL) {
|
if (name != NULL) {
|
||||||
PrintF(out, "%s", composed_name);
|
PrintF(out, "%s", name);
|
||||||
return;
|
} else {
|
||||||
}
|
bool is_first = true;
|
||||||
bool first_entry = true;
|
PrintF(out, "(");
|
||||||
PrintF(out, "{");
|
for (int mask = 1; mask != 0; mask = mask << 1) {
|
||||||
for (unsigned i = 0; i < sizeof(val)*8; ++i) {
|
if ((bitset & mask) != 0) {
|
||||||
int mask = (1 << i);
|
if (!is_first) PrintF(out, " | ");
|
||||||
if ((val & mask) != 0) {
|
is_first = false;
|
||||||
if (!first_entry) PrintF(out, ",");
|
PrintF(out, "%s", bitset_name(mask));
|
||||||
first_entry = false;
|
}
|
||||||
PrintF(out, "%s", GetPrimitiveName(mask));
|
|
||||||
}
|
}
|
||||||
|
PrintF(out, ")");
|
||||||
}
|
}
|
||||||
PrintF(out, "}");
|
|
||||||
} else if (is_constant()) {
|
} else if (is_constant()) {
|
||||||
PrintF(out, "Constant(%p : ", static_cast<void*>(*as_constant()));
|
PrintF(out, "Constant(%p : ", static_cast<void*>(*as_constant()));
|
||||||
from_bitset(LubBitset())->TypePrint(out);
|
from_bitset(LubBitset())->TypePrint(out);
|
||||||
@ -553,14 +563,14 @@ void Type::TypePrint(FILE* out) {
|
|||||||
from_bitset(LubBitset())->TypePrint(out);
|
from_bitset(LubBitset())->TypePrint(out);
|
||||||
PrintF(")");
|
PrintF(")");
|
||||||
} else if (is_union()) {
|
} else if (is_union()) {
|
||||||
PrintF(out, "{");
|
PrintF(out, "(");
|
||||||
Handle<Unioned> unioned = as_union();
|
Handle<Unioned> unioned = as_union();
|
||||||
for (int i = 0; i < unioned->length(); ++i) {
|
for (int i = 0; i < unioned->length(); ++i) {
|
||||||
Handle<Type> type_i = union_get(unioned, i);
|
Handle<Type> type_i = union_get(unioned, i);
|
||||||
if (i > 0) PrintF(out, ",");
|
if (i > 0) PrintF(out, " | ");
|
||||||
type_i->TypePrint(out);
|
type_i->TypePrint(out);
|
||||||
}
|
}
|
||||||
PrintF(out, "}");
|
PrintF(out, ")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
40
src/types.h
40
src/types.h
@ -95,7 +95,7 @@ namespace internal {
|
|||||||
// a concurrent compilation context.
|
// a concurrent compilation context.
|
||||||
|
|
||||||
|
|
||||||
#define PRIMITIVE_TYPE_LIST(V) \
|
#define BITSET_TYPE_LIST(V) \
|
||||||
V(None, 0) \
|
V(None, 0) \
|
||||||
V(Null, 1 << 0) \
|
V(Null, 1 << 0) \
|
||||||
V(Undefined, 1 << 1) \
|
V(Undefined, 1 << 1) \
|
||||||
@ -113,9 +113,8 @@ namespace internal {
|
|||||||
V(RegExp, 1 << 13) \
|
V(RegExp, 1 << 13) \
|
||||||
V(OtherObject, 1 << 14) \
|
V(OtherObject, 1 << 14) \
|
||||||
V(Proxy, 1 << 15) \
|
V(Proxy, 1 << 15) \
|
||||||
V(Internal, 1 << 16)
|
V(Internal, 1 << 16) \
|
||||||
|
\
|
||||||
#define COMPOSED_TYPE_LIST(V) \
|
|
||||||
V(Oddball, kBoolean | kNull | kUndefined) \
|
V(Oddball, kBoolean | kNull | kUndefined) \
|
||||||
V(Signed32, kSmi | kOtherSigned32) \
|
V(Signed32, kSmi | kOtherSigned32) \
|
||||||
V(Number, kSigned32 | kUnsigned32 | kDouble) \
|
V(Number, kSigned32 | kUnsigned32 | kDouble) \
|
||||||
@ -131,17 +130,12 @@ namespace internal {
|
|||||||
V(NonNumber, kAny - kNumber) \
|
V(NonNumber, kAny - kNumber) \
|
||||||
V(Detectable, kAllocated - kUndetectable)
|
V(Detectable, kAllocated - kUndetectable)
|
||||||
|
|
||||||
#define TYPE_LIST(V) \
|
|
||||||
PRIMITIVE_TYPE_LIST(V) \
|
|
||||||
COMPOSED_TYPE_LIST(V)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Type : public Object {
|
class Type : public Object {
|
||||||
public:
|
public:
|
||||||
#define DEFINE_TYPE_CONSTRUCTOR(type, value) \
|
#define DEFINE_TYPE_CONSTRUCTOR(type, value) \
|
||||||
static Type* type() { return from_bitset(k##type); }
|
static Type* type() { return from_bitset(k##type); }
|
||||||
TYPE_LIST(DEFINE_TYPE_CONSTRUCTOR)
|
BITSET_TYPE_LIST(DEFINE_TYPE_CONSTRUCTOR)
|
||||||
#undef DEFINE_TYPE_CONSTRUCTOR
|
#undef DEFINE_TYPE_CONSTRUCTOR
|
||||||
|
|
||||||
static Type* Class(Handle<i::Map> map) { return from_handle(map); }
|
static Type* Class(Handle<i::Map> map) { return from_handle(map); }
|
||||||
@ -226,7 +220,7 @@ class Type : public Object {
|
|||||||
|
|
||||||
enum {
|
enum {
|
||||||
#define DECLARE_TYPE(type, value) k##type = (value),
|
#define DECLARE_TYPE(type, value) k##type = (value),
|
||||||
TYPE_LIST(DECLARE_TYPE)
|
BITSET_TYPE_LIST(DECLARE_TYPE)
|
||||||
#undef DECLARE_TYPE
|
#undef DECLARE_TYPE
|
||||||
kUnusedEOL = 0
|
kUnusedEOL = 0
|
||||||
};
|
};
|
||||||
@ -277,29 +271,7 @@ class Type : public Object {
|
|||||||
int ExtendIntersection(
|
int ExtendIntersection(
|
||||||
Handle<Unioned> unioned, Handle<Type> type, int current_size);
|
Handle<Unioned> unioned, Handle<Type> type, int current_size);
|
||||||
|
|
||||||
static const char* GetComposedName(int type) {
|
static const char* bitset_name(int bitset);
|
||||||
switch (type) {
|
|
||||||
#define PRINT_COMPOSED_TYPE(type, value) \
|
|
||||||
case k##type: \
|
|
||||||
return # type;
|
|
||||||
COMPOSED_TYPE_LIST(PRINT_COMPOSED_TYPE)
|
|
||||||
#undef PRINT_COMPOSED_TYPE
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const char* GetPrimitiveName(int type) {
|
|
||||||
switch (type) {
|
|
||||||
#define PRINT_PRIMITIVE_TYPE(type, value) \
|
|
||||||
case k##type: \
|
|
||||||
return # type;
|
|
||||||
PRIMITIVE_TYPE_LIST(PRINT_PRIMITIVE_TYPE)
|
|
||||||
#undef PRINT_PRIMITIVE_TYPE
|
|
||||||
default:
|
|
||||||
UNREACHABLE();
|
|
||||||
return "InvalidType";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user