Mercurial > projects > ldc
annotate lphobos/typeinfo2/ti_Afloat.d @ 1644:9176437d98be
Add -linkonce-templates for emitting linkonce_odr syms instead of weak_odr.
author | Matti Niemenmaa <matti.niemenmaa+hg@iki.fi> |
---|---|
date | Tue, 09 Mar 2010 23:07:08 +0200 |
parents | b86e00b938a5 |
children |
rev | line source |
---|---|
61
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
1 /* |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
2 * Copyright (C) 2004-2005 by Digital Mars, www.digitalmars.com |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
3 * Written by Walter Bright |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
4 * |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
5 * This software is provided 'as-is', without any express or implied |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
6 * warranty. In no event will the authors be held liable for any damages |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
7 * arising from the use of this software. |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
8 * |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
9 * Permission is granted to anyone to use this software for any purpose, |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
10 * including commercial applications, and to alter it and redistribute it |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
11 * freely, in both source and binary form, subject to the following |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
12 * restrictions: |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
13 * |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
14 * o The origin of this software must not be misrepresented; you must not |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
15 * claim that you wrote the original software. If you use this software |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
16 * in a product, an acknowledgment in the product documentation would be |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
17 * appreciated but is not required. |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
18 * o Altered source versions must be plainly marked as such, and must not |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
19 * be misrepresented as being the original software. |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
20 * o This notice may not be removed or altered from any source |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
21 * distribution. |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
22 */ |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
23 |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
24 module typeinfo2.ti_Afloat; |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
25 |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
26 private import typeinfo1.ti_float; |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
27 |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
28 // float[] |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
29 |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
30 class TypeInfo_Af : TypeInfo |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
31 { |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
32 char[] toString() { return "float[]"; } |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
33 |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
34 hash_t getHash(void *p) |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
35 { float[] s = *cast(float[]*)p; |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
36 size_t len = s.length; |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
37 auto str = s.ptr; |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
38 hash_t hash = 0; |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
39 |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
40 while (len) |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
41 { |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
42 hash *= 9; |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
43 hash += *cast(uint *)str; |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
44 str++; |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
45 len--; |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
46 } |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
47 |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
48 return hash; |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
49 } |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
50 |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
51 int equals(void *p1, void *p2) |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
52 { |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
53 float[] s1 = *cast(float[]*)p1; |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
54 float[] s2 = *cast(float[]*)p2; |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
55 size_t len = s1.length; |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
56 |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
57 if (len != s2.length) |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
58 return 0; |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
59 for (size_t u = 0; u < len; u++) |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
60 { |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
61 int c = TypeInfo_f._equals(s1[u], s2[u]); |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
62 if (c == 0) |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
63 return 0; |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
64 } |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
65 return 1; |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
66 } |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
67 |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
68 int compare(void *p1, void *p2) |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
69 { |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
70 float[] s1 = *cast(float[]*)p1; |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
71 float[] s2 = *cast(float[]*)p2; |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
72 size_t len = s1.length; |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
73 |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
74 if (s2.length < len) |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
75 len = s2.length; |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
76 for (size_t u = 0; u < len; u++) |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
77 { |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
78 int c = TypeInfo_f._compare(s1[u], s2[u]); |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
79 if (c) |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
80 return c; |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
81 } |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
82 return cast(int)s1.length - cast(int)s2.length; |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
83 } |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
84 |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
85 size_t tsize() |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
86 { |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
87 return (float[]).sizeof; |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
88 } |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
89 |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
90 uint flags() |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
91 { |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
92 return 1; |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
93 } |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
94 |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
95 TypeInfo next() |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
96 { |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
97 return typeid(float); |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
98 } |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
99 } |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
100 |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
101 // ifloat[] |
62
b86e00b938a5
[svn r66] Added support for imaginary floating point types
lindquist
parents:
61
diff
changeset
|
102 |
61
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
103 class TypeInfo_Ao : TypeInfo_Af |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
104 { |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
105 char[] toString() { return "ifloat[]"; } |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
106 |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
107 TypeInfo next() |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
108 { |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
109 return typeid(ifloat); |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
110 } |
0258a7171a42
[svn r65] Added typeinfo implementations for float[], double[] and real[]
lindquist
parents:
diff
changeset
|
111 } |