annotate dmd/TypeBasic.d @ 157:b7b61140701d

* added all missing default cases in switch statements + Lexer.getDocComment + Lexer.combineComments
author trass3r
date Thu, 16 Sep 2010 01:34:10 +0200
parents 0c8cc2a10f99
children e3afd1303184
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;
157
b7b61140701d * added all missing default cases in switch statements
trass3r
parents: 156
diff changeset
133 default:
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
134 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
135
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
136 this.dstring = d;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
137 this.flags = flags;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
138 merge();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
139 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
140
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
141 version (DumbClone) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
142 } else {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
143 Type clone()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
144 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
145 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
146 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
147 }
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 22
diff changeset
148 override Type syntaxCopy()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
149 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
150 // No semantic analysis done on basic types, no need to copy
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
151 return this;
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: 22
diff changeset
154 override ulong size(Loc loc)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
155 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
156 uint size;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
157
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
158 //printf("TypeBasic.size()\n");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
159 switch (ty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
160 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
161 case TY.Tint8:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
162 case TY.Tuns8: size = 1; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
163 case TY.Tint16:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
164 case TY.Tuns16: size = 2; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
165 case TY.Tint32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
166 case TY.Tuns32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
167 case TY.Tfloat32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
168 case TY.Timaginary32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
169 size = 4; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
170 case TY.Tint64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
171 case TY.Tuns64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
172 case TY.Tfloat64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
173 case TY.Timaginary64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
174 size = 8; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
175 case TY.Tfloat80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
176 case TY.Timaginary80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
177 size = REALSIZE; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
178 case TY.Tcomplex32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
179 size = 8; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
180 case TY.Tcomplex64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
181 size = 16; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
182 case TY.Tcomplex80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
183 size = REALSIZE * 2; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
184
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
185 case TY.Tvoid:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
186 //size = Type.size(); // error message
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
187 size = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
188 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
189
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
190 case TY.Tbool: size = 1; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
191 case TY.Tascii: size = 1; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
192 case TY.Twchar: size = 2; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
193 case TY.Tdchar: size = 4; break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
194
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
195 default:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
196 assert(0);
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;
157
b7b61140701d * added all missing default cases in switch statements
trass3r
parents: 156
diff changeset
266 default:
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
267 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
268 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
269 else if (ident is Id.min)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
270 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
271 switch (ty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
272 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
273 case TY.Tint8: ivalue = byte.min; goto Livalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
274 case TY.Tuns8: ivalue = ubyte.min; goto Livalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
275 case TY.Tint16: ivalue = short.min; goto Livalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
276 case TY.Tuns16: ivalue = ushort.min; goto Livalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
277 case TY.Tint32: ivalue = int.min; goto Livalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
278 case TY.Tuns32: ivalue = uint.min; goto Livalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
279 case TY.Tint64: ivalue = long.min; goto Livalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
280 case TY.Tuns64: ivalue = ulong.min; goto Livalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
281 case TY.Tbool: ivalue = bool.min; goto Livalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
282 case TY.Tchar: ivalue = char.min; goto Livalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
283 case TY.Twchar: ivalue = wchar.min; goto Livalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
284 case TY.Tdchar: ivalue = dchar.min; goto Livalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
285 case TY.Tcomplex32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
286 case TY.Timaginary32:
96
acd69f84627e further work
Trass3r
parents: 72
diff changeset
287 case Tfloat32:
acd69f84627e further work
Trass3r
parents: 72
diff changeset
288 case Tcomplex64:
acd69f84627e further work
Trass3r
parents: 72
diff changeset
289 case Timaginary64:
acd69f84627e further work
Trass3r
parents: 72
diff changeset
290 case Tfloat64:
acd69f84627e further work
Trass3r
parents: 72
diff changeset
291 case Tcomplex80:
acd69f84627e further work
Trass3r
parents: 72
diff changeset
292 case Timaginary80:
acd69f84627e further work
Trass3r
parents: 72
diff changeset
293 case Tfloat80:
acd69f84627e further work
Trass3r
parents: 72
diff changeset
294 // For backwards compatibility - eventually, deprecate
acd69f84627e further work
Trass3r
parents: 72
diff changeset
295 goto Lmin_normal;
156
0c8cc2a10f99 + ArrayInitializer.toAssocArrayLiteral()
trass3r
parents: 134
diff changeset
296 default:
96
acd69f84627e further work
Trass3r
parents: 72
diff changeset
297 }
acd69f84627e further work
Trass3r
parents: 72
diff changeset
298 }
acd69f84627e further work
Trass3r
parents: 72
diff changeset
299 else if (ident == Id.min_normal)
acd69f84627e further work
Trass3r
parents: 72
diff changeset
300 {
acd69f84627e further work
Trass3r
parents: 72
diff changeset
301 Lmin_normal:
acd69f84627e further work
Trass3r
parents: 72
diff changeset
302 switch (ty)
acd69f84627e further work
Trass3r
parents: 72
diff changeset
303 {
acd69f84627e further work
Trass3r
parents: 72
diff changeset
304 case Tcomplex32:
acd69f84627e further work
Trass3r
parents: 72
diff changeset
305 case Timaginary32:
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
306 case TY.Tfloat32: fvalue = float.min; goto Lfvalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
307 case TY.Tcomplex64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
308 case TY.Timaginary64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
309 case TY.Tfloat64: fvalue = double.min; goto Lfvalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
310 case TY.Tcomplex80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
311 case TY.Timaginary80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
312 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
313 default:
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
314 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
315 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
316 else if (ident is Id.nan)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
317 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
318 switch (ty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
319 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
320 case TY.Tcomplex32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
321 case TY.Tcomplex64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
322 case TY.Tcomplex80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
323 case TY.Timaginary32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
324 case TY.Timaginary64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
325 case TY.Timaginary80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
326 case TY.Tfloat32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
327 case TY.Tfloat64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
328 case TY.Tfloat80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
329 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
330 fvalue = real.nan;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
331 goto Lfvalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
332 }
157
b7b61140701d * added all missing default cases in switch statements
trass3r
parents: 156
diff changeset
333 default:
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
334 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
335 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
336 else if (ident is Id.infinity)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
337 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
338 switch (ty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
339 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
340 case TY.Tcomplex32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
341 case TY.Tcomplex64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
342 case TY.Tcomplex80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
343 case TY.Timaginary32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
344 case TY.Timaginary64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
345 case TY.Timaginary80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
346 case TY.Tfloat32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
347 case TY.Tfloat64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
348 case TY.Tfloat80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
349 fvalue = real.infinity;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
350 goto Lfvalue;
157
b7b61140701d * added all missing default cases in switch statements
trass3r
parents: 156
diff changeset
351 default:
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
352 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
353 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
354 else if (ident is Id.dig)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
355 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
356 switch (ty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
357 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
358 case TY.Tcomplex32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
359 case TY.Timaginary32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
360 case TY.Tfloat32: ivalue = float.dig; goto Lint;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
361 case TY.Tcomplex64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
362 case TY.Timaginary64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
363 case TY.Tfloat64: ivalue = double.dig; goto Lint;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
364 case TY.Tcomplex80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
365 case TY.Timaginary80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
366 case TY.Tfloat80: ivalue = real.dig; goto Lint;
157
b7b61140701d * added all missing default cases in switch statements
trass3r
parents: 156
diff changeset
367 default:
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
368 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
369 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
370 else if (ident is Id.epsilon)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
371 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
372 switch (ty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
373 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
374 case TY.Tcomplex32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
375 case TY.Timaginary32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
376 case TY.Tfloat32: fvalue = float.epsilon; goto Lfvalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
377 case TY.Tcomplex64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
378 case TY.Timaginary64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
379 case TY.Tfloat64: fvalue = double.epsilon; goto Lfvalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
380 case TY.Tcomplex80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
381 case TY.Timaginary80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
382 case TY.Tfloat80: fvalue = real.epsilon; goto Lfvalue;
157
b7b61140701d * added all missing default cases in switch statements
trass3r
parents: 156
diff changeset
383 default:
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
384 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
385 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
386 else if (ident is Id.mant_dig)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
387 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
388 switch (ty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
389 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
390 case TY.Tcomplex32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
391 case TY.Timaginary32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
392 case TY.Tfloat32: ivalue = float.mant_dig; goto Lint;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
393 case TY.Tcomplex64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
394 case TY.Timaginary64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
395 case TY.Tfloat64: ivalue = double.mant_dig; goto Lint;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
396 case TY.Tcomplex80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
397 case TY.Timaginary80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
398 case TY.Tfloat80: ivalue = real.mant_dig; goto Lint;
157
b7b61140701d * added all missing default cases in switch statements
trass3r
parents: 156
diff changeset
399 default:
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
400 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
401 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
402 else if (ident is Id.max_10_exp)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
403 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
404 switch (ty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
405 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
406 case TY.Tcomplex32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
407 case TY.Timaginary32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
408 case TY.Tfloat32: ivalue = float.max_10_exp; goto Lint;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
409 case TY.Tcomplex64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
410 case TY.Timaginary64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
411 case TY.Tfloat64: ivalue = double.max_10_exp; goto Lint;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
412 case TY.Tcomplex80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
413 case TY.Timaginary80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
414 case TY.Tfloat80: ivalue = real.max_10_exp; goto Lint;
157
b7b61140701d * added all missing default cases in switch statements
trass3r
parents: 156
diff changeset
415 default:
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
416 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
417 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
418 else if (ident is Id.max_exp)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
419 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
420 switch (ty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
421 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
422 case TY.Tcomplex32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
423 case TY.Timaginary32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
424 case TY.Tfloat32: ivalue = float.max_exp; goto Lint;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
425 case TY.Tcomplex64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
426 case TY.Timaginary64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
427 case TY.Tfloat64: ivalue = double.max_exp; goto Lint;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
428 case TY.Tcomplex80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
429 case TY.Timaginary80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
430 case TY.Tfloat80: ivalue = real.max_exp; goto Lint;
157
b7b61140701d * added all missing default cases in switch statements
trass3r
parents: 156
diff changeset
431 default:
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
432 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
433 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
434 else if (ident is Id.min_10_exp)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
435 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
436 switch (ty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
437 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
438 case TY.Tcomplex32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
439 case TY.Timaginary32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
440 case TY.Tfloat32: ivalue = float.min_10_exp; goto Lint;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
441 case TY.Tcomplex64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
442 case TY.Timaginary64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
443 case TY.Tfloat64: ivalue = double.min_10_exp; goto Lint;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
444 case TY.Tcomplex80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
445 case TY.Timaginary80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
446 case TY.Tfloat80: ivalue = real.min_10_exp; goto Lint;
157
b7b61140701d * added all missing default cases in switch statements
trass3r
parents: 156
diff changeset
447 default:
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
448 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
449 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
450 else if (ident is Id.min_exp)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
451 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
452 switch (ty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
453 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
454 case TY.Tcomplex32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
455 case TY.Timaginary32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
456 case TY.Tfloat32: ivalue = float.min_exp; goto Lint;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
457 case TY.Tcomplex64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
458 case TY.Timaginary64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
459 case TY.Tfloat64: ivalue = double.min_exp; goto Lint;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
460 case TY.Tcomplex80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
461 case TY.Timaginary80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
462 case TY.Tfloat80: ivalue = real.min_exp; goto Lint;
157
b7b61140701d * added all missing default cases in switch statements
trass3r
parents: 156
diff changeset
463 default:
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
464 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
465 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
466
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
467 Ldefault:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
468 return Type.getProperty(loc, ident);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
469
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
470 Livalue:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
471 e = new IntegerExp(loc, ivalue, this);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
472 return e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
473
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
474 Lfvalue:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
475 if (isreal() || isimaginary())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
476 e = new RealExp(loc, fvalue, this);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
477 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
478 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
479 Complex!(real) cvalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
480 cvalue.re = fvalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
481 cvalue.im = fvalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
482
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
483 //for (int i = 0; i < 20; i++)
96
acd69f84627e further work
Trass3r
parents: 72
diff changeset
484 // printf("%02x ", ((unsigned char *)&cvalue)[i]);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
485 //printf("\n");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
486 e = new ComplexExp(loc, cvalue, this);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
487 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
488 return e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
489
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
490 Lint:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
491 e = new IntegerExp(loc, ivalue, Type.tint32);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
492 return e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
493 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
494
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 22
diff changeset
495 override Expression dotExp(Scope sc, Expression e, Identifier ident)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
496 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
497 version (LOGDOTEXP) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
498 printf("TypeBasic.dotExp(e = '%s', ident = '%s')\n", e.toChars(), ident.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
499 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
500 Type t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
501
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
502 if (ident is Id.re)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
503 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
504 switch (ty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
505 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
506 case TY.Tcomplex32: t = tfloat32; goto L1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
507 case TY.Tcomplex64: t = tfloat64; goto L1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
508 case TY.Tcomplex80: t = tfloat80; goto L1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
509 L1:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
510 e = e.castTo(sc, t);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
511 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
512
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
513 case TY.Tfloat32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
514 case TY.Tfloat64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
515 case TY.Tfloat80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
516 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
517
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
518 case TY.Timaginary32: t = tfloat32; goto L2;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
519 case TY.Timaginary64: t = tfloat64; goto L2;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
520 case TY.Timaginary80: t = tfloat80; goto L2;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
521 L2:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
522 e = new RealExp(Loc(0), 0.0, t);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
523 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
524
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
525 default:
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
526 e = Type.getProperty(e.loc, ident);
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
527 break;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
528 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
529 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
530 else if (ident is Id.im)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
531 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
532 Type t2;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
533
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
534 switch (ty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
535 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
536 case TY.Tcomplex32: t = timaginary32; t2 = tfloat32; goto L3;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
537 case TY.Tcomplex64: t = timaginary64; t2 = tfloat64; goto L3;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
538 case TY.Tcomplex80: t = timaginary80; t2 = tfloat80; goto L3;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
539 L3:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
540 e = e.castTo(sc, t);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
541 e.type = t2;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
542 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
543
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
544 case TY.Timaginary32: t = tfloat32; goto L4;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
545 case TY.Timaginary64: t = tfloat64; goto L4;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
546 case TY.Timaginary80: t = tfloat80; goto L4;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
547 L4:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
548 e = e.copy();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
549 e.type = t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
550 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
551
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
552 case TY.Tfloat32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
553 case TY.Tfloat64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
554 case TY.Tfloat80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
555 e = new RealExp(Loc(0), 0.0, this);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
556 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
557
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
558 default:
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
559 e = Type.getProperty(e.loc, ident);
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
560 break;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
561 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
562 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
563 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
564 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
565 return Type.dotExp(sc, e, ident);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
566 }
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
567 e = e.semantic(sc);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
568 return e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
569 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
570
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 22
diff changeset
571 override string toChars()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
572 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
573 return Type.toChars();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
574 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
575
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 22
diff changeset
576 override void toCBuffer2(OutBuffer buf, HdrGenState* hgs, MOD mod)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
577 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
578 //printf("TypeBasic.toCBuffer2(mod = %d, this.mod = %d)\n", mod, this.mod);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
579 if (mod != this.mod)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
580 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
581 toCBuffer3(buf, hgs, mod);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
582 return;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
583 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
584 buf.writestring(dstring);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
585 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
586
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
587 version (CPP_MANGLE) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
588 void toCppMangle(OutBuffer buf, CppMangleState* cms)
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 isintegral()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
594 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
595 //printf("TypeBasic.isintegral('%s') x%x\n", toChars(), flags);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
596 return (flags & TFLAGS.TFLAGSintegral) != 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
597 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
598
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
599 bool isbit()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
600 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
601 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
602 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
603
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 22
diff changeset
604 override bool isfloating()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
605 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
606 return (flags & TFLAGS.TFLAGSfloating) != 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
607 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
608
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 22
diff changeset
609 override bool isreal()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
610 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
611 return (flags & TFLAGS.TFLAGSreal) != 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
612 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
613
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 22
diff changeset
614 override bool isimaginary()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
615 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
616 return (flags & TFLAGS.TFLAGSimaginary) != 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
617 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
618
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 22
diff changeset
619 override bool iscomplex()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
620 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
621 return (flags & TFLAGS.TFLAGScomplex) != 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
622 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
623
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 22
diff changeset
624 override bool isscalar()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
625 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
626 return (flags & (TFLAGS.TFLAGSintegral | TFLAGS.TFLAGSfloating)) != 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
627 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
628
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 22
diff changeset
629 override bool isunsigned()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
630 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
631 return (flags & TFLAGS.TFLAGSunsigned) != 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
632 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
633
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 22
diff changeset
634 override MATCH implicitConvTo(Type to)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
635 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
636 //printf("TypeBasic.implicitConvTo(%s) from %s\n", to.toChars(), toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
637 if (this is to)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
638 return MATCH.MATCHexact;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
639
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
640 version (DMDV2) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
641 if (ty is to.ty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
642 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
643 return (mod == to.mod) ? MATCH.MATCHexact : MATCH.MATCHconst;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
644 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
645 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
646
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
647 if (ty == TY.Tvoid || to.ty == TY.Tvoid)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
648 return MATCH.MATCHnomatch;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
649 if (to.ty == TY.Tbool)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
650 return MATCH.MATCHnomatch;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
651 if (!to.isTypeBasic())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
652 return MATCH.MATCHnomatch;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
653
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
654 TypeBasic tob = cast(TypeBasic)to;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
655 if (flags & TFLAGS.TFLAGSintegral)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
656 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
657 // Disallow implicit conversion of integers to imaginary or complex
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
658 if (tob.flags & (TFLAGS.TFLAGSimaginary | TFLAGS.TFLAGScomplex))
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 version (DMDV2) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
662 // If converting from integral to integral
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
663 if (1 && tob.flags & TFLAGS.TFLAGSintegral)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
664 { ulong sz = size(Loc(0));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
665 ulong tosz = tob.size(Loc(0));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
666
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
667 /* Can't convert to smaller size
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
668 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
669 if (sz > tosz)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
670 return MATCH.MATCHnomatch;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
671
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
672 /* Can't change sign if same size
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
673 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
674 /*if (sz == tosz && (flags ^ tob.flags) & TFLAGSunsigned)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
675 return MATCH.MATCHnomatch;*/
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
676 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
677 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
678 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
679 else if (flags & TFLAGS.TFLAGSfloating)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
680 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
681 // Disallow implicit conversion of floating point to integer
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
682 if (tob.flags & TFLAGS.TFLAGSintegral)
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 assert(tob.flags & TFLAGS.TFLAGSfloating);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
686
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
687 // Disallow implicit conversion from complex to non-complex
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
688 if (flags & TFLAGS.TFLAGScomplex && !(tob.flags & TFLAGS.TFLAGScomplex))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
689 return MATCH.MATCHnomatch;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
690
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
691 // Disallow implicit conversion of real or imaginary to complex
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
692 if (flags & (TFLAGS.TFLAGSreal | TFLAGS.TFLAGSimaginary) &&
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
693 tob.flags & TFLAGS.TFLAGScomplex)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
694 return MATCH.MATCHnomatch;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
695
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
696 // Disallow implicit conversion to-from real and imaginary
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
697 if ((flags & (TFLAGS.TFLAGSreal | TFLAGS.TFLAGSimaginary)) !=
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
698 (tob.flags & (TFLAGS.TFLAGSreal | TFLAGS.TFLAGSimaginary)))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
699 return MATCH.MATCHnomatch;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
700 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
701 return MATCH.MATCHconvert;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
702 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
703
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 22
diff changeset
704 override Expression defaultInit(Loc loc)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
705 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
706 long value = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
707
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
708 version (SNAN_DEFAULT_INIT) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
709 /*
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
710 * Use a payload which is different from the machine NaN,
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
711 * so that uninitialised variables can be
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
712 * detected even if exceptions are disabled.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
713 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
714 ushort[8] snan = [ 0, 0, 0, 0xA000, 0x7FFF, 0, 0, 0 ];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
715 /*
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
716 * Although long doubles are 10 bytes long, some
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
717 * C ABIs pad them out to 12 or even 16 bytes, so
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
718 * leave enough space in the snan array.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
719 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
720 assert(REALSIZE <= snan.sizeof);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
721 real fvalue = *cast(real*)snan.ptr;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
722 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
723
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
724 version (LOGDEFAULTINIT) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
725 printf("TypeBasic.defaultInit() '%s'\n", toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
726 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
727 switch (ty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
728 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
729 case TY.Tchar:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
730 value = 0xFF;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
731 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
732
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
733 case TY.Twchar:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
734 case TY.Tdchar:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
735 value = 0xFFFF;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
736 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
737
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
738 case TY.Timaginary32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
739 case TY.Timaginary64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
740 case TY.Timaginary80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
741 case TY.Tfloat32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
742 case TY.Tfloat64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
743 case TY.Tfloat80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
744 version (SNAN_DEFAULT_INIT) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
745 return new RealExp(loc, fvalue, this);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
746 } else {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
747 return getProperty(loc, Id.nan);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
748 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
749
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
750 case TY.Tcomplex32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
751 case TY.Tcomplex64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
752 case TY.Tcomplex80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
753 version (SNAN_DEFAULT_INIT) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
754 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
755 // Can't use fvalue + I*fvalue (the im part becomes a quiet NaN).
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
756 Complex!(real) cvalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
757 cvalue.re = fvalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
758 cvalue.im = fvalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
759
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
760 return new ComplexExp(loc, cvalue, this);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
761 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
762 } else {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
763 return getProperty(loc, Id.nan);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
764 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
765
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
766 case TY.Tvoid:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
767 error(loc, "void does not have a default initializer");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
768
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
769 default:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
770 break; ///
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
771 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
772 return new IntegerExp(loc, value, this);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
773 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
774
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 22
diff changeset
775 override bool isZeroInit(Loc loc)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
776 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
777 switch (ty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
778 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
779 case TY.Tchar:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
780 case TY.Twchar:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
781 case TY.Tdchar:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
782 case TY.Timaginary32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
783 case TY.Timaginary64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
784 case TY.Timaginary80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
785 case TY.Tfloat32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
786 case TY.Tfloat64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
787 case TY.Tfloat80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
788 case TY.Tcomplex32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
789 case TY.Tcomplex64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
790 case TY.Tcomplex80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
791 return false; // no
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
792 default:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
793 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
794 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
795
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
796 return true; // yes
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
797 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
798
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 22
diff changeset
799 override bool builtinTypeInfo()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
800 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
801 version (DMDV2) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
802 return mod ? false : true;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
803 } else {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
804 return true;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
805 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
806 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
807
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
808 // For eliminating dynamic_cast
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 22
diff changeset
809 override TypeBasic isTypeBasic()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
810 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
811 return this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
812 }
22
fd4acc376c45 Implemented object file output and linking on linux.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
813 }