Permalink
Browse files

Added type() function to TypeInfo class. Fixed TypeInfo_Const.next

  • Loading branch information...
1 parent 50a1148 commit 74713f7af496fd50fe4cfe60b3d9906b87efbdb6 @Ingrater committed Jul 8, 2012
View
@@ -87,6 +87,28 @@ struct OffsetTypeInfo
class TypeInfo
{
+ enum Type {
+ Info,
+ Native,
+ Vector,
+ Typedef,
+ Enum,
+ Pointer,
+ Array,
+ StaticArray,
+ AssociativeArray,
+ Function,
+ Delegate,
+ Class,
+ Interface,
+ Struct,
+ Tuple,
+ Const,
+ Immutable,
+ Shared,
+ Inout
+ }
+
hash_t getHash(in void* p);
equals_t equals(in void* p1, in void* p2);
int compare(in void* p1, in void* p2);
@@ -101,6 +123,7 @@ class TypeInfo
void postblit(void* p);
@property size_t talign() nothrow pure;
version (X86_64) int argTypes(out TypeInfo arg1, out TypeInfo arg2);
+ @property Type type() nothrow pure;
}
class TypeInfo_Typedef : TypeInfo
View
@@ -257,6 +257,28 @@ struct OffsetTypeInfo
*/
class TypeInfo
{
+ enum Type {
+ Info,
+ Native,
+ Vector,
+ Typedef,
+ Enum,
+ Pointer,
+ Array,
+ StaticArray,
+ AssociativeArray,
+ Function,
+ Delegate,
+ Class,
+ Interface,
+ Struct,
+ Tuple,
+ Const,
+ Immutable,
+ Shared,
+ Inout
+ }
+
override hash_t toHash()
{
auto data = this.toString();
@@ -345,6 +367,8 @@ class TypeInfo
{ arg1 = this;
return 0;
}
+
+ @property Type type() nothrow pure { return Type.Info; }
}
class TypeInfo_Vector : TypeInfo
@@ -375,6 +399,8 @@ class TypeInfo_Vector : TypeInfo
{ return base.argTypes(arg1, arg2);
}
+ @property override Type type() nothrow pure { return Type.Vector; }
+
TypeInfo base;
}
@@ -413,14 +439,16 @@ class TypeInfo_Typedef : TypeInfo
{ return base.argTypes(arg1, arg2);
}
+ @property override Type type() nothrow pure { return Type.Typedef; }
+
TypeInfo base;
string name;
void[] m_init;
}
class TypeInfo_Enum : TypeInfo_Typedef
{
-
+ @property override Type type() nothrow pure { return Type.Enum; }
}
class TypeInfo_Pointer : TypeInfo
@@ -473,6 +501,8 @@ class TypeInfo_Pointer : TypeInfo
@property override TypeInfo next() nothrow pure { return m_next; }
@property override uint flags() nothrow pure { return 1; }
+ @property override Type type() nothrow pure { return Type.Pointer; }
+
TypeInfo m_next;
}
@@ -553,6 +583,8 @@ class TypeInfo_Array : TypeInfo
return (void[]).alignof;
}
+ @property override Type type() nothrow pure { return Type.Array; }
+
version (X86_64) override int argTypes(out TypeInfo arg1, out TypeInfo arg2)
{ //arg1 = typeid(size_t);
//arg2 = typeid(void*);
@@ -675,6 +707,8 @@ class TypeInfo_StaticArray : TypeInfo
{ arg1 = typeid(void*);
return 0;
}
+
+ @property override Type type() nothrow pure { return Type.StaticArray; }
}
class TypeInfo_AssociativeArray : TypeInfo
@@ -717,6 +751,8 @@ class TypeInfo_AssociativeArray : TypeInfo
{ arg1 = typeid(void*);
return 0;
}
+
+ @property override Type type() nothrow pure { return Type.AssociativeArray; }
}
class TypeInfo_Function : TypeInfo
@@ -741,6 +777,8 @@ class TypeInfo_Function : TypeInfo
return 0; // no size for functions
}
+ @property override Type type() nothrow pure { return Type.Function; }
+
TypeInfo next;
string deco;
}
@@ -783,6 +821,8 @@ class TypeInfo_Delegate : TypeInfo
//arg2 = typeid(void*);
return 0;
}
+
+ @property override Type type() nothrow pure { return Type.Delegate; }
}
/**
@@ -928,6 +968,8 @@ class TypeInfo_Class : TypeInfo
return xgetMembers(name);
return null;
}
+
+ @property override Type type() nothrow pure { return Type.Class; }
}
alias TypeInfo_Class ClassInfo;
@@ -999,6 +1041,8 @@ class TypeInfo_Interface : TypeInfo
@property override uint flags() nothrow pure { return 1; }
+ @property override Type type() nothrow pure { return Type.Interface; }
+
TypeInfo_Class info;
}
@@ -1119,6 +1163,8 @@ class TypeInfo_Struct : TypeInfo
TypeInfo m_arg1;
TypeInfo m_arg2;
}
+
+ @property override Type type() nothrow pure { return Type.Struct; }
}
unittest
@@ -1216,6 +1262,8 @@ class TypeInfo_Tuple : TypeInfo
{
assert(0);
}
+
+ @property override Type type() nothrow pure { return Type.Tuple; }
}
class TypeInfo_Const : TypeInfo
@@ -1251,7 +1299,7 @@ class TypeInfo_Const : TypeInfo
@property override size_t tsize() nothrow pure { return base.tsize; }
override void swap(void *p1, void *p2) { return base.swap(p1, p2); }
- @property override TypeInfo next() nothrow pure { return base.next; }
+ @property override TypeInfo next() nothrow pure { return base; }
@property override uint flags() nothrow pure { return base.flags; }
override void[] init() nothrow pure { return base.init(); }
@@ -1261,6 +1309,8 @@ class TypeInfo_Const : TypeInfo
{ return base.argTypes(arg1, arg2);
}
+ @property override Type type() nothrow pure { return Type.Const; }
+
TypeInfo base;
}
@@ -1273,6 +1323,8 @@ class TypeInfo_Invariant : TypeInfo_Const
else
return cast(string) ("immutable(" ~ base.toString() ~ ")");
}
+
+ @property override Type type() nothrow pure { return Type.Immutable; }
}
class TypeInfo_Shared : TypeInfo_Const
@@ -1284,6 +1336,8 @@ class TypeInfo_Shared : TypeInfo_Const
else
return cast(string) ("shared(" ~ base.toString() ~ ")");
}
+
+ @property override Type type() nothrow pure { return Type.Shared; }
}
class TypeInfo_Inout : TypeInfo_Const
@@ -1295,6 +1349,8 @@ class TypeInfo_Inout : TypeInfo_Const
else
return cast(string) ("inout(" ~ base.toString() ~ ")");
}
+
+ @property override Type type() nothrow pure { return Type.Inout; }
}
abstract class MemberInfo
@@ -110,4 +110,6 @@ class TypeInfo_AC : TypeInfo
//arg2 = typeid(void*);
return 0;
}
+
+ @property override Type type() nothrow pure { return Type.Array; }
}
@@ -96,4 +96,6 @@ class TypeInfo_Ar : TypeInfo
//arg2 = typeid(void*);
return 0;
}
+
+ @property override Type type() nothrow pure { return Type.Array; }
}
@@ -96,4 +96,6 @@ class TypeInfo_Aq : TypeInfo
//arg2 = typeid(void*);
return 0;
}
+
+ @property override Type type() nothrow pure { return Type.Array; }
}
@@ -96,4 +96,6 @@ class TypeInfo_Ac : TypeInfo
//arg2 = typeid(void*);
return 0;
}
+
+ @property override Type type() nothrow pure { return Type.Array; }
}
@@ -96,6 +96,8 @@ class TypeInfo_Ad : TypeInfo
//arg2 = typeid(void*);
return 0;
}
+
+ @property override Type type() nothrow pure { return Type.Array; }
}
// idouble[]
@@ -114,4 +116,6 @@ class TypeInfo_Ap : TypeInfo_Ad
{
return typeid(idouble);
}
+
+ @property override Type type() nothrow pure { return Type.Array; }
}
@@ -96,6 +96,8 @@ class TypeInfo_Af : TypeInfo
//arg2 = typeid(void*);
return 0;
}
+
+ @property override Type type() nothrow pure { return Type.Array; }
}
// ifloat[]
@@ -114,4 +116,6 @@ class TypeInfo_Ao : TypeInfo_Af
{
return typeid(ifloat);
}
+
+ @property override Type type() nothrow pure { return Type.Array; }
}
@@ -90,6 +90,8 @@ class TypeInfo_Ag : TypeInfo
//arg2 = typeid(void*);
return 0;
}
+
+ @property override Type type() nothrow pure { return Type.Array; }
}
@@ -117,6 +119,8 @@ class TypeInfo_Ah : TypeInfo_Ag
{
return typeid(ubyte);
}
+
+ @property override Type type() nothrow pure { return Type.Array; }
}
// void[]
@@ -135,6 +139,8 @@ class TypeInfo_Av : TypeInfo_Ah
{
return typeid(void);
}
+
+ @property override Type type() nothrow pure { return Type.Array; }
}
// bool[]
@@ -153,6 +159,8 @@ class TypeInfo_Ab : TypeInfo_Ah
{
return typeid(bool);
}
+
+ @property override Type type() nothrow pure { return Type.Array; }
}
// char[]
@@ -220,6 +228,8 @@ else
{
return typeid(char);
}
+
+ @property override Type type() nothrow pure { return Type.Array; }
}
// string
@@ -238,5 +248,7 @@ class TypeInfo_Aya : TypeInfo_Aa
{
return typeid(immutable(char));
}
+
+ @property override Type type() nothrow pure { return Type.Array; }
}
@@ -89,6 +89,8 @@ class TypeInfo_Ai : TypeInfo
//arg2 = typeid(void*);
return 0;
}
+
+ @property override Type type() nothrow pure { return Type.Array; }
}
unittest
@@ -139,6 +141,8 @@ class TypeInfo_Ak : TypeInfo_Ai
{
return typeid(uint);
}
+
+ @property override Type type() nothrow pure { return Type.Array; }
}
// dchar[]
@@ -157,4 +161,6 @@ class TypeInfo_Aw : TypeInfo_Ak
{
return typeid(dchar);
}
+
+ @property override Type type() nothrow pure { return Type.Array; }
}
@@ -90,6 +90,8 @@ class TypeInfo_Al : TypeInfo
//arg2 = typeid(void*);
return 0;
}
+
+ @property override Type type() nothrow pure { return Type.Array; }
}
@@ -131,4 +133,6 @@ class TypeInfo_Am : TypeInfo_Al
{
return typeid(ulong);
}
+
+ @property override Type type() nothrow pure { return Type.Array; }
}
Oops, something went wrong.

0 comments on commit 74713f7

Please sign in to comment.