comparison druntime/src/compiler/dmd/typeinfo/ti_Afloat.d @ 759:d3eb054172f9

Added copy of druntime from DMD 2.020 modified for LDC.
author Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
date Tue, 11 Nov 2008 01:52:37 +0100
parents
children
comparison
equal deleted inserted replaced
758:f04dde6e882c 759:d3eb054172f9
1 /*
2 * Copyright (C) 2004-2005 by Digital Mars, www.digitalmars.com
3 * Written by Walter Bright
4 *
5 * This software is provided 'as-is', without any express or implied
6 * warranty. In no event will the authors be held liable for any damages
7 * arising from the use of this software.
8 *
9 * Permission is granted to anyone to use this software for any purpose,
10 * including commercial applications, and to alter it and redistribute it
11 * freely, in both source and binary form, subject to the following
12 * restrictions:
13 *
14 * o The origin of this software must not be misrepresented; you must not
15 * claim that you wrote the original software. If you use this software
16 * in a product, an acknowledgment in the product documentation would be
17 * appreciated but is not required.
18 * o Altered source versions must be plainly marked as such, and must not
19 * be misrepresented as being the original software.
20 * o This notice may not be removed or altered from any source
21 * distribution.
22 */
23
24 module rt.typeinfo.ti_Afloat;
25
26 private import typeinfo.ti_float;
27
28 // float[]
29
30 class TypeInfo_Af : TypeInfo
31 {
32 override string toString() { return "float[]"; }
33
34 override hash_t getHash(in void* p)
35 { float[] s = *cast(float[]*)p;
36 size_t len = s.length;
37 auto str = s.ptr;
38 hash_t hash = 0;
39
40 while (len)
41 {
42 hash *= 9;
43 hash += *cast(uint *)str;
44 str++;
45 len--;
46 }
47
48 return hash;
49 }
50
51 override equals_t equals(in void* p1, in void* p2)
52 {
53 float[] s1 = *cast(float[]*)p1;
54 float[] s2 = *cast(float[]*)p2;
55 size_t len = s1.length;
56
57 if (len != s2.length)
58 return 0;
59 for (size_t u = 0; u < len; u++)
60 {
61 if (!TypeInfo_f._equals(s1[u], s2[u]))
62 return false;
63 }
64 return true;
65 }
66
67 override int compare(in void* p1, in void* p2)
68 {
69 float[] s1 = *cast(float[]*)p1;
70 float[] s2 = *cast(float[]*)p2;
71 size_t len = s1.length;
72
73 if (s2.length < len)
74 len = s2.length;
75 for (size_t u = 0; u < len; u++)
76 {
77 int c = TypeInfo_f._compare(s1[u], s2[u]);
78 if (c)
79 return c;
80 }
81 if (s1.length < s2.length)
82 return -1;
83 else if (s1.length > s2.length)
84 return 1;
85 return 0;
86 }
87
88 override size_t tsize()
89 {
90 return (float[]).sizeof;
91 }
92
93 override uint flags()
94 {
95 return 1;
96 }
97
98 override TypeInfo next()
99 {
100 return typeid(float);
101 }
102 }
103
104 // ifloat[]
105
106 class TypeInfo_Ao : TypeInfo_Af
107 {
108 override string toString() { return "ifloat[]"; }
109
110 override TypeInfo next()
111 {
112 return typeid(ifloat);
113 }
114 }