annotate dmd/TypeBasic.d @ 134:4251f96733f4 dmd2037

Fix of the hopefully last regression with dmd2.037
author Eldar Insafutdinov <e.insafutdinov@gmail.com>
date Sat, 11 Sep 2010 13:03:39 +0100
parents 60bb0fe4563e
children 0c8cc2a10f99
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1 module dmd.TypeBasic;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2
114
e28b18c23469 added a module dmd.common for commonly used stuff
Trass3r
parents: 96
diff changeset
3 import dmd.common;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
4 import dmd.Type;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
5 import dmd.Id;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
6 import dmd.MOD;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
7 import dmd.TOK;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
8 import dmd.Token;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
9 import dmd.TFLAGS;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
10 import dmd.TY;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
11 import dmd.Loc;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
12 import dmd.Scope;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
13 import dmd.Expression;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
14 import dmd.IntegerExp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
15 import dmd.Identifier;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
16 import dmd.OutBuffer;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
17 import dmd.HdrGenState;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
18 import dmd.CppMangleState;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
19 import dmd.MATCH;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
20 import dmd.RealExp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
21 import dmd.ComplexExp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
22 import dmd.Util;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
23 import dmd.Port;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
24 import dmd.Complex;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
25
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
26 class TypeBasic : Type
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
27 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
28 string dstring;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
29 uint flags;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
30
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
31 this(TY ty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
32 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
33 super(ty);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
34
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
35 enum TFLAGSintegral = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
36 enum TFLAGSfloating = 2;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
37 enum TFLAGSunsigned = 4;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
38 enum TFLAGSreal = 8;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
39 enum TFLAGSimaginary = 0x10;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
40 enum TFLAGScomplex = 0x20;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
41
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
42 string d;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
43
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
44 uint flags = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
45 switch (ty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
46 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
47 case TY.Tvoid: d = Token.toChars(TOK.TOKvoid);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
48 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
49
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
50 case TY.Tint8: d = Token.toChars(TOK.TOKint8);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
51 flags |= TFLAGSintegral;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
52 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
53
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
54 case TY.Tuns8: d = Token.toChars(TOK.TOKuns8);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
55 flags |= TFLAGSintegral | TFLAGSunsigned;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
56 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
57
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
58 case TY.Tint16: d = Token.toChars(TOK.TOKint16);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
59 flags |= TFLAGSintegral;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
60 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
61
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
62 case TY.Tuns16: d = Token.toChars(TOK.TOKuns16);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
63 flags |= TFLAGSintegral | TFLAGSunsigned;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
64 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
65
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
66 case TY.Tint32: d = Token.toChars(TOK.TOKint32);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
67 flags |= TFLAGSintegral;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
68 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
69
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
70 case TY.Tuns32: d = Token.toChars(TOK.TOKuns32);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
71 flags |= TFLAGSintegral | TFLAGSunsigned;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
72 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
73
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
74 case TY.Tfloat32: d = Token.toChars(TOK.TOKfloat32);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
75 flags |= TFLAGSfloating | TFLAGSreal;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
76 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
77
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
78 case TY.Tint64: d = Token.toChars(TOK.TOKint64);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
79 flags |= TFLAGSintegral;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
80 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
81
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
82 case TY.Tuns64: d = Token.toChars(TOK.TOKuns64);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
83 flags |= TFLAGSintegral | TFLAGSunsigned;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
84 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
85
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
86 case TY.Tfloat64: d = Token.toChars(TOK.TOKfloat64);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
87 flags |= TFLAGSfloating | TFLAGSreal;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
88 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
89
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
90 case TY.Tfloat80: d = Token.toChars(TOK.TOKfloat80);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
91 flags |= TFLAGSfloating | TFLAGSreal;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
92 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
93
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
94 case TY.Timaginary32: d = Token.toChars(TOK.TOKimaginary32);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
95 flags |= TFLAGSfloating | TFLAGSimaginary;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
96 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
97
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
98 case TY.Timaginary64: d = Token.toChars(TOK.TOKimaginary64);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
99 flags |= TFLAGSfloating | TFLAGSimaginary;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
100 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
101
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
102 case TY.Timaginary80: d = Token.toChars(TOK.TOKimaginary80);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
103 flags |= TFLAGSfloating | TFLAGSimaginary;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
104 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
105
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
106 case TY.Tcomplex32: d = Token.toChars(TOK.TOKcomplex32);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
107 flags |= TFLAGSfloating | TFLAGScomplex;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
108 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
109
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
110 case TY.Tcomplex64: d = Token.toChars(TOK.TOKcomplex64);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
111 flags |= TFLAGSfloating | TFLAGScomplex;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
112 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
113
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
114 case TY.Tcomplex80: d = Token.toChars(TOK.TOKcomplex80);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
115 flags |= TFLAGSfloating | TFLAGScomplex;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
116 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
117
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
118 case TY.Tbool: d = "bool";
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
119 flags |= TFLAGSintegral | TFLAGSunsigned;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
120 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
121
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
122 case TY.Tascii: d = Token.toChars(TOK.TOKchar);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
123 flags |= TFLAGSintegral | TFLAGSunsigned;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
124 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
125
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
126 case TY.Twchar: d = Token.toChars(TOK.TOKwchar);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
127 flags |= TFLAGSintegral | TFLAGSunsigned;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
128 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
129
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
130 case TY.Tdchar: d = Token.toChars(TOK.TOKdchar);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
131 flags |= TFLAGSintegral | TFLAGSunsigned;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
132 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
133 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
134
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
135 this.dstring = d;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
136 this.flags = flags;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
137 merge();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
138 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
139
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
140 version (DumbClone) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
141 } else {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
142 Type clone()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
143 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
144 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
145 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
146 }
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 22
diff changeset
147 override Type syntaxCopy()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
148 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
149 // No semantic analysis done on basic types, no need to copy
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
150 return this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
151 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
152
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 22
diff changeset
153 override ulong size(Loc loc)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
154 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
155 uint size;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
156
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
157 //printf("TypeBasic.size()\n");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
158 switch (ty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
159 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
160 case TY.Tint8:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
161 case TY.Tuns8: size = 1; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
162 case TY.Tint16:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
163 case TY.Tuns16: size = 2; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
164 case TY.Tint32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
165 case TY.Tuns32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
166 case TY.Tfloat32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
167 case TY.Timaginary32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
168 size = 4; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
169 case TY.Tint64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
170 case TY.Tuns64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
171 case TY.Tfloat64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
172 case TY.Timaginary64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
173 size = 8; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
174 case TY.Tfloat80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
175 case TY.Timaginary80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
176 size = REALSIZE; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
177 case TY.Tcomplex32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
178 size = 8; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
179 case TY.Tcomplex64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
180 size = 16; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
181 case TY.Tcomplex80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
182 size = REALSIZE * 2; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
183
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
184 case TY.Tvoid:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
185 //size = Type.size(); // error message
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
186 size = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
187 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
188
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
189 case TY.Tbool: size = 1; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
190 case TY.Tascii: size = 1; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
191 case TY.Twchar: size = 2; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
192 case TY.Tdchar: size = 4; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
193
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
194 default:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
195 assert(0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
196 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
197 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
198
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
199 //printf("TypeBasic.size() = %d\n", size);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
200 return size;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
201 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
202
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 22
diff changeset
203 override uint alignsize()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
204 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
205 uint sz;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
206
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
207 switch (ty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
208 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
209 case TY.Tfloat80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
210 case TY.Timaginary80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
211 case TY.Tcomplex80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
212 sz = REALALIGNSIZE;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
213 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
214
22
fd4acc376c45 Implemented object file output and linking on linux.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
215 version (POSIX) { ///TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
216 case TY.Tint64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
217 case TY.Tuns64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
218 case TY.Tfloat64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
219 case TY.Timaginary64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
220 case TY.Tcomplex32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
221 case TY.Tcomplex64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
222 sz = 4;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
223 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
224 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
225
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
226 default:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
227 sz = cast(uint)size(Loc(0)); ///
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
228 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
229 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
230
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
231 return sz;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
232 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
233
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 22
diff changeset
234 override Expression getProperty(Loc loc, Identifier ident)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
235 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
236 Expression e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
237 long ivalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
238 real fvalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
239
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
240 //printf("TypeBasic.getProperty('%s')\n", ident.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
241 if (ident is Id.max)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
242 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
243 switch (ty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
244 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
245 case TY.Tint8: ivalue = byte.max; goto Livalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
246 case TY.Tuns8: ivalue = ubyte.max; goto Livalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
247 case TY.Tint16: ivalue = short.max; goto Livalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
248 case TY.Tuns16: ivalue = ushort.max; goto Livalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
249 case TY.Tint32: ivalue = int.max; goto Livalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
250 case TY.Tuns32: ivalue = uint.max; goto Livalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
251 case TY.Tint64: ivalue = long.max; goto Livalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
252 case TY.Tuns64: ivalue = ulong.max; goto Livalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
253 case TY.Tbool: ivalue = bool.max; goto Livalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
254 case TY.Tchar: ivalue = char.max; goto Livalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
255 case TY.Twchar: ivalue = wchar.max; goto Livalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
256 case TY.Tdchar: ivalue = 0x10FFFF; goto Livalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
257 case TY.Tcomplex32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
258 case TY.Timaginary32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
259 case TY.Tfloat32: fvalue = float.max; goto Lfvalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
260 case TY.Tcomplex64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
261 case TY.Timaginary64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
262 case TY.Tfloat64: fvalue = double.max;goto Lfvalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
263 case TY.Tcomplex80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
264 case TY.Timaginary80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
265 case TY.Tfloat80: fvalue = real.max; goto Lfvalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
266 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
267 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
268 else if (ident is Id.min)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
269 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
270 switch (ty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
271 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
272 case TY.Tint8: ivalue = byte.min; goto Livalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
273 case TY.Tuns8: ivalue = ubyte.min; goto Livalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
274 case TY.Tint16: ivalue = short.min; goto Livalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
275 case TY.Tuns16: ivalue = ushort.min; goto Livalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
276 case TY.Tint32: ivalue = int.min; goto Livalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
277 case TY.Tuns32: ivalue = uint.min; goto Livalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
278 case TY.Tint64: ivalue = long.min; goto Livalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
279 case TY.Tuns64: ivalue = ulong.min; goto Livalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
280 case TY.Tbool: ivalue = bool.min; goto Livalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
281 case TY.Tchar: ivalue = char.min; goto Livalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
282 case TY.Twchar: ivalue = wchar.min; goto Livalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
283 case TY.Tdchar: ivalue = dchar.min; goto Livalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
284 case TY.Tcomplex32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
285 case TY.Timaginary32:
96
acd69f84627e further work
Trass3r
parents: 72
diff changeset
286 case Tfloat32:
acd69f84627e further work
Trass3r
parents: 72
diff changeset
287 case Tcomplex64:
acd69f84627e further work
Trass3r
parents: 72
diff changeset
288 case Timaginary64:
acd69f84627e further work
Trass3r
parents: 72
diff changeset
289 case Tfloat64:
acd69f84627e further work
Trass3r
parents: 72
diff changeset
290 case Tcomplex80:
acd69f84627e further work
Trass3r
parents: 72
diff changeset
291 case Timaginary80:
acd69f84627e further work
Trass3r
parents: 72
diff changeset
292 case Tfloat80:
acd69f84627e further work
Trass3r
parents: 72
diff changeset
293 // For backwards compatibility - eventually, deprecate
acd69f84627e further work
Trass3r
parents: 72
diff changeset
294 goto Lmin_normal;
acd69f84627e further work
Trass3r
parents: 72
diff changeset
295 }
acd69f84627e further work
Trass3r
parents: 72
diff changeset
296 }
acd69f84627e further work
Trass3r
parents: 72
diff changeset
297 else if (ident == Id.min_normal)
acd69f84627e further work
Trass3r
parents: 72
diff changeset
298 {
acd69f84627e further work
Trass3r
parents: 72
diff changeset
299 Lmin_normal:
acd69f84627e further work
Trass3r
parents: 72
diff changeset
300 switch (ty)
acd69f84627e further work
Trass3r
parents: 72
diff changeset
301 {
acd69f84627e further work
Trass3r
parents: 72
diff changeset
302 case Tcomplex32:
acd69f84627e further work
Trass3r
parents: 72
diff changeset
303 case Timaginary32:
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
304 case TY.Tfloat32: fvalue = float.min; goto Lfvalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
305 case TY.Tcomplex64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
306 case TY.Timaginary64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
307 case TY.Tfloat64: fvalue = double.min; goto Lfvalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
308 case TY.Tcomplex80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
309 case TY.Timaginary80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
310 case TY.Tfloat80: fvalue = real.min; goto Lfvalue;
134
4251f96733f4 Fix of the hopefully last regression with dmd2.037
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
311 default:
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
312 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
313 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
314 else if (ident is Id.nan)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
315 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
316 switch (ty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
317 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
318 case TY.Tcomplex32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
319 case TY.Tcomplex64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
320 case TY.Tcomplex80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
321 case TY.Timaginary32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
322 case TY.Timaginary64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
323 case TY.Timaginary80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
324 case TY.Tfloat32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
325 case TY.Tfloat64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
326 case TY.Tfloat80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
327 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
328 fvalue = real.nan;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
329 goto Lfvalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
330 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
331 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
332 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
333 else if (ident is Id.infinity)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
334 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
335 switch (ty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
336 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
337 case TY.Tcomplex32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
338 case TY.Tcomplex64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
339 case TY.Tcomplex80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
340 case TY.Timaginary32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
341 case TY.Timaginary64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
342 case TY.Timaginary80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
343 case TY.Tfloat32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
344 case TY.Tfloat64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
345 case TY.Tfloat80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
346 fvalue = real.infinity;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
347 goto Lfvalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
348 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
349 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
350 else if (ident is Id.dig)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
351 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
352 switch (ty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
353 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
354 case TY.Tcomplex32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
355 case TY.Timaginary32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
356 case TY.Tfloat32: ivalue = float.dig; goto Lint;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
357 case TY.Tcomplex64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
358 case TY.Timaginary64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
359 case TY.Tfloat64: ivalue = double.dig; goto Lint;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
360 case TY.Tcomplex80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
361 case TY.Timaginary80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
362 case TY.Tfloat80: ivalue = real.dig; goto Lint;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
363 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
364 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
365 else if (ident is Id.epsilon)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
366 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
367 switch (ty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
368 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
369 case TY.Tcomplex32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
370 case TY.Timaginary32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
371 case TY.Tfloat32: fvalue = float.epsilon; goto Lfvalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
372 case TY.Tcomplex64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
373 case TY.Timaginary64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
374 case TY.Tfloat64: fvalue = double.epsilon; goto Lfvalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
375 case TY.Tcomplex80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
376 case TY.Timaginary80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
377 case TY.Tfloat80: fvalue = real.epsilon; goto Lfvalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
378 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
379 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
380 else if (ident is Id.mant_dig)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
381 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
382 switch (ty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
383 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
384 case TY.Tcomplex32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
385 case TY.Timaginary32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
386 case TY.Tfloat32: ivalue = float.mant_dig; goto Lint;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
387 case TY.Tcomplex64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
388 case TY.Timaginary64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
389 case TY.Tfloat64: ivalue = double.mant_dig; goto Lint;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
390 case TY.Tcomplex80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
391 case TY.Timaginary80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
392 case TY.Tfloat80: ivalue = real.mant_dig; goto Lint;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
393 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
394 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
395 else if (ident is Id.max_10_exp)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
396 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
397 switch (ty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
398 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
399 case TY.Tcomplex32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
400 case TY.Timaginary32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
401 case TY.Tfloat32: ivalue = float.max_10_exp; goto Lint;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
402 case TY.Tcomplex64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
403 case TY.Timaginary64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
404 case TY.Tfloat64: ivalue = double.max_10_exp; goto Lint;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
405 case TY.Tcomplex80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
406 case TY.Timaginary80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
407 case TY.Tfloat80: ivalue = real.max_10_exp; goto Lint;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
408 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
409 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
410 else if (ident is Id.max_exp)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
411 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
412 switch (ty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
413 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
414 case TY.Tcomplex32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
415 case TY.Timaginary32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
416 case TY.Tfloat32: ivalue = float.max_exp; goto Lint;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
417 case TY.Tcomplex64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
418 case TY.Timaginary64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
419 case TY.Tfloat64: ivalue = double.max_exp; goto Lint;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
420 case TY.Tcomplex80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
421 case TY.Timaginary80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
422 case TY.Tfloat80: ivalue = real.max_exp; goto Lint;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
423 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
424 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
425 else if (ident is Id.min_10_exp)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
426 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
427 switch (ty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
428 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
429 case TY.Tcomplex32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
430 case TY.Timaginary32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
431 case TY.Tfloat32: ivalue = float.min_10_exp; goto Lint;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
432 case TY.Tcomplex64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
433 case TY.Timaginary64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
434 case TY.Tfloat64: ivalue = double.min_10_exp; goto Lint;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
435 case TY.Tcomplex80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
436 case TY.Timaginary80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
437 case TY.Tfloat80: ivalue = real.min_10_exp; goto Lint;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
438 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
439 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
440 else if (ident is Id.min_exp)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
441 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
442 switch (ty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
443 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
444 case TY.Tcomplex32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
445 case TY.Timaginary32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
446 case TY.Tfloat32: ivalue = float.min_exp; goto Lint;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
447 case TY.Tcomplex64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
448 case TY.Timaginary64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
449 case TY.Tfloat64: ivalue = double.min_exp; goto Lint;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
450 case TY.Tcomplex80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
451 case TY.Timaginary80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
452 case TY.Tfloat80: ivalue = real.min_exp; goto Lint;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
453 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
454 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
455
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
456 Ldefault:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
457 return Type.getProperty(loc, ident);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
458
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
459 Livalue:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
460 e = new IntegerExp(loc, ivalue, this);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
461 return e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
462
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
463 Lfvalue:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
464 if (isreal() || isimaginary())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
465 e = new RealExp(loc, fvalue, this);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
466 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
467 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
468 Complex!(real) cvalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
469 cvalue.re = fvalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
470 cvalue.im = fvalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
471
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
472 //for (int i = 0; i < 20; i++)
96
acd69f84627e further work
Trass3r
parents: 72
diff changeset
473 // printf("%02x ", ((unsigned char *)&cvalue)[i]);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
474 //printf("\n");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
475 e = new ComplexExp(loc, cvalue, this);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
476 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
477 return e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
478
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
479 Lint:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
480 e = new IntegerExp(loc, ivalue, Type.tint32);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
481 return e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
482 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
483
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 22
diff changeset
484 override Expression dotExp(Scope sc, Expression e, Identifier ident)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
485 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
486 version (LOGDOTEXP) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
487 printf("TypeBasic.dotExp(e = '%s', ident = '%s')\n", e.toChars(), ident.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
488 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
489 Type t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
490
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
491 if (ident is Id.re)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
492 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
493 switch (ty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
494 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
495 case TY.Tcomplex32: t = tfloat32; goto L1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
496 case TY.Tcomplex64: t = tfloat64; goto L1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
497 case TY.Tcomplex80: t = tfloat80; goto L1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
498 L1:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
499 e = e.castTo(sc, t);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
500 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
501
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
502 case TY.Tfloat32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
503 case TY.Tfloat64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
504 case TY.Tfloat80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
505 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
506
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
507 case TY.Timaginary32: t = tfloat32; goto L2;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
508 case TY.Timaginary64: t = tfloat64; goto L2;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
509 case TY.Timaginary80: t = tfloat80; goto L2;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
510 L2:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
511 e = new RealExp(Loc(0), 0.0, t);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
512 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
513
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
514 default:
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
515 e = Type.getProperty(e.loc, ident);
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
516 break;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
517 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
518 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
519 else if (ident is Id.im)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
520 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
521 Type t2;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
522
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
523 switch (ty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
524 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
525 case TY.Tcomplex32: t = timaginary32; t2 = tfloat32; goto L3;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
526 case TY.Tcomplex64: t = timaginary64; t2 = tfloat64; goto L3;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
527 case TY.Tcomplex80: t = timaginary80; t2 = tfloat80; goto L3;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
528 L3:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
529 e = e.castTo(sc, t);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
530 e.type = t2;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
531 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
532
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
533 case TY.Timaginary32: t = tfloat32; goto L4;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
534 case TY.Timaginary64: t = tfloat64; goto L4;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
535 case TY.Timaginary80: t = tfloat80; goto L4;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
536 L4:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
537 e = e.copy();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
538 e.type = t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
539 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
540
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
541 case TY.Tfloat32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
542 case TY.Tfloat64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
543 case TY.Tfloat80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
544 e = new RealExp(Loc(0), 0.0, this);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
545 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
546
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
547 default:
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
548 e = Type.getProperty(e.loc, ident);
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
549 break;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
550 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
551 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
552 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
553 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
554 return Type.dotExp(sc, e, ident);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
555 }
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
556 e = e.semantic(sc);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
557 return e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
558 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
559
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 22
diff changeset
560 override string toChars()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
561 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
562 return Type.toChars();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
563 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
564
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 22
diff changeset
565 override void toCBuffer2(OutBuffer buf, HdrGenState* hgs, MOD mod)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
566 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
567 //printf("TypeBasic.toCBuffer2(mod = %d, this.mod = %d)\n", mod, this.mod);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
568 if (mod != this.mod)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
569 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
570 toCBuffer3(buf, hgs, mod);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
571 return;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
572 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
573 buf.writestring(dstring);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
574 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
575
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
576 version (CPP_MANGLE) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
577 void toCppMangle(OutBuffer buf, CppMangleState* cms)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
578 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
579 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
580 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
581 }
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 22
diff changeset
582 override bool isintegral()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
583 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
584 //printf("TypeBasic.isintegral('%s') x%x\n", toChars(), flags);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
585 return (flags & TFLAGS.TFLAGSintegral) != 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
586 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
587
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
588 bool isbit()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
589 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
590 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
591 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
592
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 22
diff changeset
593 override bool isfloating()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
594 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
595 return (flags & TFLAGS.TFLAGSfloating) != 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
596 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
597
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 22
diff changeset
598 override bool isreal()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
599 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
600 return (flags & TFLAGS.TFLAGSreal) != 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
601 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
602
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 22
diff changeset
603 override bool isimaginary()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
604 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
605 return (flags & TFLAGS.TFLAGSimaginary) != 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
606 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
607
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 22
diff changeset
608 override bool iscomplex()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
609 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
610 return (flags & TFLAGS.TFLAGScomplex) != 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
611 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
612
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 22
diff changeset
613 override bool isscalar()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
614 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
615 return (flags & (TFLAGS.TFLAGSintegral | TFLAGS.TFLAGSfloating)) != 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
616 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
617
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 22
diff changeset
618 override bool isunsigned()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
619 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
620 return (flags & TFLAGS.TFLAGSunsigned) != 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
621 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
622
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 22
diff changeset
623 override MATCH implicitConvTo(Type to)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
624 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
625 //printf("TypeBasic.implicitConvTo(%s) from %s\n", to.toChars(), toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
626 if (this is to)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
627 return MATCH.MATCHexact;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
628
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
629 version (DMDV2) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
630 if (ty is to.ty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
631 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
632 return (mod == to.mod) ? MATCH.MATCHexact : MATCH.MATCHconst;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
633 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
634 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
635
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
636 if (ty == TY.Tvoid || to.ty == TY.Tvoid)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
637 return MATCH.MATCHnomatch;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
638 if (to.ty == TY.Tbool)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
639 return MATCH.MATCHnomatch;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
640 if (!to.isTypeBasic())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
641 return MATCH.MATCHnomatch;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
642
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
643 TypeBasic tob = cast(TypeBasic)to;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
644 if (flags & TFLAGS.TFLAGSintegral)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
645 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
646 // Disallow implicit conversion of integers to imaginary or complex
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
647 if (tob.flags & (TFLAGS.TFLAGSimaginary | TFLAGS.TFLAGScomplex))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
648 return MATCH.MATCHnomatch;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
649
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
650 version (DMDV2) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
651 // If converting from integral to integral
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
652 if (1 && tob.flags & TFLAGS.TFLAGSintegral)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
653 { ulong sz = size(Loc(0));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
654 ulong tosz = tob.size(Loc(0));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
655
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
656 /* Can't convert to smaller size
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
657 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
658 if (sz > tosz)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
659 return MATCH.MATCHnomatch;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
660
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
661 /* Can't change sign if same size
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
662 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
663 /*if (sz == tosz && (flags ^ tob.flags) & TFLAGSunsigned)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
664 return MATCH.MATCHnomatch;*/
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
665 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
666 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
667 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
668 else if (flags & TFLAGS.TFLAGSfloating)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
669 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
670 // Disallow implicit conversion of floating point to integer
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
671 if (tob.flags & TFLAGS.TFLAGSintegral)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
672 return MATCH.MATCHnomatch;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
673
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
674 assert(tob.flags & TFLAGS.TFLAGSfloating);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
675
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
676 // Disallow implicit conversion from complex to non-complex
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
677 if (flags & TFLAGS.TFLAGScomplex && !(tob.flags & TFLAGS.TFLAGScomplex))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
678 return MATCH.MATCHnomatch;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
679
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
680 // Disallow implicit conversion of real or imaginary to complex
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
681 if (flags & (TFLAGS.TFLAGSreal | TFLAGS.TFLAGSimaginary) &&
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
682 tob.flags & TFLAGS.TFLAGScomplex)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
683 return MATCH.MATCHnomatch;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
684
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
685 // Disallow implicit conversion to-from real and imaginary
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
686 if ((flags & (TFLAGS.TFLAGSreal | TFLAGS.TFLAGSimaginary)) !=
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
687 (tob.flags & (TFLAGS.TFLAGSreal | TFLAGS.TFLAGSimaginary)))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
688 return MATCH.MATCHnomatch;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
689 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
690 return MATCH.MATCHconvert;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
691 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
692
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 22
diff changeset
693 override Expression defaultInit(Loc loc)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
694 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
695 long value = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
696
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
697 version (SNAN_DEFAULT_INIT) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
698 /*
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
699 * Use a payload which is different from the machine NaN,
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
700 * so that uninitialised variables can be
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
701 * detected even if exceptions are disabled.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
702 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
703 ushort[8] snan = [ 0, 0, 0, 0xA000, 0x7FFF, 0, 0, 0 ];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
704 /*
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
705 * Although long doubles are 10 bytes long, some
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
706 * C ABIs pad them out to 12 or even 16 bytes, so
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
707 * leave enough space in the snan array.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
708 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
709 assert(REALSIZE <= snan.sizeof);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
710 real fvalue = *cast(real*)snan.ptr;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
711 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
712
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
713 version (LOGDEFAULTINIT) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
714 printf("TypeBasic.defaultInit() '%s'\n", toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
715 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
716 switch (ty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
717 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
718 case TY.Tchar:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
719 value = 0xFF;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
720 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
721
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
722 case TY.Twchar:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
723 case TY.Tdchar:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
724 value = 0xFFFF;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
725 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
726
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
727 case TY.Timaginary32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
728 case TY.Timaginary64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
729 case TY.Timaginary80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
730 case TY.Tfloat32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
731 case TY.Tfloat64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
732 case TY.Tfloat80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
733 version (SNAN_DEFAULT_INIT) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
734 return new RealExp(loc, fvalue, this);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
735 } else {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
736 return getProperty(loc, Id.nan);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
737 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
738
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
739 case TY.Tcomplex32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
740 case TY.Tcomplex64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
741 case TY.Tcomplex80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
742 version (SNAN_DEFAULT_INIT) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
743 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
744 // Can't use fvalue + I*fvalue (the im part becomes a quiet NaN).
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
745 Complex!(real) cvalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
746 cvalue.re = fvalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
747 cvalue.im = fvalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
748
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
749 return new ComplexExp(loc, cvalue, this);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
750 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
751 } else {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
752 return getProperty(loc, Id.nan);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
753 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
754
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
755 case TY.Tvoid:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
756 error(loc, "void does not have a default initializer");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
757
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
758 default:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
759 break; ///
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
760 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
761 return new IntegerExp(loc, value, this);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
762 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
763
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 22
diff changeset
764 override bool isZeroInit(Loc loc)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
765 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
766 switch (ty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
767 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
768 case TY.Tchar:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
769 case TY.Twchar:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
770 case TY.Tdchar:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
771 case TY.Timaginary32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
772 case TY.Timaginary64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
773 case TY.Timaginary80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
774 case TY.Tfloat32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
775 case TY.Tfloat64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
776 case TY.Tfloat80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
777 case TY.Tcomplex32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
778 case TY.Tcomplex64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
779 case TY.Tcomplex80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
780 return false; // no
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
781 default:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
782 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
783 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
784
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
785 return true; // yes
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
786 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
787
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 22
diff changeset
788 override bool builtinTypeInfo()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
789 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
790 version (DMDV2) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
791 return mod ? false : true;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
792 } else {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
793 return true;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
794 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
795 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
796
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
797 // For eliminating dynamic_cast
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 22
diff changeset
798 override TypeBasic isTypeBasic()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
799 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
800 return this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
801 }
22
fd4acc376c45 Implemented object file output and linking on linux.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
802 }