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