Mercurial > projects > ldc
comparison druntime/src/compiler/dmd/typeinfo/ti_ptr.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_ptr; | |
14 | |
15 // pointer | |
16 | |
17 class TypeInfo_P : TypeInfo | |
18 { | |
19 override hash_t getHash(in void* p) | |
20 { | |
21 return cast(uint)*cast(void* *)p; | |
22 } | |
23 | |
24 override equals_t equals(in void* p1, in void* p2) | |
25 { | |
26 return *cast(void* *)p1 == *cast(void* *)p2; | |
27 } | |
28 | |
29 override int compare(in void* p1, in void* p2) | |
30 { | |
31 auto c = *cast(void* *)p1 - *cast(void* *)p2; | |
32 if (c < 0) | |
33 return -1; | |
34 else if (c > 0) | |
35 return 1; | |
36 return 0; | |
37 } | |
38 | |
39 override size_t tsize() | |
40 { | |
41 return (void*).sizeof; | |
42 } | |
43 | |
44 override void swap(void *p1, void *p2) | |
45 { | |
46 void* t; | |
47 | |
48 t = *cast(void* *)p1; | |
49 *cast(void* *)p1 = *cast(void* *)p2; | |
50 *cast(void* *)p2 = t; | |
51 } | |
52 | |
53 override uint flags() | |
54 { | |
55 return 1; | |
56 } | |
57 } |