1 module rt.compiler.dmd.typeinfo.ti_AC;
2 private import rt.compiler.util.hash;
3 
4 // Object[]
5 
6 class TypeInfo_AC : TypeInfo_Array
7 {
8     override hash_t getHash(in void* p)
9     {   Object[] s = *cast(Object[]*)p;
10         hash_t hash = 0;
11 
12         foreach (Object o; s)
13         {
14             if (o){
15                 hash = rt_hash_combine(o.toHash(),hash);
16             } else {
17                 hash = rt_hash_combine(cast(hash_t)0xdeadbeef,hash);
18             }
19         }
20         return hash;
21     }
22 
23     override equals_t equals(in void* p1, in void* p2)
24     {
25         Object[] s1 = *cast(Object[]*)p1;
26         Object[] s2 = *cast(Object[]*)p2;
27 
28         if (s1.length == s2.length)
29         {
30             for (size_t u = 0; u < s1.length; u++)
31             {   Object o1 = s1[u];
32                 Object o2 = s2[u];
33 
34                 // Do not pass null's to Object.opEquals()
35                 if (o1 is o2 ||
36                     (!(o1 is null) && !(o2 is null) && o1.opEquals(o2)))
37                     continue;
38                 return false;
39             }
40             return true;
41         }
42         return false;
43     }
44 
45     override int compare(in void* p1, in void* p2)
46     {
47         Object[] s1 = *cast(Object[]*)p1;
48         Object[] s2 = *cast(Object[]*)p2;
49         ptrdiff_t c;
50 
51         c = cast(ptrdiff_t)s1.length - cast(ptrdiff_t)s2.length;
52         if (c == 0)
53         {
54             for (size_t u = 0; u < s1.length; u++)
55             {   Object o1 = s1[u];
56                 Object o2 = s2[u];
57 
58                 if (o1 is o2)
59                     continue;
60 
61                 // Regard null references as always being "less than"
62                 if (o1)
63                 {
64                     if (!o2)
65                     {   c = 1;
66                         break;
67                     }
68                     c = o1.opCmp(o2);
69                     if (c)
70                         break;
71                 }
72                 else
73                 {   c = -1;
74                     break;
75                 }
76             }
77         }
78         if (c < 0)
79             c = -1;
80         else if (c > 0)
81             c = 1;
82         return 0;
83     }
84 
85     override size_t talign()
86     {
87         return (Object[]).alignof;
88     }
89 
90     override size_t tsize()
91     {
92         return (Object[]).sizeof;
93     }
94 
95     override uint flags()
96     {
97         return 1;
98     }
99 
100     override TypeInfo next()
101     {
102         return typeid(Object);
103     }
104 
105     version (X86_64) override int argTypes(out TypeInfo arg1, out TypeInfo arg2)
106     {
107         return 0;
108     }
109 }