annotate dmd/ComplexExp.d @ 187:b0d41ff5e0df

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