1 
2 // creal
3 
4 module rt.compiler.dmd.typeinfo.ti_creal;
5 private import rt.compiler.util.hash;
6 
7 class TypeInfo_c : TypeInfo
8 {
9     override char[] toString() { return "creal"; }
10 
11     override hash_t getHash(in void* p)
12     {
13         return rt_hash_str(p,creal.sizeof,0);
14     }
15 
16     static equals_t _equals(creal f1, creal f2)
17     {
18         return f1 == f2;
19     }
20 
21     static int _compare(creal f1, creal f2)
22     {   int result;
23 
24         if (f1.re < f2.re)
25             result = -1;
26         else if (f1.re > f2.re)
27             result = 1;
28         else if (f1.im < f2.im)
29             result = -1;
30         else if (f1.im > f2.im)
31             result = 1;
32         else
33             result = 0;
34         return result;
35     }
36 
37     override equals_t equals(in void* p1, in void* p2)
38     {
39         return _equals(*cast(creal *)p1, *cast(creal *)p2);
40     }
41 
42     override int compare(in void* p1, in void* p2)
43     {
44         return _compare(*cast(creal *)p1, *cast(creal *)p2);
45     }
46 
47     override size_t talign()
48     {
49         return creal.alignof;
50     }
51 
52     override size_t tsize()
53     {
54         return creal.sizeof;
55     }
56 
57     override void swap(void *p1, void *p2)
58     {
59         creal t;
60 
61         t = *cast(creal *)p1;
62         *cast(creal *)p1 = *cast(creal *)p2;
63         *cast(creal *)p2 = t;
64     }
65 
66     override void[] init()
67     {   static creal r;
68 
69         return (cast(creal *)&r)[0 .. 1];
70     }
71 
72     version (X86_64) override int argTypes(out TypeInfo arg1, out TypeInfo arg2)
73     {
74         arg1 = typeid(real);
75         arg2 = typeid(real);
76         return 0;
77     }
78 }