Mercurial > projects > ldc
comparison druntime/src/compiler/ldc/typeinfo/ti_C.d @ 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 |
comparison
equal
deleted
inserted
replaced
1456:7b218ec1044f | 1458:e0b2d67cfe7c |
---|---|
1 /** | |
2 * TypeInfo support code. | |
3 * | |
4 * Copyright: Copyright Digital Mars 2004 - 2009. | |
5 * License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>. | |
6 * Authors: Walter Bright | |
7 * | |
8 * Copyright Digital Mars 2004 - 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 rt.typeinfo.ti_C; | |
14 | |
15 // Object | |
16 | |
17 class TypeInfo_C : TypeInfo | |
18 { | |
19 override hash_t getHash(in void* p) | |
20 { | |
21 Object o = *cast(Object*)p; | |
22 return o ? o.toHash() : 0; | |
23 } | |
24 | |
25 override equals_t equals(in void* p1, in void* p2) | |
26 { | |
27 Object o1 = *cast(Object*)p1; | |
28 Object o2 = *cast(Object*)p2; | |
29 | |
30 return o1 == o2; | |
31 } | |
32 | |
33 override int compare(in void* p1, in void* p2) | |
34 { | |
35 Object o1 = *cast(Object*)p1; | |
36 Object o2 = *cast(Object*)p2; | |
37 int c = 0; | |
38 | |
39 // Regard null references as always being "less than" | |
40 if (!(o1 is o2)) | |
41 { | |
42 if (o1) | |
43 { if (!o2) | |
44 c = 1; | |
45 else | |
46 c = o1.opCmp(o2); | |
47 } | |
48 else | |
49 c = -1; | |
50 } | |
51 return c; | |
52 } | |
53 | |
54 override size_t tsize() | |
55 { | |
56 return Object.sizeof; | |
57 } | |
58 | |
59 override uint flags() | |
60 { | |
61 return 1; | |
62 } | |
63 } |