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