comparison druntime/src/compiler/ldc/typeinfo/ti_creal.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_creal;
14
15 // creal
16
17 class TypeInfo_c : TypeInfo
18 {
19 override string toString() { return "creal"; }
20
21 override hash_t getHash(in void* p)
22 {
23 return (cast(uint *)p)[0] + (cast(uint *)p)[1] +
24 (cast(uint *)p)[2] + (cast(uint *)p)[3] +
25 (cast(uint *)p)[4];
26 }
27
28 static equals_t _equals(creal f1, creal f2)
29 {
30 return f1 == f2;
31 }
32
33 static int _compare(creal f1, creal f2)
34 { int result;
35
36 if (f1.re < f2.re)
37 result = -1;
38 else if (f1.re > f2.re)
39 result = 1;
40 else if (f1.im < f2.im)
41 result = -1;
42 else if (f1.im > f2.im)
43 result = 1;
44 else
45 result = 0;
46 return result;
47 }
48
49 override equals_t equals(in void* p1, in void* p2)
50 {
51 return _equals(*cast(creal *)p1, *cast(creal *)p2);
52 }
53
54 override int compare(in void* p1, in void* p2)
55 {
56 return _compare(*cast(creal *)p1, *cast(creal *)p2);
57 }
58
59 override size_t tsize()
60 {
61 return creal.sizeof;
62 }
63
64 override void swap(void *p1, void *p2)
65 {
66 creal t;
67
68 t = *cast(creal *)p1;
69 *cast(creal *)p1 = *cast(creal *)p2;
70 *cast(creal *)p2 = t;
71 }
72
73 override void[] init()
74 { static immutable creal r;
75
76 return (cast(creal *)&r)[0 .. 1];
77 }
78 }