Mercurial > projects > ldc
comparison druntime/src/compiler/dmd/typeinfo/ti_cfloat.d @ 759:d3eb054172f9
Added copy of druntime from DMD 2.020 modified for LDC.
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Tue, 11 Nov 2008 01:52:37 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
758:f04dde6e882c | 759:d3eb054172f9 |
---|---|
1 | |
2 // cfloat | |
3 | |
4 module rt.typeinfo.ti_cfloat; | |
5 | |
6 class TypeInfo_q : TypeInfo | |
7 { | |
8 override string toString() { return "cfloat"; } | |
9 | |
10 override hash_t getHash(in void* p) | |
11 { | |
12 return (cast(uint *)p)[0] + (cast(uint *)p)[1]; | |
13 } | |
14 | |
15 static equals_t _equals(cfloat f1, cfloat f2) | |
16 { | |
17 return f1 == f2; | |
18 } | |
19 | |
20 static int _compare(cfloat f1, cfloat f2) | |
21 { int result; | |
22 | |
23 if (f1.re < f2.re) | |
24 result = -1; | |
25 else if (f1.re > f2.re) | |
26 result = 1; | |
27 else if (f1.im < f2.im) | |
28 result = -1; | |
29 else if (f1.im > f2.im) | |
30 result = 1; | |
31 else | |
32 result = 0; | |
33 return result; | |
34 } | |
35 | |
36 override equals_t equals(in void* p1, in void* p2) | |
37 { | |
38 return _equals(*cast(cfloat *)p1, *cast(cfloat *)p2); | |
39 } | |
40 | |
41 override int compare(in void* p1, in void* p2) | |
42 { | |
43 return _compare(*cast(cfloat *)p1, *cast(cfloat *)p2); | |
44 } | |
45 | |
46 override size_t tsize() | |
47 { | |
48 return cfloat.sizeof; | |
49 } | |
50 | |
51 override void swap(void *p1, void *p2) | |
52 { | |
53 cfloat t; | |
54 | |
55 t = *cast(cfloat *)p1; | |
56 *cast(cfloat *)p1 = *cast(cfloat *)p2; | |
57 *cast(cfloat *)p2 = t; | |
58 } | |
59 | |
60 override void[] init() | |
61 { static cfloat r; | |
62 | |
63 return (cast(cfloat *)&r)[0 .. 1]; | |
64 } | |
65 } |