Mercurial > projects > ldc
comparison lphobos/typeinfo1/ti_real.d @ 58:2c3cd3596187 trunk
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
Added initial support for CatExp aka 'a ~ b'
Fixed global constant static arrays initialized with string literals
Fixed casting any dynamic array to void*
Fixed new expression with temporary storage
Fixed alias declarations in function scope
Fixed relational comparisons of pointers
author | lindquist |
---|---|
date | Thu, 25 Oct 2007 09:02:55 +0200 |
parents | lphobos/typeinfo/ti_real.d@06ccc817acd4 |
children |
comparison
equal
deleted
inserted
replaced
57:a9d29e9f1fed | 58:2c3cd3596187 |
---|---|
1 | |
2 // real | |
3 | |
4 module typeinfo1.ti_real; | |
5 | |
6 class TypeInfo_e : TypeInfo | |
7 { | |
8 char[] toString() { return "real"; } | |
9 | |
10 hash_t getHash(void *p) | |
11 { | |
12 return (cast(uint *)p)[0] + (cast(uint *)p)[1] + (cast(ushort *)p)[4]; | |
13 } | |
14 | |
15 static bool _isnan(real r) | |
16 { | |
17 return r !<>= 0; | |
18 } | |
19 | |
20 static int _equals(real f1, real f2) | |
21 { | |
22 return f1 == f2 || | |
23 (_isnan(f1) && _isnan(f2)); | |
24 } | |
25 | |
26 static int _compare(real d1, real d2) | |
27 { | |
28 if (d1 !<>= d2) // if either are NaN | |
29 { | |
30 if (_isnan(d1)) | |
31 { if (_isnan(d2)) | |
32 return 0; | |
33 return -1; | |
34 } | |
35 return 1; | |
36 } | |
37 return (d1 == d2) ? 0 : ((d1 < d2) ? -1 : 1); | |
38 } | |
39 | |
40 int equals(void *p1, void *p2) | |
41 { | |
42 return _equals(*cast(real *)p1, *cast(real *)p2); | |
43 } | |
44 | |
45 int compare(void *p1, void *p2) | |
46 { | |
47 return _compare(*cast(real *)p1, *cast(real *)p2); | |
48 } | |
49 | |
50 size_t tsize() | |
51 { | |
52 return real.sizeof; | |
53 } | |
54 | |
55 void swap(void *p1, void *p2) | |
56 { | |
57 real t; | |
58 | |
59 t = *cast(real *)p1; | |
60 *cast(real *)p1 = *cast(real *)p2; | |
61 *cast(real *)p2 = t; | |
62 } | |
63 | |
64 void[] init() | |
65 { static real r; | |
66 | |
67 return (&r)[0 .. 1]; | |
68 } | |
69 } | |
70 |