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

Unified Diff: src/types.h

Issue 18587007: Type::GetName() for printing types in debugger (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: rebase Created 7 years, 5 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 | « no previous file | src/types.cc » ('j') | src/types.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/types.h
diff --git a/src/types.h b/src/types.h
index 31aa9512f4c3a44433412fc836df800ea5efe524..bc6e580a7515b990cf8137ee5a27205a86117641 100644
--- a/src/types.h
+++ b/src/types.h
@@ -94,39 +94,54 @@ namespace internal {
// The type representation is heap-allocated, so cannot (currently) be used in
// a parallel compilation context.
+
+#define PRIMITIVE_TYPE_LIST(V) \
+ V(None, 0) \
+ V(Null, 1 << 0) \
+ V(Undefined, 1 << 1) \
+ V(Boolean, 1 << 2) \
+ V(Smi, 1 << 3) \
+ V(OtherSigned32, 1 << 4) \
+ V(Unsigned32, 1 << 5) \
+ V(Double, 1 << 6) \
+ V(Symbol, 1 << 7) \
+ V(InternalizedString, 1 << 8) \
+ V(OtherString, 1 << 9) \
+ V(Undetectable, 1 << 10) \
+ V(Array, 1 << 11) \
+ V(Function, 1 << 12) \
+ V(RegExp, 1 << 13) \
+ V(OtherObject, 1 << 14) \
+ V(Proxy, 1 << 15) \
+ V(Internal, 1 << 16)
+
+#define COMPOSED_TYPE_LIST(V) \
+ V(Oddball, kBoolean | kNull | kUndefined) \
+ V(Signed32, kSmi | kOtherSigned32) \
+ V(Number, kSigned32 | kUnsigned32 | kDouble) \
+ V(String, kInternalizedString | kOtherString) \
+ V(UniqueName, kSymbol | kInternalizedString) \
+ V(Name, kSymbol | kString) \
+ V(NumberOrString, kNumber | kString) \
+ V(Object, kUndetectable | kArray | kFunction | \
+ kRegExp | kOtherObject) \
+ V(Receiver, kObject | kProxy) \
+ V(Allocated, kDouble | kName | kReceiver) \
+ V(Any, kOddball | kNumber | kAllocated | kInternal) \
+ V(Detectable, kAllocated - kUndetectable)
+
+#define TYPE_LIST(V) \
+ PRIMITIVE_TYPE_LIST(V) \
+ COMPOSED_TYPE_LIST(V)
+
+
+
class Type : public Object {
public:
- static Type* None() { return from_bitset(kNone); }
- static Type* Any() { return from_bitset(kAny); }
- static Type* Allocated() { return from_bitset(kAllocated); }
- static Type* Detectable() { return from_bitset(kDetectable); }
-
- static Type* Oddball() { return from_bitset(kOddball); }
- static Type* Boolean() { return from_bitset(kBoolean); }
- static Type* Null() { return from_bitset(kNull); }
- static Type* Undefined() { return from_bitset(kUndefined); }
-
- static Type* Number() { return from_bitset(kNumber); }
- static Type* Smi() { return from_bitset(kSmi); }
- static Type* Signed32() { return from_bitset(kSigned32); }
- static Type* Unsigned32() { return from_bitset(kUnsigned32); }
- static Type* Double() { return from_bitset(kDouble); }
- static Type* NumberOrString() { return from_bitset(kNumberOrString); }
-
- static Type* Name() { return from_bitset(kName); }
- static Type* UniqueName() { return from_bitset(kUniqueName); }
- static Type* String() { return from_bitset(kString); }
- static Type* InternalizedString() { return from_bitset(kInternalizedString); }
- static Type* Symbol() { return from_bitset(kSymbol); }
-
- static Type* Receiver() { return from_bitset(kReceiver); }
- static Type* Object() { return from_bitset(kObject); }
- static Type* Undetectable() { return from_bitset(kUndetectable); }
- static Type* Array() { return from_bitset(kArray); }
- static Type* Function() { return from_bitset(kFunction); }
- static Type* RegExp() { return from_bitset(kRegExp); }
- static Type* Proxy() { return from_bitset(kProxy); }
- static Type* Internal() { return from_bitset(kInternal); }
+ #define DEFINE_TYPE_CONSTRUCTOR(type, value) \
+ static Type* type() { return from_bitset(k##type); }
+ TYPE_LIST(DEFINE_TYPE_CONSTRUCTOR)
+ #undef DEFINE_TYPE_CONSTRUCTOR
static Type* Class(Handle<Map> map) { return from_handle(map); }
static Type* Constant(Handle<HeapObject> value) {
@@ -191,6 +206,11 @@ class Type : public Object {
return t;
}
+#ifdef OBJECT_PRINT
+ void TypePrint();
+ void TypePrint(FILE* out);
+#endif
+
private:
// A union is a fixed array containing types. Invariants:
// - its length is at least 2
@@ -199,37 +219,10 @@ class Type : public Object {
typedef FixedArray Unioned;
enum {
- kNull = 1 << 0,
- kUndefined = 1 << 1,
- kBoolean = 1 << 2,
- kSmi = 1 << 3,
- kOtherSigned32 = 1 << 4,
- kUnsigned32 = 1 << 5,
- kDouble = 1 << 6,
- kSymbol = 1 << 7,
- kInternalizedString = 1 << 8,
- kOtherString = 1 << 9,
- kUndetectable = 1 << 10,
- kArray = 1 << 11,
- kFunction = 1 << 12,
- kRegExp = 1 << 13,
- kOtherObject = 1 << 14,
- kProxy = 1 << 15,
- kInternal = 1 << 16,
-
- kOddball = kBoolean | kNull | kUndefined,
- kSigned32 = kSmi | kOtherSigned32,
- kNumber = kSigned32 | kUnsigned32 | kDouble,
- kString = kInternalizedString | kOtherString,
- kUniqueName = kSymbol | kInternalizedString,
- kName = kSymbol | kString,
- kNumberOrString = kNumber | kString,
- kObject = kUndetectable | kArray | kFunction | kRegExp | kOtherObject,
- kReceiver = kObject | kProxy,
- kAllocated = kDouble | kName | kReceiver,
- kAny = kOddball | kNumber | kAllocated | kInternal,
- kDetectable = kAllocated - kUndetectable,
- kNone = 0
+ #define DECLARE_TYPE(type, value) k##type = (value),
+ TYPE_LIST(DECLARE_TYPE)
+ #undef DECLARE_TYPE
+ kUnusedEOL = 0
};
bool is_bitset() { return this->IsSmi(); }
@@ -272,6 +265,30 @@ class Type : public Object {
int ExtendUnion(Handle<Unioned> unioned, int current_size);
int ExtendIntersection(
Handle<Unioned> unioned, Handle<Type> type, int current_size);
+
+ static const char* GetComposedName(int type) {
+ 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";
+ }
+ }
};
} } // namespace v8::internal
« no previous file with comments | « no previous file | src/types.cc » ('j') | src/types.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698