Mercurial > projects > ldc
comparison runtime/internal/typeinfo/ti_Aint.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_Aint; | |
3 | |
4 private import tango.stdc.string; | |
5 | |
6 // int[] | |
7 | |
8 class TypeInfo_Ai : TypeInfo_Array | |
9 { | |
10 char[] toString() { return "int[]"; } | |
11 | |
12 hash_t getHash(void *p) | |
13 { int[] s = *cast(int[]*)p; | |
14 auto 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; | |
22 str++; | |
23 len--; | |
24 } | |
25 | |
26 return hash; | |
27 } | |
28 | |
29 int equals(void *p1, void *p2) | |
30 { | |
31 int[] s1 = *cast(int[]*)p1; | |
32 int[] s2 = *cast(int[]*)p2; | |
33 | |
34 return s1.length == s2.length && | |
35 memcmp(cast(void *)s1, cast(void *)s2, s1.length * int.sizeof) == 0; | |
36 } | |
37 | |
38 int compare(void *p1, void *p2) | |
39 { | |
40 int[] s1 = *cast(int[]*)p1; | |
41 int[] s2 = *cast(int[]*)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 int result = s1[u] - s2[u]; | |
49 if (result) | |
50 return result; | |
51 } | |
52 if (s1.length < s2.length) | |
53 return -1; | |
54 else if (s1.length > s2.length) | |
55 return 1; | |
56 return 0; | |
57 } | |
58 | |
59 size_t tsize() | |
60 { | |
61 return (int[]).sizeof; | |
62 } | |
63 | |
64 uint flags() | |
65 { | |
66 return 1; | |
67 } | |
68 | |
69 TypeInfo next() | |
70 { | |
71 return typeid(int); | |
72 } | |
73 } | |
74 | |
75 // uint[] | |
76 | |
77 class TypeInfo_Ak : TypeInfo_Ai | |
78 { | |
79 char[] toString() { return "uint[]"; } | |
80 | |
81 int compare(void *p1, void *p2) | |
82 { | |
83 uint[] s1 = *cast(uint[]*)p1; | |
84 uint[] s2 = *cast(uint[]*)p2; | |
85 size_t len = s1.length; | |
86 | |
87 if (s2.length < len) | |
88 len = s2.length; | |
89 for (size_t u = 0; u < len; u++) | |
90 { | |
91 int result = s1[u] - s2[u]; | |
92 if (result) | |
93 return result; | |
94 } | |
95 if (s1.length < s2.length) | |
96 return -1; | |
97 else if (s1.length > s2.length) | |
98 return 1; | |
99 return 0; | |
100 } | |
101 | |
102 TypeInfo next() | |
103 { | |
104 return typeid(uint); | |
105 } | |
106 } | |
107 | |
108 // dchar[] | |
109 | |
110 class TypeInfo_Aw : TypeInfo_Ak | |
111 { | |
112 char[] toString() { return "dchar[]"; } | |
113 | |
114 TypeInfo next() | |
115 { | |
116 return typeid(dchar); | |
117 } | |
118 } | |
119 |