comparison druntime/src/compiler/dmd/typeinfo/ti_Areal.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-2006 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_Areal;
25
26 private import typeinfo.ti_real;
27
28 // real[]
29
30 class TypeInfo_Ae : TypeInfo
31 {
32 override string toString() { return "real[]"; }
33
34 override hash_t getHash(in void* p)
35 { real[] s = *cast(real[]*)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)[0];
44 hash += (cast(uint *)str)[1];
45 hash += (cast(ushort *)str)[4];
46 str++;
47 len--;
48 }
49
50 return hash;
51 }
52
53 override equals_t equals(in void* p1, in void* p2)
54 {
55 real[] s1 = *cast(real[]*)p1;
56 real[] s2 = *cast(real[]*)p2;
57 size_t len = s1.length;
58
59 if (len != s2.length)
60 return false;
61 for (size_t u = 0; u < len; u++)
62 {
63 if (!TypeInfo_e._equals(s1[u], s2[u]))
64 return false;
65 }
66 return true;
67 }
68
69 override int compare(in void* p1, in void* p2)
70 {
71 real[] s1 = *cast(real[]*)p1;
72 real[] s2 = *cast(real[]*)p2;
73 size_t len = s1.length;
74
75 if (s2.length < len)
76 len = s2.length;
77 for (size_t u = 0; u < len; u++)
78 {
79 int c = TypeInfo_e._compare(s1[u], s2[u]);
80 if (c)
81 return c;
82 }
83 if (s1.length < s2.length)
84 return -1;
85 else if (s1.length > s2.length)
86 return 1;
87 return 0;
88 }
89
90 override size_t tsize()
91 {
92 return (real[]).sizeof;
93 }
94
95 override uint flags()
96 {
97 return 1;
98 }
99
100 override TypeInfo next()
101 {
102 return typeid(real);
103 }
104 }
105
106 // ireal[]
107
108 class TypeInfo_Aj : TypeInfo_Ae
109 {
110 override string toString() { return "ireal[]"; }
111
112 override TypeInfo next()
113 {
114 return typeid(ireal);
115 }
116 }