comparison druntime/src/compiler/dmd/typeinfo/ti_Acdouble.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_Acdouble;
14
15 private import rt.typeinfo.ti_cdouble;
16
17 // cdouble[]
18
19 class TypeInfo_Ar : TypeInfo
20 {
21 override string toString() { return "cdouble[]"; }
22
23 override hash_t getHash(in void* p)
24 { cdouble[] s = *cast(cdouble[]*)p;
25 size_t len = s.length;
26 cdouble *str = s.ptr;
27 hash_t hash = 0;
28
29 while (len)
30 {
31 hash *= 9;
32 hash += (cast(uint *)str)[0];
33 hash += (cast(uint *)str)[1];
34 hash += (cast(uint *)str)[2];
35 hash += (cast(uint *)str)[3];
36 str++;
37 len--;
38 }
39
40 return hash;
41 }
42
43 override equals_t equals(in void* p1, in void* p2)
44 {
45 cdouble[] s1 = *cast(cdouble[]*)p1;
46 cdouble[] s2 = *cast(cdouble[]*)p2;
47 size_t len = s1.length;
48
49 if (len != s2.length)
50 return false;
51 for (size_t u = 0; u < len; u++)
52 {
53 if (!TypeInfo_r._equals(s1[u], s2[u]))
54 return false;
55 }
56 return true;
57 }
58
59 override int compare(in void* p1, in void* p2)
60 {
61 cdouble[] s1 = *cast(cdouble[]*)p1;
62 cdouble[] s2 = *cast(cdouble[]*)p2;
63 size_t len = s1.length;
64
65 if (s2.length < len)
66 len = s2.length;
67 for (size_t u = 0; u < len; u++)
68 {
69 int c = TypeInfo_r._compare(s1[u], s2[u]);
70 if (c)
71 return c;
72 }
73 if (s1.length < s2.length)
74 return -1;
75 else if (s1.length > s2.length)
76 return 1;
77 return 0;
78 }
79
80 override size_t tsize()
81 {
82 return (cdouble[]).sizeof;
83 }
84
85 override uint flags()
86 {
87 return 1;
88 }
89
90 override TypeInfo next()
91 {
92 return typeid(cdouble);
93 }
94 }