comparison druntime/src/compiler/dmd/typeinfo/ti_Acfloat.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_Acfloat;
14
15 private import rt.typeinfo.ti_cfloat;
16
17 // cfloat[]
18
19 class TypeInfo_Aq : TypeInfo
20 {
21 override string toString() { return "cfloat[]"; }
22
23 override hash_t getHash(in void* p)
24 { cfloat[] s = *cast(cfloat[]*)p;
25 size_t len = s.length;
26 cfloat *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 cfloat[] s1 = *cast(cfloat[]*)p1;
44 cfloat[] s2 = *cast(cfloat[]*)p2;
45 size_t len = s1.length;
46
47 if (len != s2.length)
48 return false;
49 for (size_t u = 0; u < len; u++)
50 {
51 if (!TypeInfo_q._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 cfloat[] s1 = *cast(cfloat[]*)p1;
60 cfloat[] s2 = *cast(cfloat[]*)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_q._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 (cfloat[]).sizeof;
81 }
82
83 override uint flags()
84 {
85 return 1;
86 }
87
88 override TypeInfo next()
89 {
90 return typeid(cfloat);
91 }
92 }