]> git.ipfire.org Git - thirdparty/gcc.git/blob - libphobos/libdruntime/rt/typeinfo/ti_delegate.d
Add D front-end, libphobos library, and D2 testsuite.
[thirdparty/gcc.git] / libphobos / libdruntime / rt / typeinfo / ti_delegate.d
1 /**
2 * TypeInfo support code.
3 *
4 * Copyright: Copyright Digital Mars 2004 - 2009.
5 * License: $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
6 * Authors: Walter Bright
7 */
8
9 /* Copyright Digital Mars 2004 - 2009.
10 * Distributed under the Boost Software License, Version 1.0.
11 * (See accompanying file LICENSE or copy at
12 * http://www.boost.org/LICENSE_1_0.txt)
13 */
14 module rt.typeinfo.ti_delegate;
15
16 private import rt.util.hash;
17
18 // delegate
19
20 alias void delegate(int) dg;
21
22 class TypeInfo_D : TypeInfo
23 {
24 @trusted:
25 const:
26 pure:
27 nothrow:
28
29 override size_t getHash(in void* p)
30 {
31 return rt.util.hash.hashOf(p[0 .. dg.sizeof], 0);
32 }
33
34 override bool equals(in void* p1, in void* p2)
35 {
36 return *cast(dg *)p1 == *cast(dg *)p2;
37 }
38
39 override @property size_t tsize() nothrow pure
40 {
41 return dg.sizeof;
42 }
43
44 override void swap(void *p1, void *p2)
45 {
46 dg t;
47
48 t = *cast(dg *)p1;
49 *cast(dg *)p1 = *cast(dg *)p2;
50 *cast(dg *)p2 = t;
51 }
52
53 override const(void)[] initializer() const @trusted
54 {
55 static immutable dg d;
56
57 return (cast(void *)null)[0 .. dg.sizeof];
58 }
59
60 override @property uint flags() nothrow pure
61 {
62 return 1;
63 }
64 }