1 /*
2  *  Copyright (C) 2004-2005 by Digital Mars, www.digitalmars.com
3  *  Written by Walter Bright
4  *
5  *  This software is provided 'as-is', without any express or implied
6  *  warranty. In no event will the authors be held liable for any damages
7  *  arising from the use of this software.
8  *
9  *  Permission is granted to anyone to use this software for any purpose,
10  *  including commercial applications, and to alter it and redistribute it
11  *  freely, in both source and binary form, subject to the following
12  *  restrictions:
13  *
14  *  o  The origin of this software must not be misrepresented; you must not
15  *     claim that you wrote the original software. If you use this software
16  *     in a product, an acknowledgment in the product documentation would be
17  *     appreciated but is not required.
18  *  o  Altered source versions must be plainly marked as such, and must not
19  *     be misrepresented as being the original software.
20  *  o  This notice may not be removed or altered from any source
21  *     distribution.
22  */
23 
24 module rt.compiler.dmd.typeinfo.ti_C;
25 
26 // Object
27 
28 class TypeInfo_C : TypeInfo
29 {
30     override hash_t getHash(in void* p)
31     {
32         Object o = *cast(Object*)p;
33         return o ? o.toHash() : cast(hash_t)0xdeadbeef;
34     }
35 
36     override equals_t equals(in void* p1, in void* p2)
37     {
38         Object o1 = *cast(Object*)p1;
39         Object o2 = *cast(Object*)p2;
40 
41         return o1 == o2;
42     }
43 
44     override int compare(in void* p1, in void* p2)
45     {
46         Object o1 = *cast(Object*)p1;
47         Object o2 = *cast(Object*)p2;
48         int c = 0;
49 
50         // Regard null references as always being "less than"
51         if (!(o1 is o2))
52         {
53             if (o1)
54             {   if (!o2)
55                     c = 1;
56                 else
57                     c = o1.opCmp(o2);
58             }
59             else
60                 c = -1;
61         }
62         return c;
63     }
64 
65     override size_t talign()
66     {
67         return Object.alignof;
68     }
69 
70     override size_t tsize()
71     {
72         return Object.sizeof;
73     }
74 
75     override uint flags()
76     {
77         return 1;
78     }
79 }