Mercurial > projects > ldc
comparison lphobos/typeinfo1/ti_cfloat.d @ 107:3efbcc81ba45 trunk
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
Added typeinfo ti_C.
Did some changes to the way expressions that have both lvalue and rvalue LLVM values are handled.
author | lindquist |
---|---|
date | Tue, 20 Nov 2007 00:02:35 +0100 |
parents | |
children | 79c9ac745fbc |
comparison
equal
deleted
inserted
replaced
106:5b5194b25f33 | 107:3efbcc81ba45 |
---|---|
1 | |
2 // cfloat | |
3 | |
4 module std.typeinfo.ti_cfloat; | |
5 | |
6 class TypeInfo_q : TypeInfo | |
7 { | |
8 char[] toString() { return "cfloat"; } | |
9 | |
10 hash_t getHash(void *p) | |
11 { | |
12 return (cast(uint *)p)[0] + (cast(uint *)p)[1]; | |
13 } | |
14 | |
15 static int _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 int equals(void *p1, void *p2) | |
37 { | |
38 return _equals(*cast(cfloat *)p1, *cast(cfloat *)p2); | |
39 } | |
40 | |
41 int compare(void *p1, void *p2) | |
42 { | |
43 return _compare(*cast(cfloat *)p1, *cast(cfloat *)p2); | |
44 } | |
45 | |
46 size_t tsize() | |
47 { | |
48 return cfloat.sizeof; | |
49 } | |
50 | |
51 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 void[] init() | |
61 { static cfloat r; | |
62 | |
63 return (cast(cfloat *)&r)[0 .. 1]; | |
64 } | |
65 } | |
66 |