1 2 module rt.compiler.ldc.typeinfo.ti_Along; 3 4 private import tango.stdc.string : memcmp; 5 private import rt.compiler.util.hash; 6 7 // long[] 8 9 class TypeInfo_Al : TypeInfo_Array 10 { 11 override char[] toString() { return "long[]"; } 12 13 override hash_t getHash(in void* p) 14 { long[] s = *cast(long[]*)p; 15 size_t len = s.length; 16 auto str = s.ptr; 17 return rt_hash_str(str,len*long.sizeof,0); 18 } 19 20 override equals_t equals(in void* p1, in void* p2) 21 { 22 long[] s1 = *cast(long[]*)p1; 23 long[] s2 = *cast(long[]*)p2; 24 25 return s1.length == s2.length && 26 memcmp(cast(void *)s1, cast(void *)s2, s1.length * long.sizeof) == 0; 27 } 28 29 override int compare(in void* p1, in void* p2) 30 { 31 long[] s1 = *cast(long[]*)p1; 32 long[] s2 = *cast(long[]*)p2; 33 size_t len = s1.length; 34 35 if (s2.length < len) 36 len = s2.length; 37 for (size_t u = 0; u < len; u++) 38 { 39 if (s1[u] < s2[u]) 40 return -1; 41 else if (s1[u] > s2[u]) 42 return 1; 43 } 44 if (s1.length < s2.length) 45 return -1; 46 else if (s1.length > s2.length) 47 return 1; 48 return 0; 49 } 50 51 override size_t talign() 52 { 53 return (long[]).alignof; 54 } 55 56 override size_t tsize() 57 { 58 return (long[]).sizeof; 59 } 60 61 override uint flags() 62 { 63 return 1; 64 } 65 66 override TypeInfo next() 67 { 68 return typeid(long); 69 } 70 } 71 72 73 // ulong[] 74 75 class TypeInfo_Am : TypeInfo_Al 76 { 77 override char[] toString() { return "ulong[]"; } 78 79 override int compare(in void* p1, in void* p2) 80 { 81 ulong[] s1 = *cast(ulong[]*)p1; 82 ulong[] s2 = *cast(ulong[]*)p2; 83 size_t len = s1.length; 84 85 if (s2.length < len) 86 len = s2.length; 87 for (size_t u = 0; u < len; u++) 88 { 89 if (s1[u] < s2[u]) 90 return -1; 91 else if (s1[u] > s2[u]) 92 return 1; 93 } 94 if (s1.length < s2.length) 95 return -1; 96 else if (s1.length > s2.length) 97 return 1; 98 return 0; 99 } 100 101 override TypeInfo next() 102 { 103 return typeid(ulong); 104 } 105 }