Mercurial > projects > ldc
comparison druntime/src/compiler/ldc/typeinfo/ti_Adouble.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_Adouble; | |
14 | |
15 private import rt.typeinfo.ti_double; | |
16 | |
17 // double[] | |
18 | |
19 class TypeInfo_Ad : TypeInfo | |
20 { | |
21 override string toString() { return "double[]"; } | |
22 | |
23 override hash_t getHash(in void* p) | |
24 { double[] s = *cast(double[]*)p; | |
25 size_t len = s.length; | |
26 auto 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 str++; | |
35 len--; | |
36 } | |
37 | |
38 return hash; | |
39 } | |
40 | |
41 override equals_t equals(in void* p1, in void* p2) | |
42 { | |
43 double[] s1 = *cast(double[]*)p1; | |
44 double[] s2 = *cast(double[]*)p2; | |
45 size_t len = s1.length; | |
46 | |
47 if (len != s2.length) | |
48 return 0; | |
49 for (size_t u = 0; u < len; u++) | |
50 { | |
51 if (!TypeInfo_d._equals(s1[u], s2[u])) | |
52 return false; | |
53 } | |
54 return true; | |
55 } | |
56 | |
57 override int compare(in void* p1, in void* p2) | |
58 { | |
59 double[] s1 = *cast(double[]*)p1; | |
60 double[] s2 = *cast(double[]*)p2; | |
61 size_t len = s1.length; | |
62 | |
63 if (s2.length < len) | |
64 len = s2.length; | |
65 for (size_t u = 0; u < len; u++) | |
66 { | |
67 int c = TypeInfo_d._compare(s1[u], s2[u]); | |
68 if (c) | |
69 return c; | |
70 } | |
71 if (s1.length < s2.length) | |
72 return -1; | |
73 else if (s1.length > s2.length) | |
74 return 1; | |
75 return 0; | |
76 } | |
77 | |
78 override size_t tsize() | |
79 { | |
80 return (double[]).sizeof; | |
81 } | |
82 | |
83 override uint flags() | |
84 { | |
85 return 1; | |
86 } | |
87 | |
88 override TypeInfo next() | |
89 { | |
90 return typeid(double); | |
91 } | |
92 } | |
93 | |
94 // idouble[] | |
95 | |
96 class TypeInfo_Ap : TypeInfo_Ad | |
97 { | |
98 override string toString() { return "idouble[]"; } | |
99 | |
100 override TypeInfo next() | |
101 { | |
102 return typeid(idouble); | |
103 } | |
104 } |