1 2 module rt.compiler.dmd.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 version (X86_64) override int argTypes(out TypeInfo arg1, out TypeInfo arg2) 72 { 73 return 0; 74 } 75 } 76 77 78 // ulong[] 79 80 class TypeInfo_Am : TypeInfo_Al 81 { 82 override char[] toString() { return "ulong[]"; } 83 84 override int compare(in void* p1, in void* p2) 85 { 86 ulong[] s1 = *cast(ulong[]*)p1; 87 ulong[] s2 = *cast(ulong[]*)p2; 88 size_t len = s1.length; 89 90 if (s2.length < len) 91 len = s2.length; 92 for (size_t u = 0; u < len; u++) 93 { 94 if (s1[u] < s2[u]) 95 return -1; 96 else if (s1[u] > s2[u]) 97 return 1; 98 } 99 if (s1.length < s2.length) 100 return -1; 101 else if (s1.length > s2.length) 102 return 1; 103 return 0; 104 } 105 106 override TypeInfo next() 107 { 108 return typeid(ulong); 109 } 110 }