comparison runtime/internal/typeinfo/ti_Along.d @ 443:44f08170f4ef

Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn. Reworked the LLVMDC specific pragmas.
author Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
date Fri, 01 Aug 2008 00:32:06 +0200
parents
children
comparison
equal deleted inserted replaced
442:76078c8ab5b9 443:44f08170f4ef
1
2 module typeinfo.ti_Along;
3
4 private import tango.stdc.string;
5
6 // long[]
7
8 class TypeInfo_Al : TypeInfo_Array
9 {
10 char[] toString() { return "long[]"; }
11
12 hash_t getHash(void *p)
13 { long[] s = *cast(long[]*)p;
14 size_t len = s.length;
15 auto str = s.ptr;
16 hash_t hash = 0;
17
18 while (len)
19 {
20 hash *= 9;
21 hash += *cast(uint *)str + *(cast(uint *)str + 1);
22 str++;
23 len--;
24 }
25
26 return hash;
27 }
28
29 int equals(void *p1, void *p2)
30 {
31 long[] s1 = *cast(long[]*)p1;
32 long[] s2 = *cast(long[]*)p2;
33
34 return s1.length == s2.length &&
35 memcmp(cast(void *)s1, cast(void *)s2, s1.length * long.sizeof) == 0;
36 }
37
38 int compare(void *p1, void *p2)
39 {
40 long[] s1 = *cast(long[]*)p1;
41 long[] s2 = *cast(long[]*)p2;
42 size_t len = s1.length;
43
44 if (s2.length < len)
45 len = s2.length;
46 for (size_t u = 0; u < len; u++)
47 {
48 if (s1[u] < s2[u])
49 return -1;
50 else if (s1[u] > s2[u])
51 return 1;
52 }
53 if (s1.length < s2.length)
54 return -1;
55 else if (s1.length > s2.length)
56 return 1;
57 return 0;
58 }
59
60 size_t tsize()
61 {
62 return (long[]).sizeof;
63 }
64
65 uint flags()
66 {
67 return 1;
68 }
69
70 TypeInfo next()
71 {
72 return typeid(long);
73 }
74 }
75
76
77 // ulong[]
78
79 class TypeInfo_Am : TypeInfo_Al
80 {
81 char[] toString() { return "ulong[]"; }
82
83 int compare(void *p1, void *p2)
84 {
85 ulong[] s1 = *cast(ulong[]*)p1;
86 ulong[] s2 = *cast(ulong[]*)p2;
87 size_t len = s1.length;
88
89 if (s2.length < len)
90 len = s2.length;
91 for (size_t u = 0; u < len; u++)
92 {
93 if (s1[u] < s2[u])
94 return -1;
95 else if (s1[u] > s2[u])
96 return 1;
97 }
98 if (s1.length < s2.length)
99 return -1;
100 else if (s1.length > s2.length)
101 return 1;
102 return 0;
103 }
104
105 TypeInfo next()
106 {
107 return typeid(ulong);
108 }
109 }