/usr/lib/gcc/x86_64-linux-gnu/5/include/d/rt/typeinfo/ti_Ag.d is in libphobos-5-dev 5.5.0-12ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | /**
* TypeInfo support code.
*
* Copyright: Copyright Digital Mars 2004 - 2009.
* License: $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
* Authors: Walter Bright
*/
/* Copyright Digital Mars 2004 - 2009.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
module rt.typeinfo.ti_Ag;
private import core.stdc.string;
private import rt.util.hash;
private import rt.util.string;
// byte[]
class TypeInfo_Ag : TypeInfo_Array
{
override bool opEquals(Object o) { return TypeInfo.opEquals(o); }
override string toString() const { return "byte[]"; }
override size_t getHash(in void* p) @trusted const
{
byte[] s = *cast(byte[]*)p;
return rt.util.hash.hashOf(s.ptr, s.length * byte.sizeof);
}
override bool equals(in void* p1, in void* p2) const
{
byte[] s1 = *cast(byte[]*)p1;
byte[] s2 = *cast(byte[]*)p2;
return s1.length == s2.length &&
memcmp(cast(byte *)s1, cast(byte *)s2, s1.length) == 0;
}
override int compare(in void* p1, in void* p2) const
{
byte[] s1 = *cast(byte[]*)p1;
byte[] s2 = *cast(byte[]*)p2;
size_t len = s1.length;
if (s2.length < len)
len = s2.length;
for (size_t u = 0; u < len; u++)
{
int result = s1[u] - s2[u];
if (result)
return result;
}
if (s1.length < s2.length)
return -1;
else if (s1.length > s2.length)
return 1;
return 0;
}
override @property inout(TypeInfo) next() inout
{
return cast(inout)typeid(byte);
}
}
// ubyte[]
class TypeInfo_Ah : TypeInfo_Ag
{
override string toString() const { return "ubyte[]"; }
override int compare(in void* p1, in void* p2) const
{
char[] s1 = *cast(char[]*)p1;
char[] s2 = *cast(char[]*)p2;
return dstrcmp(s1, s2);
}
override @property inout(TypeInfo) next() inout
{
return cast(inout)typeid(ubyte);
}
}
// void[]
class TypeInfo_Av : TypeInfo_Ah
{
override string toString() const { return "void[]"; }
override @property inout(TypeInfo) next() inout
{
return cast(inout)typeid(void);
}
}
// bool[]
class TypeInfo_Ab : TypeInfo_Ah
{
override string toString() const { return "bool[]"; }
override @property inout(TypeInfo) next() inout
{
return cast(inout)typeid(bool);
}
}
// char[]
class TypeInfo_Aa : TypeInfo_Ah
{
override string toString() const { return "char[]"; }
override size_t getHash(in void* p) @trusted const
{
char[] s = *cast(char[]*)p;
size_t hash = 0;
version (all)
{
foreach (char c; s)
hash = hash * 11 + c;
}
else
{
size_t len = s.length;
char *str = s;
while (1)
{
switch (len)
{
case 0:
return hash;
case 1:
hash *= 9;
hash += *cast(ubyte *)str;
return hash;
case 2:
hash *= 9;
hash += *cast(ushort *)str;
return hash;
case 3:
hash *= 9;
hash += (*cast(ushort *)str << 8) +
(cast(ubyte *)str)[2];
return hash;
default:
hash *= 9;
hash += *cast(uint *)str;
str += 4;
len -= 4;
break;
}
}
}
return hash;
}
override @property inout(TypeInfo) next() inout
{
return cast(inout)typeid(char);
}
}
// string
class TypeInfo_Aya : TypeInfo_Aa
{
override string toString() const { return "immutable(char)[]"; }
override @property inout(TypeInfo) next() inout
{
return cast(inout)typeid(immutable(char));
}
}
// const(char)[]
class TypeInfo_Axa : TypeInfo_Aa
{
override string toString() const { return "const(char)[]"; }
override @property inout(TypeInfo) next() inout
{
return cast(inout)typeid(const(char));
}
}
|