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