module object; alias typeof(int.sizeof) size_t; alias typeof(cast(void*)0 - cast(void*)0) ptrdiff_t; alias size_t hash_t; /* * The names Mutf8, Cutf8, ... are choosen to be very easy search/replaceable. * It is expected that these name will later change */ alias char [] Mutf8; alias wchar [] Mutf16; alias dchar [] Mutf32; alias const( char)[] Cutf8; alias const(wchar)[] Cutf16; alias const(dchar)[] Cutf32; alias invariant( char)[] Iutf8; alias invariant(wchar)[] Iutf16; alias invariant(dchar)[] Iutf32; class Object { Cutf8 toString(); hash_t toHash(); int opCmp(Object o); bool opEquals(Object o); interface Monitor { void lock(); void unlock(); } } struct Interface { ClassInfo classinfo; void*[] vtbl; ptrdiff_t offset; // offset to Interface 'this' from Object 'this' } class ClassInfo : Object { byte[] init; // class static initializer Cutf8 name; // class name void*[] vtbl; // virtual function pointer table Interface[] interfaces; ClassInfo base; void* destructor; void(*classInvariant)(Object); uint flags; // 1: // IUnknown // 2: // has no possible pointers into GC memory // 4: // has offTi[] member // 8: // has constructors void* deallocator; OffsetTypeInfo[] offTi; void* defaultConstructor; const(MemberInfo[]) function(Cutf8) xgetMembers; // module getMembers() function static ClassInfo find(Cutf8 classname); Object create(); const(MemberInfo[]) getMembers(Cutf8); } struct OffsetTypeInfo { size_t offset; TypeInfo ti; } class TypeInfo { hash_t getHash(in void *p); bool equals(in void *p1, in void *p2); int compare(in void *p1, in void *p2); size_t tsize(); void swap(void *p1, void *p2); TypeInfo next(); void[] init(); uint flags(); // 1: // has possible pointers into GC memory OffsetTypeInfo[] offTi(); void destroy(void *p); void postblit(void *p); } class TypeInfo_Typedef : TypeInfo { TypeInfo base; Cutf8 name; void[] m_init; } class TypeInfo_Enum : TypeInfo_Typedef { } class TypeInfo_Pointer : TypeInfo { TypeInfo m_next; } class TypeInfo_Array : TypeInfo { TypeInfo value; } class TypeInfo_StaticArray : TypeInfo { TypeInfo value; size_t len; } class TypeInfo_AssociativeArray : TypeInfo { TypeInfo value; TypeInfo key; } class TypeInfo_Function : TypeInfo { TypeInfo next; } class TypeInfo_Delegate : TypeInfo { TypeInfo next; } class TypeInfo_Class : TypeInfo { ClassInfo info; } class TypeInfo_Interface : TypeInfo { ClassInfo info; } class TypeInfo_Struct : TypeInfo { Cutf8 name; void[] m_init; uint function(in void*) xtoHash; bool function(in void*,in void*) xopEquals; int function(in void*,in void*) xopCmp; Cutf8 function(const(void)*) xtoString; uint m_flags; const(MemberInfo[]) function(Cutf8) xgetMembers; void function(void*) xdtor; void function(void*) xpostblit; } class TypeInfo_Tuple : TypeInfo { TypeInfo[] elements; } class TypeInfo_Const : TypeInfo { TypeInfo base; } class TypeInfo_Invariant : TypeInfo_Const { } class ModuleInfo { char[] name; ModuleInfo[] importedModules; ClassInfo[] localClasses; uint flags; void function() ctor; void function() dtor; void function() unitTest; static int opApply( int delegate( inout ModuleInfo ) ); } abstract class MemberInfo { Cutf8 name(); } class MemberInfo_field : MemberInfo { this(Cutf8 name, TypeInfo ti, size_t offset) { m_name = name; m_typeinfo = ti; m_offset = offset; } override Cutf8 name() { return m_name; } TypeInfo typeInfo() { return m_typeinfo; } size_t offset() { return m_offset; } Cutf8 m_name; TypeInfo m_typeinfo; size_t m_offset; } class MemberInfo_function : MemberInfo { this(Cutf8 name, TypeInfo ti, void* fp, uint flags) { m_name = name; m_typeinfo = ti; m_fp = fp; m_flags = flags; } override Cutf8 name() { return m_name; } TypeInfo typeInfo() { return m_typeinfo; } void* fp() { return m_fp; } uint flags() { return m_flags; } Cutf8 m_name; TypeInfo m_typeinfo; void* m_fp; uint m_flags; } class Exception : Object { interface TraceInfo { int opApply( int delegate( inout char[] ) ); char[] toString(); } Cutf8 msg; Cutf8 file; size_t line; TraceInfo info; Exception next; this(Cutf8 msg, Exception next = null); this(Cutf8 msg, Cutf8 file, size_t line, Exception next = null); override Cutf8 toString(); }