annotate dmd/TypeBasic.d @ 72:2e2a5c3f943a

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