Mercurial > projects > ldc
comparison druntime/import/object.di @ 1458:e0b2d67cfe7c
Added druntime (this should be removed once it works).
author | Robert Clipsham <robert@octarineparrot.com> |
---|---|
date | Tue, 02 Jun 2009 17:43:06 +0100 |
parents | |
children | a5526b7a5ae6 |
comparison
equal
deleted
inserted
replaced
1456:7b218ec1044f | 1458:e0b2d67cfe7c |
---|---|
1 /** | |
2 * Contains all implicitly declared types and variables. | |
3 * | |
4 * Copyright: Copyright Digital Mars 2000 - 2009. | |
5 * License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>. | |
6 * Authors: Walter Bright, Sean Kelly | |
7 * | |
8 * Copyright Digital Mars 2000 - 2009. | |
9 * Distributed under the Boost Software License, Version 1.0. | |
10 * (See accompanying file LICENSE_1_0.txt or copy at | |
11 * http://www.boost.org/LICENSE_1_0.txt) | |
12 */ | |
13 module object; | |
14 | |
15 alias typeof(int.sizeof) size_t; | |
16 alias typeof(cast(void*)0 - cast(void*)0) ptrdiff_t; | |
17 | |
18 alias size_t hash_t; | |
19 alias bool equals_t; | |
20 | |
21 alias immutable(char)[] string; | |
22 alias immutable(wchar)[] wstring; | |
23 alias immutable(dchar)[] dstring; | |
24 | |
25 class Object | |
26 { | |
27 string toString(); | |
28 hash_t toHash(); | |
29 int opCmp(Object o); | |
30 equals_t opEquals(Object o); | |
31 | |
32 interface Monitor | |
33 { | |
34 void lock(); | |
35 void unlock(); | |
36 } | |
37 | |
38 static Object factory(string classname); | |
39 } | |
40 | |
41 struct Interface | |
42 { | |
43 ClassInfo classinfo; | |
44 void*[] vtbl; | |
45 ptrdiff_t offset; // offset to Interface 'this' from Object 'this' | |
46 } | |
47 | |
48 class ClassInfo : Object | |
49 { | |
50 byte[] init; // class static initializer | |
51 string name; // class name | |
52 void*[] vtbl; // virtual function pointer table | |
53 Interface[] interfaces; | |
54 ClassInfo base; | |
55 void* destructor; | |
56 void(*classInvariant)(Object); | |
57 uint flags; | |
58 // 1: // is IUnknown or is derived from IUnknown | |
59 // 2: // has no possible pointers into GC memory | |
60 // 4: // has offTi[] member | |
61 // 8: // has constructors | |
62 // 16: // has xgetMembers member | |
63 // 32: // has typeinfo member | |
64 void* deallocator; | |
65 OffsetTypeInfo[] offTi; | |
66 void* defaultConstructor; | |
67 const(MemberInfo[]) function(string) xgetMembers; | |
68 TypeInfo typeinfo; | |
69 | |
70 static ClassInfo find(in char[] classname); | |
71 Object create(); | |
72 const(MemberInfo[]) getMembers(in char[] classname); | |
73 } | |
74 | |
75 struct OffsetTypeInfo | |
76 { | |
77 size_t offset; | |
78 TypeInfo ti; | |
79 } | |
80 | |
81 class TypeInfo | |
82 { | |
83 hash_t getHash(in void* p); | |
84 equals_t equals(in void* p1, in void* p2); | |
85 int compare(in void* p1, in void* p2); | |
86 size_t tsize(); | |
87 void swap(void* p1, void* p2); | |
88 TypeInfo next(); | |
89 void[] init(); | |
90 uint flags(); | |
91 // 1: // has possible pointers into GC memory | |
92 OffsetTypeInfo[] offTi(); | |
93 void destroy(void* p); | |
94 void postblit(void* p); | |
95 } | |
96 | |
97 class TypeInfo_Typedef : TypeInfo | |
98 { | |
99 TypeInfo base; | |
100 string name; | |
101 void[] m_init; | |
102 } | |
103 | |
104 class TypeInfo_Enum : TypeInfo_Typedef | |
105 { | |
106 | |
107 } | |
108 | |
109 class TypeInfo_Pointer : TypeInfo | |
110 { | |
111 TypeInfo m_next; | |
112 } | |
113 | |
114 class TypeInfo_Array : TypeInfo | |
115 { | |
116 TypeInfo value; | |
117 } | |
118 | |
119 class TypeInfo_StaticArray : TypeInfo | |
120 { | |
121 TypeInfo value; | |
122 size_t len; | |
123 } | |
124 | |
125 class TypeInfo_AssociativeArray : TypeInfo | |
126 { | |
127 TypeInfo value; | |
128 TypeInfo key; | |
129 } | |
130 | |
131 class TypeInfo_Function : TypeInfo | |
132 { | |
133 TypeInfo next; | |
134 } | |
135 | |
136 class TypeInfo_Delegate : TypeInfo | |
137 { | |
138 TypeInfo next; | |
139 } | |
140 | |
141 class TypeInfo_Class : TypeInfo | |
142 { | |
143 ClassInfo info; | |
144 } | |
145 | |
146 class TypeInfo_Interface : TypeInfo | |
147 { | |
148 ClassInfo info; | |
149 } | |
150 | |
151 class TypeInfo_Struct : TypeInfo | |
152 { | |
153 string name; | |
154 void[] m_init; | |
155 | |
156 uint function(in void*) xtoHash; | |
157 equals_t function(in void*, in void*) xopEquals; | |
158 int function(in void*, in void*) xopCmp; | |
159 string function(in void*) xtoString; | |
160 | |
161 uint m_flags; | |
162 | |
163 const(MemberInfo[]) function(in char[]) xgetMembers; | |
164 void function(void*) xdtor; | |
165 void function(void*) xpostblit; | |
166 } | |
167 | |
168 class TypeInfo_Tuple : TypeInfo | |
169 { | |
170 TypeInfo[] elements; | |
171 } | |
172 | |
173 class TypeInfo_Const : TypeInfo | |
174 { | |
175 TypeInfo next; | |
176 } | |
177 | |
178 class TypeInfo_Invariant : TypeInfo_Const | |
179 { | |
180 | |
181 } | |
182 | |
183 class TypeInfo_Shared : TypeInfo_Const | |
184 { | |
185 | |
186 } | |
187 | |
188 abstract class MemberInfo | |
189 { | |
190 string name(); | |
191 } | |
192 | |
193 class MemberInfo_field : MemberInfo | |
194 { | |
195 this(string name, TypeInfo ti, size_t offset); | |
196 | |
197 override string name(); | |
198 TypeInfo typeInfo(); | |
199 size_t offset(); | |
200 } | |
201 | |
202 class MemberInfo_function : MemberInfo | |
203 { | |
204 enum | |
205 { | |
206 Virtual = 1, | |
207 Member = 2, | |
208 Static = 4, | |
209 } | |
210 | |
211 this(string name, TypeInfo ti, void* fp, uint flags); | |
212 | |
213 override string name(); | |
214 TypeInfo typeInfo(); | |
215 void* fp(); | |
216 uint flags(); | |
217 } | |
218 | |
219 class ModuleInfo | |
220 { | |
221 string name; | |
222 ModuleInfo[] importedModules; | |
223 ClassInfo[] localClasses; | |
224 uint flags; | |
225 | |
226 void function() ctor; | |
227 void function() dtor; | |
228 void function() unitTest; | |
229 | |
230 void* xgetMembers; | |
231 void function() ictor; | |
232 void*[4] reserved; | |
233 | |
234 static int opApply(int delegate(inout ModuleInfo)); | |
235 } | |
236 | |
237 class Throwable : Object | |
238 { | |
239 interface TraceInfo | |
240 { | |
241 int opApply(int delegate(inout char[])); | |
242 string toString(); | |
243 } | |
244 | |
245 string msg; | |
246 string file; | |
247 size_t line; | |
248 TraceInfo info; | |
249 Throwable next; | |
250 | |
251 this(string msg, Throwable next = null); | |
252 this(string msg, string file, size_t line, Throwable next = null); | |
253 override string toString(); | |
254 } | |
255 | |
256 | |
257 class Exception : Throwable | |
258 { | |
259 this(string msg, Throwable next = null); | |
260 this(string msg, string file, size_t line, Throwable next = null); | |
261 } | |
262 | |
263 | |
264 class Error : Throwable | |
265 { | |
266 this(string msg, Throwable next = null); | |
267 this(string msg, string file, size_t line, Throwable next = null); | |
268 } |