Mercurial > projects > ldc
annotate tango/lib/compiler/llvmdc/typeinfo/ti_Areal.d @ 213:7816aafeea3c trunk
[svn r229] Updated the object.d implementation to the latest Tango.
Fixed a bunch of the built-in typeinfos for arrays, they did not inherit TypeInfo_Array.
Applied patch to tango/text/convert/Layout.d by fvbommel, closes #47 .
Cleaned up some type code.
Replaced uses of llvm::Type with LLType (a typedef), same for Value and Constant.
Fixed a few cases where typeinfo for user structs could be emitted multiple times, seems to still be some cases of this :/
author | lindquist |
---|---|
date | Fri, 30 May 2008 19:32:04 +0200 |
parents | 1700239cab2e |
children |
rev | line source |
---|---|
132 | 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 typeinfo.ti_Areal; | |
25 | |
26 private import typeinfo.ti_real; | |
27 | |
28 // real[] | |
29 | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
132
diff
changeset
|
30 class TypeInfo_Ae : TypeInfo_Array |
132 | 31 { |
32 char[] toString() { return "real[]"; } | |
33 | |
34 hash_t getHash(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 int equals(void *p1, 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 0; | |
61 for (size_t u = 0; u < len; u++) | |
62 { | |
63 int c = TypeInfo_e._equals(s1[u], s2[u]); | |
64 if (c == 0) | |
65 return 0; | |
66 } | |
67 return 1; | |
68 } | |
69 | |
70 int compare(void *p1, void *p2) | |
71 { | |
72 real[] s1 = *cast(real[]*)p1; | |
73 real[] s2 = *cast(real[]*)p2; | |
74 size_t len = s1.length; | |
75 | |
76 if (s2.length < len) | |
77 len = s2.length; | |
78 for (size_t u = 0; u < len; u++) | |
79 { | |
80 int c = TypeInfo_e._compare(s1[u], s2[u]); | |
81 if (c) | |
82 return c; | |
83 } | |
84 if (s1.length < s2.length) | |
85 return -1; | |
86 else if (s1.length > s2.length) | |
87 return 1; | |
88 return 0; | |
89 } | |
90 | |
91 size_t tsize() | |
92 { | |
93 return (real[]).sizeof; | |
94 } | |
95 | |
96 uint flags() | |
97 { | |
98 return 1; | |
99 } | |
100 | |
101 TypeInfo next() | |
102 { | |
103 return typeid(real); | |
104 } | |
105 } | |
106 | |
107 // ireal[] | |
108 | |
109 class TypeInfo_Aj : TypeInfo_Ae | |
110 { | |
111 char[] toString() { return "ireal[]"; } | |
112 | |
113 TypeInfo next() | |
114 { | |
115 return typeid(ireal); | |
116 } | |
117 } |