annotate dmd/ComplexExp.d @ 178:e3afd1303184

Many small bugs fixed Made all classes derive from TObject to detect memory leaks (functionality is disabled for now) Began work on overriding backend memory allocations (to avoid memory leaks)
author korDen
date Sun, 17 Oct 2010 07:42:00 +0400
parents 94b6033c07f3
children b0d41ff5e0df
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
1 module dmd.ComplexExp;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
2
114
e28b18c23469 added a module dmd.common for commonly used stuff
Trass3r
parents: 72
diff changeset
3 import dmd.common;
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
4 import dmd.Expression;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
5 import dmd.InterState;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
6 import dmd.Type;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
7 import dmd.OutBuffer;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
8 import dmd.Loc;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
9 import dmd.Scope;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
10 import dmd.IRState;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
11 import dmd.HdrGenState;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
12 import dmd.Type;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
13 import dmd.TOK;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
14 import dmd.TY;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
15 import dmd.Port;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
16 import dmd.Complex;
129
010eb8f0e18d further work on dmd test suite
korDen
parents: 123
diff changeset
17 import dmd.expression.Util;
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
18
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
19 import dmd.backend.dt_t;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
20 import dmd.backend.elem;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
21 import dmd.backend.Util;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
22 import dmd.backend.TYM;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
23 import dmd.backend.mTY;
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
24
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
25 class ComplexExp : Expression
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
26 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
27 Complex!(real) value;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
28
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
29 this(Loc loc, Complex!(real) value, Type type)
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
30 {
178
e3afd1303184 Many small bugs fixed
korDen
parents: 175
diff changeset
31 register();
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
32 super(loc, TOK.TOKcomplex80, ComplexExp.sizeof);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
33 this.value = value;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
34 this.type = type;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
35 //printf("ComplexExp.ComplexExp(%s)\n", toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
36 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
37
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
38 override bool equals(Object o)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
39 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
40 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
41 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
42
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
43 override Expression semantic(Scope sc)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
44 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
45 if (!type)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
46 type = Type.tcomplex80;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
47 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
48 type = type.semantic(loc, sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
49 return this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
50 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
51
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
52 override Expression interpret(InterState istate)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
53 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
54 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
55 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
56
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
57 override string toChars()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
58 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
59 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
60 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
61
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
62 override ulong toInteger()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
63 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
64 return cast(ulong) toReal();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
65 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
66
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
67 override ulong toUInteger()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
68 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
69 return cast(long) toReal();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
70 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
71
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
72 override real toReal()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
73 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
74 return value.re;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
75 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
76
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
77 override real toImaginary()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
78 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
79 return value.im;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
80 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
81
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
82 override Complex!(real) toComplex()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
83 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
84 return value;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
85 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
86
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
87 override Expression castTo(Scope sc, Type t)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
88 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
89 Expression e = this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
90 if (type != t)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
91 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
92 if (type.iscomplex() && t.iscomplex())
174
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 129
diff changeset
93 {
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
94 e = copy();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
95 e.type = t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
96 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
97 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
98 e = Expression.castTo(sc, t);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
99 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
100 return e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
101 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
102
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
103 override int isConst()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
104 {
53
a8b50ff7f201 ForeachStatement.syntaxCopy
korDen
parents: 45
diff changeset
105 return 1;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
106 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
107
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
108 override bool isBool(bool result)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
109 {
123
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
110 if (result)
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
111 return value != Complex!(real).zero;
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
112 else
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
113 return value == Complex!(real).zero;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
114 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
115
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
116 override void toCBuffer(OutBuffer buf, HdrGenState* hgs)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
117 {
174
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 129
diff changeset
118 /* Print as:
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 129
diff changeset
119 * (re+imi)
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 129
diff changeset
120 */
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 129
diff changeset
121 version (IN_GCC) {
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 129
diff changeset
122 char buf1[sizeof(value) * 3 + 8 + 1];
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 129
diff changeset
123 char buf2[sizeof(value) * 3 + 8 + 1];
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 129
diff changeset
124 creall(value).format(buf1, sizeof(buf1));
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 129
diff changeset
125 cimagl(value).format(buf2, sizeof(buf2));
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 129
diff changeset
126 buf.printf("(%s+%si)", buf1, buf2);
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 129
diff changeset
127 } else {
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 129
diff changeset
128 buf.writeByte('(');
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 129
diff changeset
129 floatToBuffer(buf, type, value.re);
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 129
diff changeset
130 buf.writeByte('+');
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 129
diff changeset
131 floatToBuffer(buf, type, value.im);
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 129
diff changeset
132 buf.writestring("i)");
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 129
diff changeset
133 }
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
134 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
135
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
136 override void toMangleBuffer(OutBuffer buf)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
137 {
129
010eb8f0e18d further work on dmd test suite
korDen
parents: 123
diff changeset
138 buf.writeByte('c');
010eb8f0e18d further work on dmd test suite
korDen
parents: 123
diff changeset
139 real r = toReal();
010eb8f0e18d further work on dmd test suite
korDen
parents: 123
diff changeset
140 realToMangleBuffer(buf, r);
010eb8f0e18d further work on dmd test suite
korDen
parents: 123
diff changeset
141 buf.writeByte('c'); // separate the two
010eb8f0e18d further work on dmd test suite
korDen
parents: 123
diff changeset
142 r = toImaginary();
010eb8f0e18d further work on dmd test suite
korDen
parents: 123
diff changeset
143 realToMangleBuffer(buf, r);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
144 }
174
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 129
diff changeset
145
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
146 version (_DH) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
147 OutBuffer hexp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
148 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
149
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
150 override elem* toElem(IRState* irs)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
151 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
152 eve c;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
153 tym_t ty;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
154
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
155 //printf("ComplexExp.toElem(%p) %s\n", this, toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
156
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
157 ///memset(&c, 0, c.sizeof);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
158
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
159 ty = type.totym();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
160 switch (tybasic(ty))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
161 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
162 case TYcfloat:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
163 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
164 c.Vcfloat.re = cast(float) value.re;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
165 if (Port.isSignallingNan(value.re)) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
166 (cast(uint*)&c.Vcfloat.re)[0] &= 0xFFBFFFFFL;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
167 std.stdio.writeln("float.re is snan");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
168 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
169 c.Vcfloat.im = cast(float) value.im;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
170 if (Port.isSignallingNan(value.im)) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
171 (cast(uint*)&c.Vcfloat.im)[0] &= 0xFFBFFFFFL;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
172 std.stdio.writeln("float.im is snan");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
173 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
174 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
175 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
176
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
177 case TYcdouble:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
178 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
179 c.Vcdouble.re = cast(double) value.re;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
180 if (Port.isSignallingNan(value.re)) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
181 std.stdio.writeln("double.re is snan");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
182 (cast(uint*)&c.Vcdouble.re)[1] &= 0xFFF7FFFFL;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
183 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
184 c.Vcdouble.im = cast(double) value.im;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
185 if (Port.isSignallingNan(value.im)) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
186 (cast(uint*)&c.Vcdouble.im)[1] &= 0xFFF7FFFFL;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
187 std.stdio.writeln("double.im is snan");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
188 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
189 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
190 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
191
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
192 case TYcldouble:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
193 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
194 static if (true) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
195 c.Vcldouble = value;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
196 } else {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
197 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
198 ushort* p = cast(ushort*)&c.Vcldouble;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
199 for (int i = 0; i < (LNGDBLSIZE*2)/2; i++) printf("%04x ", p[i]);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
200 printf("\n");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
201 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
202 c.Vcldouble.im = im;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
203 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
204 ushort* p = cast(ushort*)&c.Vcldouble;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
205 for (int i = 0; i < (LNGDBLSIZE*2)/2; i++) printf("%04x ", p[i]);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
206 printf("\n");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
207 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
208 c.Vcldouble.re = re;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
209 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
210 ushort* p = cast(ushort*)&c.Vcldouble;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
211 for (int i = 0; i < (LNGDBLSIZE*2)/2; i++) printf("%04x ", p[i]);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
212 printf("\n");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
213 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
214 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
215 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
216 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
217
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
218 default:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
219 assert(0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
220 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
221 return el_const(ty, &c);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
222 }
174
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 129
diff changeset
223
175
94b6033c07f3 get rid of globals
korDen
parents: 174
diff changeset
224 static private __gshared char[6] zeropad;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
225
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
226 override dt_t** toDt(dt_t** pdt)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
227 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
228 //printf("ComplexExp.toDt() '%s'\n", toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
229 float fvalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
230 double dvalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
231 real evalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
232
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
233 switch (type.toBasetype().ty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
234 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
235 case Tcomplex32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
236 fvalue = value.re;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
237 pdt = dtnbytes(pdt,4,cast(char*)&fvalue);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
238 fvalue = value.im;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
239 pdt = dtnbytes(pdt,4,cast(char*)&fvalue);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
240 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
241
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
242 case Tcomplex64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
243 dvalue = value.re;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
244 pdt = dtnbytes(pdt,8,cast(char*)&dvalue);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
245 dvalue = value.im;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
246 pdt = dtnbytes(pdt,8,cast(char*)&dvalue);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
247 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
248
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
249 case Tcomplex80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
250 evalue = value.re;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
251 pdt = dtnbytes(pdt,REALSIZE - REALPAD,cast(char*)&evalue);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
252 pdt = dtnbytes(pdt,REALPAD,zeropad.ptr);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
253 evalue = value.im;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
254 pdt = dtnbytes(pdt,REALSIZE - REALPAD, cast(char*)&evalue);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
255 pdt = dtnbytes(pdt,REALPAD,zeropad.ptr);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
256 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
257
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
258 default:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
259 assert(0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
260 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
261 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
262 return pdt;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
263 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
264 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
265